use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertShardingRuleWithDatabaseStrategy.
@Test
public void assertShardingRuleWithDatabaseStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
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 assertIsNotShardingColumn.
@Test
public void assertIsNotShardingColumn() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTableRuleConfigs().add(createTableRuleConfigWithAllStrategies());
assertFalse(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn(new Column("column", "other_Table")));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertFindDataNodeByLogicTableFailure.
@Test(expected = ShardingConfigurationException.class)
public void assertFindDataNodeByLogicTableFailure() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.setDefaultDataSourceName("ds3");
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
new ShardingRule(shardingRuleConfig, createDataSourceNames()).findDataNodeByLogicTable("logic_table_x");
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetNoDatabaseShardingStrategy.
@Test(expected = ShardingConfigurationException.class)
public void assertGetNoDatabaseShardingStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithDatabaseShardingStrategy(new NoneShardingStrategyConfiguration());
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
actual.getDatabaseShardingStrategy(actual.getTableRule("other_Table"));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertIsShardingColumnForTableShardingStrategy.
@Test
public void assertIsShardingColumnForTableShardingStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTableRuleConfigs().add(createTableRuleConfigWithTableStrategies());
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn(new Column("column", "logic_Table")));
}
Aggregations