Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
6c87b432
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c87b432
编写于
8月 29, 2018
作者:
T
tristaZero
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' of
ssh://github.com/shardingjdbc/sharding-jdbc
into dev
上级
00f441f8
1f7dafcd
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
187 addition
and
12 deletion
+187
-12
sharding-proxy/src/main/java/io/shardingsphere/proxy/Bootstrap.java
...roxy/src/main/java/io/shardingsphere/proxy/Bootstrap.java
+1
-1
sharding-proxy/src/main/java/io/shardingsphere/proxy/listener/ProxyListenerRegister.java
.../shardingsphere/proxy/listener/ProxyListenerRegister.java
+10
-8
sharding-proxy/src/test/java/io/shardingsphere/proxy/AllTests.java
...proxy/src/test/java/io/shardingsphere/proxy/AllTests.java
+9
-1
sharding-proxy/src/test/java/io/shardingsphere/proxy/config/AllConfigTests.java
...t/java/io/shardingsphere/proxy/config/AllConfigTests.java
+27
-0
sharding-proxy/src/test/java/io/shardingsphere/proxy/config/ProxyTableMetaDataConnectionManagerTest.java
...proxy/config/ProxyTableMetaDataConnectionManagerTest.java
+46
-0
sharding-proxy/src/test/java/io/shardingsphere/proxy/listener/AllListenerTests.java
...va/io/shardingsphere/proxy/listener/AllListenerTests.java
+27
-0
sharding-proxy/src/test/java/io/shardingsphere/proxy/listener/ProxyListenerRegisterTest.java
...rdingsphere/proxy/listener/ProxyListenerRegisterTest.java
+67
-0
sharding-proxy/src/test/java/io/shardingsphere/proxy/transport/AllTransportTests.java
.../io/shardingsphere/proxy/transport/AllTransportTests.java
+0
-2
未找到文件。
sharding-proxy/src/main/java/io/shardingsphere/proxy/Bootstrap.java
浏览文件 @
6c87b432
...
...
@@ -64,7 +64,7 @@ public final class Bootstrap {
public
static
void
main
(
final
String
[]
args
)
throws
InterruptedException
,
IOException
{
YamlProxyConfiguration
localConfig
=
loadLocalConfiguration
(
new
File
(
Bootstrap
.
class
.
getResource
(
getConfig
(
args
)).
getFile
()));
int
port
=
getPort
(
args
);
ProxyListenerRegister
.
register
();
new
ProxyListenerRegister
()
.
register
();
if
(
null
==
localConfig
.
getOrchestration
())
{
startWithoutRegistryCenter
(
localConfig
,
port
);
}
else
{
...
...
sharding-proxy/src/main/java/io/shardingsphere/proxy/listener/ProxyListenerRegister.java
浏览文件 @
6c87b432
...
...
@@ -20,8 +20,6 @@ package io.shardingsphere.proxy.listener;
import
io.shardingsphere.proxy.config.RuleRegistry
;
import
io.shardingsphere.transaction.listener.local.LocalTransactionListener
;
import
io.shardingsphere.transaction.listener.xa.XATransactionListener
;
import
lombok.AccessLevel
;
import
lombok.NoArgsConstructor
;
/**
* Listener register for Proxy.
...
...
@@ -29,16 +27,20 @@ import lombok.NoArgsConstructor;
* @author zhangliang
* @author panjuan
*/
@NoArgsConstructor
(
access
=
AccessLevel
.
PRIVATE
)
public
final
class
ProxyListenerRegister
{
private
final
LocalTransactionListener
localTransactionListener
=
new
LocalTransactionListener
();
private
final
XATransactionListener
xaTransactionListener
=
new
XATransactionListener
();
private
final
RuleRegistry
ruleRegistry
=
RuleRegistry
.
getInstance
();
/**
* Register all listeners.
*
*/
public
static
void
register
()
{
new
LocalTransactionListener
()
.
register
();
new
XATransactionListener
()
.
register
();
RuleRegistry
.
getInstance
()
.
register
();
public
void
register
()
{
localTransactionListener
.
register
();
xaTransactionListener
.
register
();
ruleRegistry
.
register
();
}
}
sharding-proxy/src/test/java/io/shardingsphere/proxy/AllTests.java
浏览文件 @
6c87b432
...
...
@@ -17,12 +17,20 @@
package
io.shardingsphere.proxy
;
import
io.shardingsphere.proxy.config.AllConfigTests
;
import
io.shardingsphere.proxy.listener.AllListenerTests
;
import
io.shardingsphere.proxy.runtime.AllRuntimeTests
;
import
io.shardingsphere.proxy.transport.AllTransportTests
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
(
AllTransportTests
.
class
)
@SuiteClasses
({
AllRuntimeTests
.
class
,
AllListenerTests
.
class
,
AllConfigTests
.
class
,
AllTransportTests
.
class
})
public
final
class
AllTests
{
}
sharding-proxy/src/test/java/io/shardingsphere/proxy/config/AllConfigTests.java
0 → 100644
浏览文件 @
6c87b432
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
io.shardingsphere.proxy.config
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
(
ProxyTableMetaDataConnectionManagerTest
.
class
)
public
final
class
AllConfigTests
{
}
sharding-proxy/src/test/java/io/shardingsphere/proxy/config/ProxyTableMetaDataConnectionManagerTest.java
0 → 100644
浏览文件 @
6c87b432
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
io.shardingsphere.proxy.config
;
import
io.shardingsphere.proxy.backend.jdbc.datasource.JDBCBackendDataSource
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.sql.Connection
;
import
java.sql.SQLException
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
final
class
ProxyTableMetaDataConnectionManagerTest
{
@Mock
private
JDBCBackendDataSource
backendDataSource
;
@Test
public
void
assertGetConnection
()
throws
SQLException
{
Connection
connection
=
mock
(
Connection
.
class
);
when
(
backendDataSource
.
getConnection
(
"ds_name"
)).
thenReturn
(
connection
);
assertThat
(
new
ProxyTableMetaDataConnectionManager
(
backendDataSource
).
getConnection
(
"ds_name"
),
is
(
connection
));
}
}
sharding-proxy/src/test/java/io/shardingsphere/proxy/listener/AllListenerTests.java
0 → 100644
浏览文件 @
6c87b432
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
io.shardingsphere.proxy.listener
;
import
org.junit.runner.RunWith
;
import
org.junit.runners.Suite
;
import
org.junit.runners.Suite.SuiteClasses
;
@RunWith
(
Suite
.
class
)
@SuiteClasses
(
ProxyListenerRegisterTest
.
class
)
public
final
class
AllListenerTests
{
}
sharding-proxy/src/test/java/io/shardingsphere/proxy/listener/ProxyListenerRegisterTest.java
0 → 100644
浏览文件 @
6c87b432
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* </p>
*/
package
io.shardingsphere.proxy.listener
;
import
io.shardingsphere.proxy.config.RuleRegistry
;
import
io.shardingsphere.transaction.listener.local.LocalTransactionListener
;
import
io.shardingsphere.transaction.listener.xa.XATransactionListener
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.Mock
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
java.lang.reflect.Field
;
import
static
org
.
mockito
.
Mockito
.
verify
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
final
class
ProxyListenerRegisterTest
{
private
final
ProxyListenerRegister
proxyListenerRegister
=
new
ProxyListenerRegister
();
@Mock
private
LocalTransactionListener
localTransactionListener
;
@Mock
private
XATransactionListener
xaTransactionListener
;
@Mock
private
RuleRegistry
ruleRegistry
;
@Before
public
void
setUp
()
throws
ReflectiveOperationException
{
setField
(
"localTransactionListener"
,
localTransactionListener
);
setField
(
"xaTransactionListener"
,
xaTransactionListener
);
setField
(
"ruleRegistry"
,
ruleRegistry
);
}
private
void
setField
(
final
String
fieldName
,
final
Object
fieldValue
)
throws
ReflectiveOperationException
{
Field
field
=
ProxyListenerRegister
.
class
.
getDeclaredField
(
fieldName
);
field
.
setAccessible
(
true
);
field
.
set
(
proxyListenerRegister
,
fieldValue
);
}
@Test
public
void
assertRegister
()
{
proxyListenerRegister
.
register
();
verify
(
localTransactionListener
).
register
();
verify
(
xaTransactionListener
).
register
();
verify
(
ruleRegistry
).
register
();
}
}
sharding-proxy/src/test/java/io/shardingsphere/proxy/transport/AllTransportTests.java
浏览文件 @
6c87b432
...
...
@@ -17,7 +17,6 @@
package
io.shardingsphere.proxy.transport
;
import
io.shardingsphere.proxy.runtime.AllRuntimeTests
;
import
io.shardingsphere.proxy.transport.common.codec.AllCommonCodecTests
;
import
io.shardingsphere.proxy.transport.mysql.codec.MySQLPacketCodecTest
;
import
io.shardingsphere.proxy.transport.mysql.constant.AllMySQLConstantTests
;
...
...
@@ -28,7 +27,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith
(
Suite
.
class
)
@SuiteClasses
({
AllRuntimeTests
.
class
,
AllCommonCodecTests
.
class
,
AllMySQLConstantTests
.
class
,
MySQLPacketCodecTest
.
class
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录