use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleConfigurationConverterTest method getCommonShardingRuleConfig.
private ShardingRuleConfiguration getCommonShardingRuleConfig(final ShardingStrategyConfiguration strategyConfig) {
ShardingRuleConfiguration actual = new ShardingRuleConfiguration();
TableRuleConfiguration orderTableRuleConfig = new TableRuleConfiguration();
orderTableRuleConfig.setLogicTable("t_order");
orderTableRuleConfig.setActualDataNodes("t_order_${[0, 1]}");
actual.getTableRuleConfigs().add(orderTableRuleConfig);
TableRuleConfiguration orderItemTableRuleConfig = new TableRuleConfiguration();
orderItemTableRuleConfig.setLogicTable("t_order_item");
orderItemTableRuleConfig.setActualDataNodes("t_order_item_${[0, 1]}");
actual.getTableRuleConfigs().add(orderItemTableRuleConfig);
actual.getBindingTableGroups().add("t_order, t_order_item");
actual.setDefaultTableShardingStrategyConfig(strategyConfig);
return actual;
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class AbstractSoftTransactionIntegrationTest method prepareEnv.
private void prepareEnv() throws SQLException {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration();
tableRuleConfig.setLogicTable("transaction_test");
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
Map<String, DataSource> dataSourceMap = createDataSourceMap();
ShardingRule shardingRule = new ShardingRule(shardingRuleConfig, dataSourceMap.keySet());
shardingDataSource = new ShardingDataSource(dataSourceMap, shardingRule);
createTable(shardingDataSource);
transactionDataSource = createTransactionLogDataSource();
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class YamlTableRuleConfigurationTest method assertBuildWithoutShardingStrategy.
@Test
public void assertBuildWithoutShardingStrategy() {
TableRuleConfiguration actual = createYamlTableRuleConfig().build();
assertTableRuleConfig(actual);
assertWithoutShardingStrategy(actual);
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class YamlTableRuleConfigurationTest method assertBuildWithShardingStrategy.
@Test
public void assertBuildWithShardingStrategy() {
TableRuleConfiguration actual = createYamlTableRuleConfigWithShardingStrategy().build();
assertTableRuleConfig(actual);
assertWithShardingStrategy(actual);
}
use of io.shardingjdbc.core.api.config.TableRuleConfiguration in project sharding-jdbc by shardingjdbc.
the class ShardingRuleTest method assertGetTableShardingStrategyForNullValue.
@Test
public void assertGetTableShardingStrategyForNullValue() {
ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
assertNotNull(actual.getTableShardingStrategy(actual.getTableRule("logic_Table")));
}
Aggregations