Search in sources :

Example 11 with NoneShardingStrategyConfiguration

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

the class ShardingRuleConfigurationConverterTest method assertToJsonForNoneStrategy.

@Test
public void assertToJsonForNoneStrategy() {
    NoneShardingStrategyConfiguration actual = new NoneShardingStrategyConfiguration();
    assertThat(ShardingRuleConfigurationConverter.toJson(getCommonShardingRuleConfig(actual)), is(getJsonForNoneStrategy()));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) Test(org.junit.Test)

Example 12 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration 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")));
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 13 with NoneShardingStrategyConfiguration

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

the class ShardingRuleTest method assertFindTableRule.

@Test
public void assertFindTableRule() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    shardingRuleConfig.setDefaultTableShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertTrue(actual.tryFindTableRuleByLogicTable("logic_Table").isPresent());
    assertFalse(actual.tryFindTableRuleByLogicTable("null").isPresent());
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 14 with NoneShardingStrategyConfiguration

use of io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration 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());
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) TableRuleConfiguration(io.shardingjdbc.core.api.config.TableRuleConfiguration) Test(org.junit.Test)

Example 15 with NoneShardingStrategyConfiguration

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

the class ShardingRuleTest method assertShardingRuleWithoutBindingTableRule.

@Test
public void assertShardingRuleWithoutBindingTableRule() {
    ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
    TableRuleConfiguration tableRuleConfig = createTableRuleConfig();
    shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);
    shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    shardingRuleConfig.setDefaultTableShardingStrategyConfig(new NoneShardingStrategyConfiguration());
    ShardingRule actual = new ShardingRule(shardingRuleConfig, createDataSourceNames());
    assertTrue(actual.getDefaultDatabaseShardingStrategy().getShardingColumns().isEmpty());
    assertTrue(actual.getDefaultDatabaseShardingStrategy().getShardingColumns().isEmpty());
}
Also used : NoneShardingStrategyConfiguration(io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration) ShardingRuleConfiguration(io.shardingjdbc.core.api.config.ShardingRuleConfiguration) 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