use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertFindTableRuleByActualTable.
@Test
public void assertFindTableRuleByActualTable() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertTrue(actual.tryFindTableRuleByActualTable("table_0").isPresent());
assertFalse(actual.tryFindTableRuleByActualTable("table_3").isPresent());
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetLogicTableNameSuccess.
@Test
public void assertGetLogicTableNameSuccess() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithLogicIndex();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
assertThat(new ShardingRule(shardingRuleConfig, createDataSourceNames()).getLogicTableName("index_table"), is("logic_table"));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertShardingRuleWithoutBindingTableRule.
@Test
public void assertShardingRuleWithoutBindingTableRule() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
shardingRuleConfig.setDefaultTableShardingStrategyConfig(new NoneShardingStrategyConfiguration());
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertTrue(actual.getDefaultDatabaseShardingStrategy().getShardingColumns().isEmpty());
assertTrue(actual.getDefaultDatabaseShardingStrategy().getShardingColumns().isEmpty());
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertShardingRuleWithoutStrategy.
@Test
public void assertShardingRuleWithoutStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertTrue(actual.getDefaultDatabaseShardingStrategy().getShardingColumns().isEmpty());
assertTrue(actual.getDefaultTableShardingStrategy().getShardingColumns().isEmpty());
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertIsShardingColumnForDefaultTableShardingStrategy.
@Test
public void assertIsShardingColumnForDefaultTableShardingStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTableRuleConfigs().add(createTableRuleConfigWithAllStrategies());
shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm()));
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn(new Column("column", "")));
}
Aggregations