use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetLogicTableNameFailure.
@Test(expected = ShardingConfigurationException.class)
public void assertGetLogicTableNameFailure() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithLogicIndex();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
new ShardingRule(shardingRuleConfig, createDataSourceNames()).getLogicTableName("");
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertShardingRuleWithTableStrategy.
@Test
public void assertShardingRuleWithTableStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
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.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetDatabaseShardingStrategyForNullValue.
@Test
public void assertGetDatabaseShardingStrategyForNullValue() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(null);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertNotNull(actual.getDatabaseShardingStrategy(actual.getTableRule("logic_Table")));
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration 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.TableRuleConfiguration 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"));
}
Aggregations