use of io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm in project sharding-jdbc by shardingjdbc.
the class ShardingStrategyTest method assertDoShardingForBetweenSingleKey.
@Test
public void assertDoShardingForBetweenSingleKey() {
StandardShardingStrategy strategy = new StandardShardingStrategy(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm(), new TestRangeShardingAlgorithm()));
assertThat(strategy.doSharding(targets, Collections.<ShardingValue>singletonList(new RangeShardingValue<>("logicTable", "column", Range.open("1", "3")))), is((Collection<String>) Sets.newHashSet("1", "2", "3")));
}
use of io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method createTableRuleConfigWithTableStrategies.
private TableRuleConfiguration createTableRuleConfigWithTableStrategies() {
TableRuleConfiguration result = new TableRuleConfiguration();
result.setLogicTable("LOGIC_TABLE");
result.setActualDataNodes("ds${0..1}.table_${0..2}");
result.setTableShardingStrategyConfig(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm()));
return result;
}
use of io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm 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.algorithm.fixture.TestPreciseShardingAlgorithm 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", "")));
}
use of io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method createTableRuleConfigWithAllStrategies.
private TableRuleConfiguration createTableRuleConfigWithAllStrategies() {
TableRuleConfiguration result = new TableRuleConfiguration();
result.setLogicTable("LOGIC_TABLE");
result.setActualDataNodes("ds${0..1}.table_${0..2}");
result.setDatabaseShardingStrategyConfig(new StandardShardingStrategyConfiguration("column", new TestPreciseShardingAlgorithm()));
result.setTableShardingStrategyConfig(new NoneShardingStrategyConfiguration());
return result;
}
Aggregations