use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGenerateKeyWithDefaultKeyGenerator.
@Test
public void assertGenerateKeyWithDefaultKeyGenerator() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
assertThat(new ShardingRule(shardingRuleConfig, createDataSourceNames()).generateKey("logic_table"), instanceOf(Long.class));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration 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.ShardingRuleConfiguration 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.ShardingRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertIsShardingColumnForDefaultDatabaseShardingStrategy.
@Test
public void assertIsShardingColumnForDefaultDatabaseShardingStrategy() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
shardingRuleConfig.getTableRuleConfigs().add(createTableRuleConfigWithAllStrategies());
shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm()));
assertTrue(new ShardingRule(shardingRuleConfig, createDataSourceNames()).isShardingColumn(new Column("column", "")));
}
use of io.shardingjdbc.core.api.config.ShardingRuleConfiguration 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")));
}
Aggregations