Search in sources :

Example 1 with TestDataSource

use of com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource in project sharding-jdbc by dangdangdotcom.

the class DataSourceRuleTest method setUp.

@Before
public void setUp() {
    dataSourceMap.put("ds0", new TestDataSource("ds0"));
    dataSourceMap.put("ds1", new TestDataSource("ds1"));
    dataSourceMap.put("ds2", new TestDataSource("ds2"));
    dataSourceRule = new DataSourceRule(dataSourceMap);
}
Also used : TestDataSource(com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource) Before(org.junit.Before)

Example 2 with TestDataSource

use of com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource in project sharding-jdbc by dangdangdotcom.

the class DataSourceRuleTest method assertGetDefaultDataSourceWithSingleDataSource.

@Test
public void assertGetDefaultDataSourceWithSingleDataSource() {
    Map<String, DataSource> dataSourceMap = new HashMap<>(1);
    dataSourceMap.put("ds0", new TestDataSource("ds0"));
    dataSourceRule = new DataSourceRule(dataSourceMap);
    assertThat(dataSourceRule.getDefaultDataSource().get(), is(dataSourceRule.getDataSource("ds0")));
}
Also used : HashMap(java.util.HashMap) TestDataSource(com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource) TestDataSource(com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 3 with TestDataSource

use of com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource in project sharding-jdbc by dangdangdotcom.

the class RoundRobinSlaveLoadBalanceStrategyTest method assertGetDataSource.

@Test
public void assertGetDataSource() {
    DataSource slaveDataSource1 = new TestDataSource("test_ds_slave_1");
    DataSource slaveDataSource2 = new TestDataSource("test_ds_slave_2");
    assertThat(roundRobinSlaveLoadBalanceStrategy.getDataSource("ds", Arrays.asList(slaveDataSource1, slaveDataSource2)), is(slaveDataSource1));
    assertThat(roundRobinSlaveLoadBalanceStrategy.getDataSource("ds", Arrays.asList(slaveDataSource1, slaveDataSource2)), is(slaveDataSource2));
    assertThat(roundRobinSlaveLoadBalanceStrategy.getDataSource("ds", Arrays.asList(slaveDataSource1, slaveDataSource2)), is(slaveDataSource1));
}
Also used : TestDataSource(com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource) TestDataSource(com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Aggregations

TestDataSource (com.dangdang.ddframe.rdb.sharding.fixture.TestDataSource)3 DataSource (javax.sql.DataSource)2 Test (org.junit.Test)2 HashMap (java.util.HashMap)1 Before (org.junit.Before)1