Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
597b89b9
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,发现更多精彩内容 >>
提交
597b89b9
编写于
8月 18, 2020
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor SpringNamespaceTest
上级
4a560b38
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
78 addition
and
500 deletion
+78
-500
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/SpringNamespaceTest.java
...org/apache/shardingsphere/spring/SpringNamespaceTest.java
+44
-218
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/application-context.xml
...rc/test/resources/META-INF/spring/application-context.xml
+32
-157
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/datasource/dataSource.xml
.../test/resources/META-INF/spring/datasource/dataSource.xml
+0
-31
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/datasource/masterSlaveDataSource.xml
...rces/META-INF/spring/datasource/masterSlaveDataSource.xml
+0
-36
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/conf/rdb/conf.properties
...ing-namespace/src/test/resources/conf/rdb/conf.properties
+2
-11
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/conf/rdb/master_slave_conf.properties
.../src/test/resources/conf/rdb/master_slave_conf.properties
+0
-47
未找到文件。
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/java/org/apache/shardingsphere/spring/SpringNamespaceTest.java
浏览文件 @
597b89b9
...
...
@@ -19,34 +19,20 @@ package org.apache.shardingsphere.spring;
import
org.apache.shardingsphere.driver.jdbc.core.datasource.ShardingSphereDataSource
;
import
org.apache.shardingsphere.encrypt.rule.EncryptRule
;
import
org.apache.shardingsphere.infra.config.properties.ConfigurationPropertyKey
;
import
org.apache.shardingsphere.infra.datanode.DataNode
;
import
org.apache.shardingsphere.infra.rule.ShardingSphereRule
;
import
org.apache.shardingsphere.kernel.context.SchemaContexts
;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.ComplexShardingStrategyConfiguration
;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.HintShardingStrategyConfiguration
;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.NoneShardingStrategyConfiguration
;
import
org.apache.shardingsphere.sharding.api.config.strategy.sharding.StandardShardingStrategyConfiguration
;
import
org.apache.shardingsphere.sharding.rule.BindingTableRule
;
import
org.apache.shardingsphere.masterslave.rule.MasterSlaveRule
;
import
org.apache.shardingsphere.sharding.rule.ShardingRule
;
import
org.apache.shardingsphere.sharding.rule.TableRule
;
import
org.apache.shardingsphere.sharding.spi.KeyGenerateAlgorithm
;
import
org.apache.shardingsphere.sharding.strategy.none.NoneShardingStrategy
;
import
org.apache.shardingsphere.spring.fixture.IncrementKeyGenerateAlgorithm
;
import
org.apache.shardingsphere.spring.transaction.ShardingTransactionTypeScanner
;
import
org.junit.Test
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests
;
import
javax.sql.DataSource
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.LinkedList
;
import
java.util.Map
;
import
static
org
.
hamcrest
.
CoreMatchers
.
instanceOf
;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertFalse
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
@@ -54,221 +40,61 @@ import static org.junit.Assert.assertTrue;
@ContextConfiguration
(
locations
=
"classpath:META-INF/spring/application-context.xml"
)
public
final
class
SpringNamespaceTest
extends
AbstractJUnit4SpringContextTests
{
@Test
public
void
assertKeyGenerateAlgorithm
()
{
assertThat
(
applicationContext
.
getBean
(
"incrementAlgorithm"
),
instanceOf
(
KeyGenerateAlgorithm
.
class
));
KeyGenerateAlgorithm
incrementKeyGenerateAlgorithm
=
(
KeyGenerateAlgorithm
)
applicationContext
.
getBean
(
"incrementAlgorithm"
);
KeyGenerateAlgorithm
directIncrementKeyGenerateAlgorithm
=
new
IncrementKeyGenerateAlgorithm
();
assertThat
(
directIncrementKeyGenerateAlgorithm
.
generateKey
(),
is
(
incrementKeyGenerateAlgorithm
.
generateKey
()));
}
@Test
public
void
assertStandardStrategy
()
{
StandardShardingStrategyConfiguration
standardStrategy
=
applicationContext
.
getBean
(
"standardStrategy"
,
StandardShardingStrategyConfiguration
.
class
);
assertThat
(
standardStrategy
.
getShardingColumn
(),
is
(
"user_id"
));
assertThat
(
standardStrategy
.
getShardingAlgorithmName
(),
is
(
"standardModuloDatabaseShardingAlgorithm"
));
}
@Test
public
void
assertRangeStandardStrategy
()
{
StandardShardingStrategyConfiguration
rangeStandardStrategy
=
applicationContext
.
getBean
(
"rangeStandardStrategy"
,
StandardShardingStrategyConfiguration
.
class
);
assertThat
(
rangeStandardStrategy
.
getShardingColumn
(),
is
(
"order_id"
));
assertThat
(
rangeStandardStrategy
.
getShardingAlgorithmName
(),
is
(
"standardModuloTableShardingAlgorithm"
));
}
@Test
public
void
assertComplexStrategy
()
{
ComplexShardingStrategyConfiguration
complexStrategy
=
applicationContext
.
getBean
(
"complexStrategy"
,
ComplexShardingStrategyConfiguration
.
class
);
assertThat
(
complexStrategy
.
getShardingColumns
(),
is
(
"order_id,user_id"
));
assertThat
(
complexStrategy
.
getShardingAlgorithmName
(),
is
(
"defaultComplexKeysShardingAlgorithm"
));
}
@Test
public
void
assertInlineStrategy
()
{
StandardShardingStrategyConfiguration
inlineStrategy
=
applicationContext
.
getBean
(
"inlineStrategy"
,
StandardShardingStrategyConfiguration
.
class
);
assertThat
(
inlineStrategy
.
getShardingColumn
(),
is
(
"order_id"
));
assertThat
(
inlineStrategy
.
getShardingAlgorithmName
(),
is
(
"inlineStrategyShardingAlgorithm"
));
}
@Resource
private
ShardingSphereDataSource
dataSource
;
@Test
public
void
assertHintStrategy
()
{
HintShardingStrategyConfiguration
hintStrategy
=
applicationContext
.
getBean
(
"hintStrategy"
,
HintShardingStrategyConfiguration
.
class
);
assertThat
(
hintStrategy
.
getShardingAlgorithmName
(),
is
(
"defaultHintShardingAlgorithm"
));
public
void
assertShardingSphereDataSource
()
{
assertDataSourceMap
();
Collection
<
ShardingSphereRule
>
rules
=
dataSource
.
getSchemaContexts
().
getDefaultSchemaContext
().
getSchema
().
getRules
();
assertThat
(
rules
.
size
(),
is
(
3
));
for
(
ShardingSphereRule
each
:
rules
)
{
if
(
each
instanceof
ShardingRule
)
{
assertShardingRule
((
ShardingRule
)
each
);
}
else
if
(
each
instanceof
MasterSlaveRule
)
{
assertMasterSlaveRule
((
MasterSlaveRule
)
each
);
}
else
if
(
each
instanceof
EncryptRule
)
{
assertEncryptRule
((
EncryptRule
)
each
);
}
}
}
@Test
public
void
assertNoneStrategy
()
{
applicationContext
.
getBean
(
"noneStrategy"
,
NoneShardingStrategyConfiguration
.
class
);
private
void
assertDataSourceMap
()
{
assertThat
(
dataSource
.
getDataSourceMap
().
size
(),
is
(
6
));
assertTrue
(
dataSource
.
getDataSourceMap
().
containsKey
(
"ds_0_master"
));
assertTrue
(
dataSource
.
getDataSourceMap
().
containsKey
(
"ds_0_slave_0"
));
assertTrue
(
dataSource
.
getDataSourceMap
().
containsKey
(
"ds_0_slave_1"
));
assertTrue
(
dataSource
.
getDataSourceMap
().
containsKey
(
"ds_1_master"
));
assertTrue
(
dataSource
.
getDataSourceMap
().
containsKey
(
"ds_1_slave_0"
));
assertTrue
(
dataSource
.
getDataSourceMap
().
containsKey
(
"ds_1_slave_1"
));
}
@Test
public
void
assertSimpleShardingSphereDataSource
()
{
Map
<
String
,
DataSource
>
dataSourceMap
=
getDataSourceMap
(
"simpleShardingDataSource"
);
assertNotNull
(
dataSourceMap
.
get
(
"dbtbl_0"
));
Iterator
<
ShardingSphereRule
>
rules
=
getRules
(
"simpleShardingDataSource"
).
iterator
();
ShardingRule
shardingRule
=
(
ShardingRule
)
rules
.
next
();
assertThat
(
shardingRule
.
getTableRules
().
size
(),
is
(
1
));
assertThat
(
shardingRule
.
getTableRules
().
iterator
().
next
().
getLogicTable
(),
is
(
"t_order"
));
EncryptRule
encryptRule
=
(
EncryptRule
)
rules
.
next
();
assertThat
(
encryptRule
.
getEncryptTableNames
().
size
(),
is
(
1
));
assertTrue
(
encryptRule
.
getEncryptTableNames
().
contains
(
"t_order"
));
assertFalse
(
rules
.
hasNext
());
private
void
assertShardingRule
(
final
ShardingRule
rule
)
{
assertThat
(
rule
.
getTableRules
().
size
(),
is
(
1
));
assertThat
(
rule
.
getTableRule
(
"t_order"
).
getActualDataNodes
(),
is
(
Arrays
.
asList
(
new
DataNode
(
"ds_0.t_order_0"
),
new
DataNode
(
"ds_0.t_order_1"
),
new
DataNode
(
"ds_0.t_order_2"
),
new
DataNode
(
"ds_0.t_order_3"
),
new
DataNode
(
"ds_1.t_order_0"
),
new
DataNode
(
"ds_1.t_order_1"
),
new
DataNode
(
"ds_1.t_order_2"
),
new
DataNode
(
"ds_1.t_order_3"
))));
assertThat
(
rule
.
getTableRule
(
"t_order"
).
getDatabaseShardingStrategy
().
getShardingAlgorithm
().
getProps
().
getProperty
(
"algorithm.expression"
),
is
(
"ds_$->{user_id % 2}"
));
assertThat
(
rule
.
getTableRule
(
"t_order"
).
getTableShardingStrategy
().
getShardingAlgorithm
().
getProps
().
getProperty
(
"algorithm.expression"
),
is
(
"t_order_$->{order_id % 4}"
));
}
@Test
public
void
assertShardingRuleWithAttributesDataSource
()
{
Map
<
String
,
DataSource
>
dataSourceMap
=
getDataSourceMap
(
"shardingRuleWithAttributesDataSource"
);
assertNotNull
(
dataSourceMap
.
get
(
"dbtbl_0"
));
assertNotNull
(
dataSourceMap
.
get
(
"dbtbl_1"
));
ShardingRule
shardingRule
=
getShardingRule
(
"shardingRuleWithAttributesDataSource"
);
assertThat
(
shardingRule
.
getDefaultDatabaseShardingStrategy
().
getShardingColumns
().
toArray
(
new
String
[]{}),
is
(
new
String
[]{
applicationContext
.
getBean
(
"standardStrategy"
,
StandardShardingStrategyConfiguration
.
class
).
getShardingColumn
()}));
assertThat
(
shardingRule
.
getDefaultTableShardingStrategy
().
getShardingColumns
().
toArray
(
new
String
[]{}),
is
(
new
String
[]{
applicationContext
.
getBean
(
"inlineStrategy"
,
StandardShardingStrategyConfiguration
.
class
).
getShardingColumn
()}));
assertThat
(
shardingRule
.
getDefaultKeyGenerateAlgorithm
(),
instanceOf
(
IncrementKeyGenerateAlgorithm
.
class
));
private
void
assertMasterSlaveRule
(
final
MasterSlaveRule
rule
)
{
assertTrue
(
rule
.
findDataSourceRule
(
"ds_0"
).
isPresent
());
assertThat
(
rule
.
findDataSourceRule
(
"ds_0"
).
get
().
getMasterDataSourceName
(),
is
(
"ds_0_master"
));
assertThat
(
rule
.
findDataSourceRule
(
"ds_0"
).
get
().
getSlaveDataSourceNames
(),
is
(
Arrays
.
asList
(
"ds_0_slave_0"
,
"ds_0_slave_1"
)));
assertTrue
(
rule
.
findDataSourceRule
(
"ds_1"
).
isPresent
());
assertThat
(
rule
.
findDataSourceRule
(
"ds_1"
).
get
().
getMasterDataSourceName
(),
is
(
"ds_1_master"
));
assertThat
(
rule
.
findDataSourceRule
(
"ds_1"
).
get
().
getSlaveDataSourceNames
(),
is
(
Arrays
.
asList
(
"ds_1_slave_0"
,
"ds_1_slave_1"
)));
}
@Test
public
void
assertAutoShardingDataSource
()
{
Map
<
String
,
DataSource
>
dataSourceMap
=
getDataSourceMap
(
"autoShardingDataSource"
);
assertNotNull
(
dataSourceMap
.
get
(
"dbtbl_0"
));
assertNotNull
(
dataSourceMap
.
get
(
"dbtbl_1"
));
ShardingRule
shardingRule
=
getShardingRule
(
"autoShardingDataSource"
);
assertThat
(
shardingRule
.
getTableRules
().
size
(),
is
(
1
));
TableRule
tableRule
=
shardingRule
.
getTableRules
().
iterator
().
next
();
assertThat
(
tableRule
.
getLogicTable
(),
is
(
"t_order"
));
assertThat
(
tableRule
.
getActualDataNodes
().
size
(),
is
(
4
));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_0"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_1"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_2"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_3"
)));
assertThat
(
tableRule
.
getDatabaseShardingStrategy
(),
instanceOf
(
NoneShardingStrategy
.
class
));
assertThat
(
tableRule
.
getTableShardingStrategy
().
getShardingColumns
().
toArray
(
new
String
[]{}),
is
(
new
String
[]{
applicationContext
.
getBean
(
"inlineStrategy"
,
StandardShardingStrategyConfiguration
.
class
).
getShardingColumn
()}));
assertTrue
(
tableRule
.
getGenerateKeyColumn
().
isPresent
());
assertThat
(
tableRule
.
getGenerateKeyColumn
().
get
(),
is
(
"order_id"
));
assertThat
(
tableRule
.
getKeyGeneratorName
(),
is
(
"incrementAlgorithm"
));
}
@Test
public
void
assertTableRuleWithAttributesDataSource
()
{
ShardingRule
shardingRule
=
getShardingRule
(
"tableRuleWithAttributesDataSource"
);
assertThat
(
shardingRule
.
getTableRules
().
size
(),
is
(
1
));
TableRule
tableRule
=
shardingRule
.
getTableRules
().
iterator
().
next
();
assertThat
(
tableRule
.
getLogicTable
(),
is
(
"t_order"
));
assertThat
(
tableRule
.
getActualDataNodes
().
size
(),
is
(
8
));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_0"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_1"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_2"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_3"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_0"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_1"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_2"
)));
assertTrue
(
tableRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_3"
)));
assertThat
(
tableRule
.
getDatabaseShardingStrategy
().
getShardingColumns
().
toArray
(
new
String
[]{}),
is
(
new
String
[]{
applicationContext
.
getBean
(
"standardStrategy"
,
StandardShardingStrategyConfiguration
.
class
).
getShardingColumn
()}));
assertThat
(
tableRule
.
getTableShardingStrategy
().
getShardingColumns
().
toArray
(
new
String
[]{}),
is
(
new
String
[]{
applicationContext
.
getBean
(
"inlineStrategy"
,
StandardShardingStrategyConfiguration
.
class
).
getShardingColumn
()}));
assertTrue
(
tableRule
.
getGenerateKeyColumn
().
isPresent
());
assertThat
(
tableRule
.
getGenerateKeyColumn
().
get
(),
is
(
"order_id"
));
assertThat
(
tableRule
.
getKeyGeneratorName
(),
is
(
"incrementAlgorithm"
));
}
@Test
public
void
assertMultiTableRulesDataSource
()
{
ShardingRule
shardingRule
=
getShardingRule
(
"multiTableRulesDataSource"
);
assertThat
(
shardingRule
.
getTableRules
().
size
(),
is
(
2
));
Iterator
<
TableRule
>
tableRules
=
shardingRule
.
getTableRules
().
iterator
();
assertThat
(
tableRules
.
next
().
getLogicTable
(),
is
(
"t_order"
));
assertThat
(
tableRules
.
next
().
getLogicTable
(),
is
(
"t_order_item"
));
}
@Test
public
void
assertBindingTableRuleDatasource
()
{
ShardingRule
shardingRule
=
getShardingRule
(
"bindingTableRuleDatasource"
);
assertThat
(
shardingRule
.
getBindingTableRules
().
size
(),
is
(
1
));
BindingTableRule
bindingTableRule
=
shardingRule
.
getBindingTableRules
().
iterator
().
next
();
assertThat
(
bindingTableRule
.
getBindingActualTable
(
"dbtbl_0"
,
"t_order"
,
"t_order_item"
),
is
(
"t_order"
));
assertThat
(
bindingTableRule
.
getBindingActualTable
(
"dbtbl_1"
,
"t_order"
,
"t_order_item"
),
is
(
"t_order"
));
}
@Test
public
void
assertMultiBindingTableRulesDatasource
()
{
ShardingRule
shardingRule
=
getShardingRule
(
"multiBindingTableRulesDatasource"
);
assertThat
(
shardingRule
.
getBindingTableRules
().
size
(),
is
(
2
));
Iterator
<
BindingTableRule
>
bindingTableRules
=
shardingRule
.
getBindingTableRules
().
iterator
();
BindingTableRule
orderRule
=
bindingTableRules
.
next
();
assertThat
(
orderRule
.
getBindingActualTable
(
"dbtbl_0"
,
"t_order"
,
"t_order_item"
),
is
(
"t_order"
));
assertThat
(
orderRule
.
getBindingActualTable
(
"dbtbl_1"
,
"t_order"
,
"t_order_item"
),
is
(
"t_order"
));
BindingTableRule
userRule
=
bindingTableRules
.
next
();
assertThat
(
userRule
.
getBindingActualTable
(
"dbtbl_0"
,
"t_user"
,
"t_user_detail"
),
is
(
"t_user"
));
assertThat
(
userRule
.
getBindingActualTable
(
"dbtbl_1"
,
"t_user"
,
"t_user_detail"
),
is
(
"t_user"
));
}
@Test
public
void
assertBroadcastTableRuleDatasource
()
{
ShardingRule
shardingRule
=
getShardingRule
(
"broadcastTableRuleDatasource"
);
assertThat
(
shardingRule
.
getBroadcastTables
().
size
(),
is
(
1
));
assertThat
(
shardingRule
.
getBroadcastTables
().
iterator
().
next
(),
is
(
"t_config"
));
}
@Test
public
void
assertMultiBroadcastTableRulesDatasource
()
{
ShardingRule
shardingRule
=
getShardingRule
(
"multiBroadcastTableRulesDatasource"
);
assertThat
(
shardingRule
.
getBroadcastTables
().
size
(),
is
(
2
));
assertThat
(((
LinkedList
<
String
>)
shardingRule
.
getBroadcastTables
()).
get
(
0
),
is
(
"t_config1"
));
assertThat
(((
LinkedList
<
String
>)
shardingRule
.
getBroadcastTables
()).
get
(
1
),
is
(
"t_config2"
));
}
@Test
public
void
assertPropsDataSource
()
{
ShardingSphereDataSource
shardingSphereDataSource
=
applicationContext
.
getBean
(
"propsDataSource"
,
ShardingSphereDataSource
.
class
);
SchemaContexts
schemaContexts
=
shardingSphereDataSource
.
getSchemaContexts
();
assertTrue
(
schemaContexts
.
getProps
().<
Boolean
>
getValue
(
ConfigurationPropertyKey
.
SQL_SHOW
));
boolean
showSql
=
schemaContexts
.
getProps
().
getValue
(
ConfigurationPropertyKey
.
SQL_SHOW
);
assertTrue
(
showSql
);
int
executorSize
=
schemaContexts
.
getProps
().
getValue
(
ConfigurationPropertyKey
.
EXECUTOR_SIZE
);
assertThat
(
executorSize
,
is
(
10
));
}
@Test
public
void
assertShardingSphereDataSourceType
()
{
assertNotNull
(
applicationContext
.
getBean
(
"simpleShardingDataSource"
,
ShardingSphereDataSource
.
class
));
}
@Test
public
void
assertDefaultActualDataNodes
()
{
ShardingSphereDataSource
shardingSphereDataSource
=
applicationContext
.
getBean
(
"multiTableRulesDataSource"
,
ShardingSphereDataSource
.
class
);
SchemaContexts
schemaContexts
=
shardingSphereDataSource
.
getSchemaContexts
();
ShardingRule
shardingRule
=
(
ShardingRule
)
schemaContexts
.
getDefaultSchemaContext
().
getSchema
().
getRules
().
iterator
().
next
();
assertThat
(
shardingRule
.
getTableRules
().
size
(),
is
(
2
));
Iterator
<
TableRule
>
tableRules
=
shardingRule
.
getTableRules
().
iterator
();
TableRule
orderRule
=
tableRules
.
next
();
assertThat
(
orderRule
.
getActualDataNodes
().
size
(),
is
(
2
));
assertTrue
(
orderRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order"
)));
assertTrue
(
orderRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order"
)));
TableRule
orderItemRule
=
tableRules
.
next
();
assertThat
(
orderItemRule
.
getActualDataNodes
().
size
(),
is
(
2
));
assertTrue
(
orderItemRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_0"
,
"t_order_item"
)));
assertTrue
(
orderItemRule
.
getActualDataNodes
().
contains
(
new
DataNode
(
"dbtbl_1"
,
"t_order_item"
)));
private
void
assertEncryptRule
(
final
EncryptRule
rule
)
{
assertThat
(
rule
.
getCipherColumn
(
"t_order"
,
"pwd"
),
is
(
"pwd_cipher"
));
assertTrue
(
rule
.
findEncryptor
(
"t_order"
,
"pwd"
).
isPresent
());
assertThat
(
rule
.
findEncryptor
(
"t_order"
,
"pwd"
).
get
().
getProps
().
getProperty
(
"aes.key.value"
),
is
(
"123456"
));
}
@Test
public
void
assertShardingTransactionTypeScanner
()
{
assertNotNull
(
applicationContext
.
getBean
(
ShardingTransactionTypeScanner
.
class
));
}
private
Map
<
String
,
DataSource
>
getDataSourceMap
(
final
String
dataSourceName
)
{
ShardingSphereDataSource
shardingSphereDataSource
=
applicationContext
.
getBean
(
dataSourceName
,
ShardingSphereDataSource
.
class
);
return
shardingSphereDataSource
.
getDataSourceMap
();
}
private
ShardingRule
getShardingRule
(
final
String
dataSourceName
)
{
ShardingSphereDataSource
shardingSphereDataSource
=
applicationContext
.
getBean
(
dataSourceName
,
ShardingSphereDataSource
.
class
);
return
(
ShardingRule
)
shardingSphereDataSource
.
getSchemaContexts
().
getDefaultSchemaContext
().
getSchema
().
getRules
().
iterator
().
next
();
}
private
Collection
<
ShardingSphereRule
>
getRules
(
final
String
dataSourceName
)
{
return
applicationContext
.
getBean
(
dataSourceName
,
ShardingSphereDataSource
.
class
).
getSchemaContexts
().
getDefaultSchemaContext
().
getSchema
().
getRules
();
}
}
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/application-context.xml
浏览文件 @
597b89b9
...
...
@@ -18,12 +18,15 @@
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:shardingsphere=
"http://shardingsphere.apache.org/schema/shardingsphere/datasource"
xmlns:sharding=
"http://shardingsphere.apache.org/schema/shardingsphere/sharding"
xmlns:master-slave=
"http://shardingsphere.apache.org/schema/shardingsphere/masterslave"
xmlns:encrypt=
"http://shardingsphere.apache.org/schema/shardingsphere/encrypt"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://shardingsphere.apache.org/schema/shardingsphere/datasource
http://shardingsphere.apache.org/schema/shardingsphere/datasource/datasource.xsd
http://shardingsphere.apache.org/schema/shardingsphere/sharding
...
...
@@ -33,184 +36,56 @@
http://shardingsphere.apache.org/schema/shardingsphere/encrypt
http://shardingsphere.apache.org/schema/shardingsphere/encrypt/encrypt.xsd
"
>
<import
resource=
"datasource/dataSource.xml"
/>
<import
resource=
"datasource/masterSlaveDataSource.xml"
/>
<context:property-placeholder
location=
"classpath:conf/rdb/conf.properties"
/>
<sharding:sharding-algorithm
id=
"standardModuloDatabaseShardingAlgorithm"
type=
"STANDARD_TEST_DB"
/>
<sharding:sharding-algorithm
id=
"standardModuloTableShardingAlgorithm"
type=
"STANDARD_TEST_TBL"
/>
<sharding:sharding-algorithm
id=
"defaultComplexKeysShardingAlgorithm"
type=
"COMPLEX_TEST"
/>
<sharding:sharding-algorithm
id=
"defaultHintShardingAlgorithm"
type=
"HINT_TEST"
/>
<sharding:sharding-algorithm
id=
"inlineStrategyShardingAlgorithm"
type=
"INLINE"
>
<bean
id=
"ds_0_master"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"ds_0_slave_0"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"ds_0_slave_1"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"ds_1_master"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"ds_1_slave_0"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"ds_1_slave_1"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<sharding:sharding-algorithm
id=
"dataSourceShardingAlgorithm"
type=
"INLINE"
>
<props>
<prop
key=
"algorithm.expression"
>
t_order_${order_id % 4
}
</prop>
<prop
key=
"algorithm.expression"
>
ds_$->{user_id % 2
}
</prop>
</props>
</sharding:sharding-algorithm>
<sharding:sharding-algorithm
id=
"
modStrategyShardingAlgorithm"
type=
"MOD
"
>
<sharding:sharding-algorithm
id=
"
orderTableShardingAlgorithm"
type=
"INLINE
"
>
<props>
<prop
key=
"
sharding.count"
>
4
</prop>
<prop
key=
"
algorithm.expression"
>
t_order_$->{order_id % 4}
</prop>
</props>
</sharding:sharding-algorithm>
<sharding:key-generate-algorithm
id=
"incrementAlgorithm"
type=
"INCREMENT"
/>
<sharding:standard-strategy
id=
"standardStrategy"
sharding-column=
"user_id"
algorithm-ref=
"standardModuloDatabaseShardingAlgorithm"
/>
<sharding:standard-strategy
id=
"rangeStandardStrategy"
sharding-column=
"order_id"
algorithm-ref=
"standardModuloTableShardingAlgorithm"
/>
<sharding:standard-strategy
id=
"inlineStrategy"
sharding-column=
"order_id"
algorithm-ref=
"inlineStrategyShardingAlgorithm"
/>
<sharding:standard-strategy
id=
"modStrategy"
sharding-column=
"order_id"
algorithm-ref=
"modStrategyShardingAlgorithm"
/>
<sharding:complex-strategy
id=
"complexStrategy"
sharding-columns=
"order_id,user_id"
algorithm-ref=
"defaultComplexKeysShardingAlgorithm"
/>
<sharding:hint-strategy
id=
"hintStrategy"
algorithm-ref=
"defaultHintShardingAlgorithm"
/>
<sharding:none-strategy
id=
"noneStrategy"
/>
<sharding:standard-strategy
id=
"dataSourceShardingStrategy"
sharding-column=
"user_id"
algorithm-ref=
"dataSourceShardingAlgorithm"
/>
<sharding:standard-strategy
id=
"orderTableShardingStrategy"
sharding-column=
"order_id"
algorithm-ref=
"orderTableShardingAlgorithm"
/>
<sharding:key-generate-strategy
id=
"defaultKeyGenerateStrategy"
column=
"id"
algorithm-ref=
"incrementAlgorithm"
/>
<sharding:key-generate-strategy
id=
"orderKeyGenerator"
column=
"order_id"
algorithm-ref=
"incrementAlgorithm"
/>
<master-slave:load-balance-algorithm
id=
"randomLoadBalanceAlgorithm"
type=
"RANDOM"
/>
<sharding:rule
id=
"simpleShardingDataSourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
</sharding:table-rules>
</sharding:rule>
<sharding:rule
id=
"autoShardingDataSourceWithAutoTableRule"
>
<sharding:auto-table-rules>
<sharding:auto-table-rule
logic-table=
"t_order"
actual-data-sources=
"dbtbl_0, dbtbl_1"
sharding-strategy-ref=
"modStrategy"
key-generate-strategy-ref=
"orderKeyGenerator"
/>
</sharding:auto-table-rules>
</sharding:rule>
<encrypt:encrypt-algorithm
id=
"aes_encryptor"
type=
"AES"
>
<encrypt:encrypt-algorithm
id=
"aesEncryptor"
type=
"AES"
>
<props>
<prop
key=
"aes.key.value"
>
123456
</prop>
<prop
key=
"aes.key.value"
>
${aes.key.value}
</prop>
</props>
</encrypt:encrypt-algorithm>
<encrypt:encrypt-algorithm
id=
"md5_encryptor"
type=
"MD5"
/>
<encrypt:rule
id=
"simpleShardingDataSourceEncryptRule"
>
<encrypt:table
name=
"t_order"
>
<encrypt:column
logic-column=
"user_id"
cipher-column=
"user_encrypt"
assisted-query-column=
"user_assisted"
plain-column=
"user_decrypt"
encrypt-algorithm-ref=
"aes_encryptor"
/>
<encrypt:column
logic-column=
"order_id"
cipher-column=
"order_encrypt"
assisted-query-column=
"order_assisted"
plain-column=
"order_decrypt"
encrypt-algorithm-ref=
"md5_encryptor"
/>
</encrypt:table>
</encrypt:rule>
<shardingsphere:data-source
id=
"simpleShardingDataSource"
data-source-names=
"dbtbl_0"
rule-refs=
"simpleShardingDataSourceShardingRule, simpleShardingDataSourceEncryptRule"
/>
<shardingsphere:data-source
id=
"autoShardingDataSource"
data-source-names=
"dbtbl_0, dbtbl_1"
rule-refs=
"autoShardingDataSourceWithAutoTableRule"
/>
<sharding:rule
id=
"
masterSlaveShardingDataSourceByDefaultStrategyShardingRule"
default-key-generate-strategy-ref=
"defaultKeyGenerateStrategy
"
>
<sharding:rule
id=
"
shardingRule
"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"d
btbl_${0..1}.t_order_${0..3}"
database-strategy-ref=
"standardStrategy"
table-strategy-ref=
"inlineStrategy"
key-generate-strategy-ref=
"orderKeyGenerator
"
/>
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"d
s_$->{0..1}.t_order_$->{0..3}"
database-strategy-ref=
"dataSourceShardingStrategy"
table-strategy-ref=
"orderTableShardingStrategy
"
/>
</sharding:table-rules>
</sharding:rule>
<master-slave:rule
id=
"masterSlaveShardingDataSourceByDefaultStrategyMasterSlaveRule"
>
<master-slave:data-source-rule
id=
"dbtbl_0"
master-data-source-name=
"dbtbl_0_master"
slave-data-source-names=
"dbtbl_0_slave_0,dbtbl_0_slave_1"
/>
<master-slave:data-source-rule
id=
"dbtbl_1"
master-data-source-name=
"dbtbl_1_master"
slave-data-source-names=
"dbtbl_1_slave_0,dbtbl_1_slave_1"
/>
</master-slave:rule>
<shardingsphere:data-source
id=
"masterSlaveShardingDataSourceByDefaultStrategy"
data-source-names=
"dbtbl_0_master,dbtbl_0_slave_0,dbtbl_0_slave_1,dbtbl_1_master,dbtbl_1_slave_0,dbtbl_1_slave_1"
rule-refs=
"masterSlaveShardingDataSourceByDefaultStrategyShardingRule, masterSlaveShardingDataSourceByDefaultStrategyMasterSlaveRule"
/>
<encrypt:rule
id=
"encryptRule"
>
<encrypt:table
name=
"t_order"
>
<encrypt:column
logic-column=
"pwd"
cipher-column=
"pwd_cipher"
encrypt-algorithm-ref=
"aesEncryptor"
/>
</encrypt:table>
</encrypt:rule>
<sharding:rule
id=
"masterSlaveShardingDataSourceByUserStrategyShardingRule"
default-key-generate-strategy-ref=
"defaultKeyGenerateStrategy"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"dbtbl_${0..1}.t_order_${0..3}"
database-strategy-ref=
"standardStrategy"
table-strategy-ref=
"inlineStrategy"
key-generate-strategy-ref=
"orderKeyGenerator"
/>
</sharding:table-rules>
</sharding:rule>
<master-slave:rule
id=
"masterSlaveShardingDataSourceByUserStrategyMasterSlaveRule"
>
<master-slave:data-source-rule
id=
"dbtbl_0"
master-data-source-name=
"dbtbl_0_master"
slave-data-source-names=
"dbtbl_0_slave_0,dbtbl_0_slave_1"
load-balance-algorithm-ref=
"randomLoadBalanceAlgorithm"
/>
<master-slave:data-source-rule
id=
"dbtbl_1"
master-data-source-name=
"dbtbl_1_master"
slave-data-source-names=
"dbtbl_1_slave_0,dbtbl_1_slave_1"
load-balance-algorithm-ref=
"randomLoadBalanceAlgorithm"
/>
<master-slave:rule
id=
"masterSlaveRule"
>
<master-slave:data-source-rule
id=
"ds_0"
master-data-source-name=
"ds_0_master"
slave-data-source-names=
"ds_0_slave_0,ds_0_slave_1"
/>
<master-slave:data-source-rule
id=
"ds_1"
master-data-source-name=
"ds_1_master"
slave-data-source-names=
"ds_1_slave_0,ds_1_slave_1"
/>
</master-slave:rule>
<shardingsphere:data-source
id=
"masterSlaveShardingDataSourceByUserStrategy"
data-source-names=
"dbtbl_0_master,dbtbl_0_slave_0,dbtbl_0_slave_1,dbtbl_1_master,dbtbl_1_slave_0,dbtbl_1_slave_1"
rule-refs=
"masterSlaveShardingDataSourceByUserStrategyShardingRule, masterSlaveShardingDataSourceByUserStrategyMasterSlaveRule"
/>
<sharding:rule
id=
"shardingRuleWithAttributesDataSourceShardingRule"
default-database-strategy-ref=
"standardStrategy"
default-table-strategy-ref=
"inlineStrategy"
default-key-generate-strategy-ref=
"defaultKeyGenerateStrategy"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
</sharding:table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"shardingRuleWithAttributesDataSource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"shardingRuleWithAttributesDataSourceShardingRule"
/>
<sharding:rule
id=
"tableRuleWithAttributesDataSourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
actual-data-nodes=
"dbtbl_${0..1}.t_order_${0..3}"
database-strategy-ref=
"standardStrategy"
table-strategy-ref=
"inlineStrategy"
key-generate-strategy-ref=
"orderKeyGenerator"
/>
</sharding:table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"tableRuleWithAttributesDataSource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"tableRuleWithAttributesDataSourceShardingRule"
/>
<sharding:rule
id=
"multiTableRulesDataSourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
<sharding:table-rule
logic-table=
"t_order_item"
/>
</sharding:table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"multiTableRulesDataSource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"multiTableRulesDataSourceShardingRule"
/>
<sharding:rule
id=
"bindingTableRuleDatasourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
<sharding:table-rule
logic-table=
"t_order_item"
/>
</sharding:table-rules>
<sharding:binding-table-rules>
<sharding:binding-table-rule
logic-tables=
"t_order, t_order_item"
/>
</sharding:binding-table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"bindingTableRuleDatasource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"bindingTableRuleDatasourceShardingRule"
/>
<sharding:rule
id=
"multiBindingTableRulesDatasourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
<sharding:table-rule
logic-table=
"t_order_item"
/>
<sharding:table-rule
logic-table=
"t_user"
/>
<sharding:table-rule
logic-table=
"t_user_detail"
/>
</sharding:table-rules>
<sharding:binding-table-rules>
<sharding:binding-table-rule
logic-tables=
"t_order, t_order_item"
/>
<sharding:binding-table-rule
logic-tables=
"t_user, t_user_detail"
/>
</sharding:binding-table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"multiBindingTableRulesDatasource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"multiBindingTableRulesDatasourceShardingRule"
/>
<sharding:rule
id=
"broadcastTableRuleDatasourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
<sharding:table-rule
logic-table=
"t_order_item"
/>
</sharding:table-rules>
<sharding:binding-table-rules>
<sharding:binding-table-rule
logic-tables=
"t_order, t_order_item"
/>
</sharding:binding-table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_config"
/>
</sharding:broadcast-table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"broadcastTableRuleDatasource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"broadcastTableRuleDatasourceShardingRule"
/>
<sharding:rule
id=
"multiBroadcastTableRulesDatasourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
<sharding:table-rule
logic-table=
"t_order_item"
/>
</sharding:table-rules>
<sharding:binding-table-rules>
<sharding:binding-table-rule
logic-tables=
"t_order, t_order_item"
/>
</sharding:binding-table-rules>
<sharding:broadcast-table-rules>
<sharding:broadcast-table-rule
table=
"t_config1"
/>
<sharding:broadcast-table-rule
table=
"t_config2"
/>
</sharding:broadcast-table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"multiBroadcastTableRulesDatasource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"multiBroadcastTableRulesDatasourceShardingRule"
/>
<sharding:rule
id=
"propsDataSourceShardingRule"
>
<sharding:table-rules>
<sharding:table-rule
logic-table=
"t_order"
/>
</sharding:table-rules>
</sharding:rule>
<shardingsphere:data-source
id=
"propsDataSource"
data-source-names=
"dbtbl_0,dbtbl_1"
rule-refs=
"propsDataSourceShardingRule"
>
<shardingsphere:data-source
id=
"dataSource"
data-source-names=
"ds_0_master,ds_0_slave_0,ds_0_slave_1,ds_1_master,ds_1_slave_0,ds_1_slave_1"
rule-refs=
"shardingRule, masterSlaveRule, encryptRule"
>
<props>
<prop
key=
"sql.show"
>
${sql_show}
</prop>
<prop
key=
"executor.size"
>
10
</prop>
<prop
key=
"foo"
>
bar
</prop>
<prop
key=
"sql.show"
>
false
</prop>
<prop
key=
"executor.size"
>
${executor.size}
</prop>
</props>
</shardingsphere:data-source>
...
...
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/datasource/dataSource.xml
已删除
100644 → 0
浏览文件 @
4a560b38
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You 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.
-->
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
"
>
<context:property-placeholder
location=
"classpath:conf/rdb/conf.properties"
ignore-unresolvable=
"true"
/>
<bean
id=
"dbtbl_0"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"dbtbl_1"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
</beans>
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/META-INF/spring/datasource/masterSlaveDataSource.xml
已删除
100644 → 0
浏览文件 @
4a560b38
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You 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.
-->
<beans
xmlns=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
"
>
<context:property-placeholder
location=
"classpath:conf/rdb/master_slave_conf.properties"
ignore-unresolvable=
"true"
/>
<bean
id=
"dbtbl_0_master"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"dbtbl_0_slave_0"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"dbtbl_0_slave_1"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"dbtbl_1_master"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"dbtbl_1_slave_0"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
<bean
id=
"dbtbl_1_slave_1"
class=
"org.apache.shardingsphere.test.MockedDataSource"
/>
</beans>
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/conf/rdb/conf.properties
浏览文件 @
597b89b9
...
...
@@ -15,14 +15,5 @@
# limitations under the License.
#
dbtbl_0.driver
=
org.h2.Driver
dbtbl_0.url
=
jdbc:h2:mem:dbtbl_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_0.username
=
sa
dbtbl_0.password
=
dbtbl_1.driver
=
org.h2.Driver
dbtbl_1.url
=
jdbc:h2:mem:dbtbl_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_1.username
=
sa
dbtbl_1.password
=
sql_show
=
true
aes.key.value
=
123456
executor.size
=
10
shardingsphere-jdbc/shardingsphere-jdbc-spring/shardingsphere-jdbc-core-spring/shardingsphere-jdbc-core-spring-namespace/src/test/resources/conf/rdb/master_slave_conf.properties
已删除
100644 → 0
浏览文件 @
4a560b38
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
#
dbtbl_0_master.driver
=
org.h2.Driver
dbtbl_0_master.url
=
jdbc:h2:mem:dbtbl_0_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_0_master.username
=
sa
dbtbl_0_master.password
=
dbtbl_0_slave_0.driver
=
org.h2.Driver
dbtbl_0_slave_0.url
=
jdbc:h2:mem:dbtbl_0_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_0_slave_0.username
=
sa
dbtbl_0_slave_0.password
=
dbtbl_0_slave_1.driver
=
org.h2.Driver
dbtbl_0_slave_1.url
=
jdbc:h2:mem:dbtbl_0_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_0_slave_1.username
=
sa
dbtbl_0_slave_1.password
=
dbtbl_1_master.driver
=
org.h2.Driver
dbtbl_1_master.url
=
jdbc:h2:mem:dbtbl_1_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_1_master.username
=
sa
dbtbl_1_master.password
=
dbtbl_1_slave_0.driver
=
org.h2.Driver
dbtbl_1_slave_0.url
=
jdbc:h2:mem:dbtbl_1_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_1_slave_0.username
=
sa
dbtbl_1_slave_0.password
=
dbtbl_1_slave_1.driver
=
org.h2.Driver
dbtbl_1_slave_1.url
=
jdbc:h2:mem:dbtbl_1_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
dbtbl_1_slave_1.username
=
sa
dbtbl_1_slave_1.password
=
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录