Search in sources :

Example 16 with MasterSlaveRuleConfiguration

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

the class YamlMasterSlaveRuleConfigurationTest method assertGetMasterSlaveRuleConfigurationWithLoadBalanceAlgorithmClassName.

@Test
public void assertGetMasterSlaveRuleConfigurationWithLoadBalanceAlgorithmClassName() {
    YamlMasterSlaveRuleConfiguration yamlConfig = createYamlMasterSlaveRuleConfig();
    yamlConfig.setLoadBalanceAlgorithmClassName(RoundRobinMasterSlaveLoadBalanceAlgorithm.class.getName());
    MasterSlaveRuleConfiguration actual = yamlConfig.getMasterSlaveRuleConfiguration();
    assertMasterSlaveRuleConfig(actual);
    assertThat(actual.getLoadBalanceAlgorithm(), instanceOf(RoundRobinMasterSlaveLoadBalanceAlgorithm.class));
}
Also used : RoundRobinMasterSlaveLoadBalanceAlgorithm(io.shardingjdbc.core.api.algorithm.masterslave.RoundRobinMasterSlaveLoadBalanceAlgorithm) MasterSlaveRuleConfiguration(io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration) Test(org.junit.Test)

Example 17 with MasterSlaveRuleConfiguration

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

the class YamlMasterSlaveRuleConfigurationTest method assertGetMasterSlaveRuleConfigurationWithLoadBalanceAlgorithmType.

@Test
public void assertGetMasterSlaveRuleConfigurationWithLoadBalanceAlgorithmType() {
    YamlMasterSlaveRuleConfiguration yamlConfig = createYamlMasterSlaveRuleConfig();
    yamlConfig.setLoadBalanceAlgorithmType(MasterSlaveLoadBalanceAlgorithmType.RANDOM);
    MasterSlaveRuleConfiguration actual = yamlConfig.getMasterSlaveRuleConfiguration();
    assertMasterSlaveRuleConfig(actual);
    assertThat(actual.getLoadBalanceAlgorithm(), is(MasterSlaveLoadBalanceAlgorithmType.RANDOM.getAlgorithm()));
}
Also used : MasterSlaveRuleConfiguration(io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration) Test(org.junit.Test)

Example 18 with MasterSlaveRuleConfiguration

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

the class MasterSlaveRuleTest method assertNewMasterSlaveRuleFailure.

@Test(expected = NullPointerException.class)
public void assertNewMasterSlaveRuleFailure() {
    MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration("", "", null, null);
    new MasterSlaveRule(masterSlaveRuleConfig);
}
Also used : MasterSlaveRuleConfiguration(io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration) Test(org.junit.Test)

Aggregations

MasterSlaveRuleConfiguration (io.shardingjdbc.core.api.config.MasterSlaveRuleConfiguration)18 Test (org.junit.Test)12 HashMap (java.util.HashMap)7 DataSource (javax.sql.DataSource)7 TestDataSource (io.shardingjdbc.core.fixture.TestDataSource)5 MasterSlaveDataSource (io.shardingjdbc.core.jdbc.core.datasource.MasterSlaveDataSource)3 YamlMasterSlaveRuleConfiguration (io.shardingjdbc.core.yaml.masterslave.YamlMasterSlaveRuleConfiguration)3 ShardingRuleConfiguration (io.shardingjdbc.core.api.config.ShardingRuleConfiguration)2 MasterSlaveConnection (io.shardingjdbc.core.jdbc.core.connection.MasterSlaveConnection)2 OrchestrationFacade (io.shardingjdbc.orchestration.internal.OrchestrationFacade)2 ConfigurationService (io.shardingjdbc.orchestration.internal.config.ConfigurationService)2 YamlOrchestrationMasterSlaveRuleConfiguration (io.shardingjdbc.orchestration.yaml.YamlOrchestrationMasterSlaveRuleConfiguration)2 Connection (java.sql.Connection)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 RoundRobinMasterSlaveLoadBalanceAlgorithm (io.shardingjdbc.core.api.algorithm.masterslave.RoundRobinMasterSlaveLoadBalanceAlgorithm)1 LinkedList (java.util.LinkedList)1 BeforeClass (org.junit.BeforeClass)1