use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertIsAllInDefaultDataSource.
@Test
public void assertIsAllInDefaultDataSource() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertTrue(actual.isAllInDefaultDataSource(Collections.singletonList("table_0")));
assertFalse(actual.isAllInDefaultDataSource(Collections.singletonList("logic_table")));
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration 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.TableRuleConfiguration 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.TableRuleConfiguration 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.TableRuleConfiguration 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