Search in sources :

Example 1 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingRuleTest method assertGetTableShardingStrategyFromTableRule.

@Test
public void assertGetTableShardingStrategyFromTableRule() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithTableShardingStrategy(new NoneShardingStrategyConfiguration());
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertThat(actual.getDatabaseShardingStrategy(actual.getTableRule("logic_Table")), instanceOf(NoneShardingStrategy.class));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) NoneShardingStrategy(io.shardingjdbc.core.routing.strategy.none.NoneShardingStrategy) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 2 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingRuleTest method assertGetDatabaseShardingStrategyFromTableRule.

@Test
public void assertGetDatabaseShardingStrategyFromTableRule() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithDatabaseShardingStrategy(new NoneShardingStrategyConfiguration());
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertThat(actual.getDatabaseShardingStrategy(actual.getTableRule("logic_Table")), instanceOf(NoneShardingStrategy.class));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) NoneShardingStrategy(io.shardingjdbc.core.routing.strategy.none.NoneShardingStrategy) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 3 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingRuleTest method assertGetTableShardingStrategyFromDefault.

@Test
public void assertGetTableShardingStrategyFromDefault() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertThat(actual.getTableShardingStrategy(actual.getTableRule("logic_Table")), instanceOf(NoneShardingStrategy.class));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) NoneShardingStrategy(io.shardingjdbc.core.routing.strategy.none.NoneShardingStrategy) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 4 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingRuleTest method assertGetDatabaseShardingStrategyFromDefault.

@Test
public void assertGetDatabaseShardingStrategyFromDefault() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertThat(actual.getDatabaseShardingStrategy(actual.getTableRule("logic_Table")), instanceOf(NoneShardingStrategy.class));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) NoneShardingStrategy(io.shardingjdbc.core.routing.strategy.none.NoneShardingStrategy) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 5 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration in project sharding-jdbc by shardingjdbc.

the class ShardingRuleTest method assertGetDatabaseShardingStrategyWithDefaultDataSource.

@Test
public void assertGetDatabaseShardingStrategyWithDefaultDataSource() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    shardingRuleConfig.setDefaultDataSourceName("ds0");
    TableRuleConfiguration tableRuleConfig = createTableRuleConfigWithDatabaseShardingStrategy(new NoneShardingStrategyConfiguration());
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertThat(actual.getDatabaseShardingStrategy(actual.getTableRule("other_Table")), instanceOf(NoneShardingStrategy.class));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) NoneShardingStrategy(io.shardingjdbc.core.routing.strategy.none.NoneShardingStrategy) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Aggregations

NoneShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration)19 TableRuleConfiguration (io.shardingjdbc.core.api.config.TableRuleConfiguration)16 ShardingRuleConfiguration (io.shardingjdbc.core.api.config.ShardingRuleConfiguration)14 Test (org.junit.Test)13 NoneShardingStrategy (io.shardingjdbc.core.routing.strategy.none.NoneShardingStrategy)5 ComplexShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.ComplexShardingStrategyConfiguration)4 StandardShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration)4 ShardingRule (io.shardingjdbc.core.rule.ShardingRule)3 HintShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.HintShardingStrategyConfiguration)2 InlineShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.InlineShardingStrategyConfiguration)2 DatabaseType (io.shardingjdbc.core.constant.DatabaseType)2 ComplexKeysModuloDatabaseShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.ComplexKeysModuloDatabaseShardingAlgorithm)2 SQLShardingRule (io.shardingjdbc.core.integrate.jaxb.SQLShardingRule)2 ShardingDataSource (io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource)2 Map (java.util.Map)2 TestPreciseShardingAlgorithm (io.shardingjdbc.core.api.algorithm.fixture.TestPreciseShardingAlgorithm)1 ShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.ShardingStrategyConfiguration)1 IncrementKeyGenerator (io.shardingjdbc.core.fixture.IncrementKeyGenerator)1 PreciseModuloTableShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.PreciseModuloTableShardingAlgorithm)1 RangeModuloTableShardingAlgorithm (io.shardingjdbc.core.integrate.fixture.RangeModuloTableShardingAlgorithm)1