use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetTableShardingStrategyFromTableRule.
@Test
public void assertGetTableShardingStrategyFromTableRule() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithTableShardingStrategy(new NoneShardingStrategyConfiguration());
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertThat(actual.getDatabaseShardingStrategy(actual.getTableRule("logic_Table")), instanceOf(NoneShardingStrategy.class));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertDataSourceNameFromDefaultDataSourceName.
@Test
public void assertDataSourceNameFromDefaultDataSourceName() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.setDefaultDataSourceName("ds3");
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertThat(actual.getDefaultDataSourceName(), is("ds3"));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetDatabaseShardingStrategyFromTableRule.
@Test
public void assertGetDatabaseShardingStrategyFromTableRule() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithDatabaseShardingStrategy(new NoneShardingStrategyConfiguration());
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertThat(actual.getDatabaseShardingStrategy(actual.getTableRule("logic_Table")), instanceOf(NoneShardingStrategy.class));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetBindingTableRuleForFound.
@Test
public void assertGetBindingTableRuleForFound() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
TableRuleConfiguration subTableRuleConfig = createSubTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRuleConfig.getTableRuleConfigs().add(subTableRuleConfig);
shardingRuleConfig.getBindingTableGroups().add(createTableRuleConfig().getLogicTable() + "," + createSubTableRuleConfig().getLogicTable());
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertTrue(actual.findBindingTableRule("logic_Table").isPresent());
assertThat(actual.findBindingTableRule("logic_Table").get().getTableRules().size(), is(2));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertFindDataNodeByLogicTableSuccess.
@Test
public void assertFindDataNodeByLogicTableSuccess() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
assertThat(new ShardingRule(shardingRuleConfig, createDataSourceNames()).findDataNodeByLogicTable("logic_table").getDataSourceName(), is("ds0"));
}
Aggregations