use of com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm in project sharding-jdbc by dangdangdotcom.
the class AbstractShardingNullableDBUnitTest method getShardingDataSource.
protected final ShardingDataSource getShardingDataSource() {
if (null != shardingDataSource && !isShutdown) {
return shardingDataSource;
}
isShutdown = false;
DataSourceRule dataSourceRule = new DataSourceRule(createDataSourceMap("dataSource_%s"));
TableRule orderTableRule = TableRule.builder("t_order").dataSourceRule(dataSourceRule).build();
ShardingRule shardingRule = ShardingRule.builder().dataSourceRule(dataSourceRule).tableRules(Collections.singletonList(orderTableRule)).bindingTableRules(Collections.singletonList(new BindingTableRule(Collections.singletonList(orderTableRule)))).databaseShardingStrategy(new DatabaseShardingStrategy(Collections.singletonList("user_id"), new MultipleKeysModuloDatabaseShardingAlgorithm())).tableShardingStrategy(new TableShardingStrategy(Collections.singletonList("order_id"), new NoneTableShardingAlgorithm())).build();
shardingDataSource = new ShardingDataSource(shardingRule);
return shardingDataSource;
}
use of com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm in project sharding-jdbc by dangdangdotcom.
the class TableRuleTest method assertTableRuleWithTableShardingStrategyWithoutDataNode.
@Test
public void assertTableRuleWithTableShardingStrategyWithoutDataNode() {
TableRule actual = TableRule.builder("logicTable").actualTables(Arrays.asList("table_0", "table_1", "table_2")).dataSourceRule(createDataSourceRule()).tableShardingStrategy(new TableShardingStrategy("", new NoneTableShardingAlgorithm())).build();
assertActualTable(actual);
assertNull(actual.getDatabaseShardingStrategy());
assertNotNull(actual.getTableShardingStrategy());
}
use of com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm in project sharding-jdbc by dangdangdotcom.
the class AbstractShardingDataBasesOnlyHintDBUnitTest method initDataSource.
ShardingDataSource initDataSource() {
DataSourceRule dataSourceRule = new DataSourceRule(createDataSourceMap("dataSource_%s"));
TableRule orderTableRule = TableRule.builder("t_order").dataSourceRule(dataSourceRule).build();
TableRule orderItemTableRule = TableRule.builder("t_order_item").dataSourceRule(dataSourceRule).build();
ShardingRule shardingRule = ShardingRule.builder().dataSourceRule(dataSourceRule).tableRules(Lists.newArrayList(orderTableRule, orderItemTableRule)).bindingTableRules(Collections.singletonList(new BindingTableRule(Arrays.asList(orderTableRule, orderItemTableRule)))).databaseShardingStrategy(new DatabaseShardingStrategy(Collections.singletonList("user_id"), new MultipleKeysModuloDatabaseShardingAlgorithm())).tableShardingStrategy(new TableShardingStrategy(Collections.singletonList("order_id"), new NoneTableShardingAlgorithm())).build();
return new ShardingDataSource(shardingRule);
}
use of com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm in project sharding-jdbc by dangdangdotcom.
the class TableRuleTest method assertTableRuleForDynamicWithTableStrategy.
@Test
public void assertTableRuleForDynamicWithTableStrategy() {
TableRule actual = TableRule.builder("logicTable").dynamic(true).dataSourceRule(createDataSourceRule()).tableShardingStrategy(new TableShardingStrategy("", new NoneTableShardingAlgorithm())).build();
assertDynamicTable(actual);
assertNull(actual.getDatabaseShardingStrategy());
assertNotNull(actual.getTableShardingStrategy());
}
use of com.dangdang.ddframe.rdb.sharding.api.strategy.table.NoneTableShardingAlgorithm in project sharding-jdbc by dangdangdotcom.
the class TableRuleTest method assertTableRuleForDynamicWithAllStrategies.
@Test
public void assertTableRuleForDynamicWithAllStrategies() {
TableRule actual = TableRule.builder("logicTable").dynamic(true).dataSourceRule(createDataSourceRule()).databaseShardingStrategy(new DatabaseShardingStrategy("", new NoneDatabaseShardingAlgorithm())).tableShardingStrategy(new TableShardingStrategy("", new NoneTableShardingAlgorithm())).build();
assertDynamicTable(actual);
assertNotNull(actual.getDatabaseShardingStrategy());
assertNotNull(actual.getTableShardingStrategy());
}
Aggregations