Package com.taobao.tddl.common.mockdatasource

Examples of com.taobao.tddl.common.mockdatasource.MockDataSource


  @Test
  public void test_һ�������ϴ�������Statement() {
    TGroupDataSource tgds = new TGroupDataSource();
    tgds.setDbGroupKey("dbKey0");
    List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
    MockDataSource db1 = new MockDataSource("db", "db1");
    MockDataSource db2 = new MockDataSource("db", "db2");
    DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "rw", db1, DBType.MYSQL);
    DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
    dataSourceWrappers.add(dsw1);
    dataSourceWrappers.add(dsw2);
    tgds.init(dataSourceWrappers);

    TGroupConnection conn = null;
    Statement stat = null;
    try {
      db1.setClosed(true);
      db2.setClosed(false);
      conn = tgds.getConnection();
      stat = conn.createStatement();
      stat.executeQuery("select 1 from test");
      MockDataSource.showTrace();
      Assert.assertTrue(MockDataSource.hasTrace("db", "db2", "select 1 from test"));

      db1.setClosed(false);
      db2.setClosed(true);
      stat = conn.createStatement();
      stat.executeQuery("select 2 from test");
      //Assert.assertTrue(MockDataSource.hasTrace("db", "db1", "select 1 from test"));
      Assert.fail("û�����õ�һ������");
    } catch (SQLException e) {
View Full Code Here


    public void test_autocommit() {
        MockDataSource.clearTrace();
        TGroupDataSource tgds = new TGroupDataSource();
        tgds.setDbGroupKey("dbKey0");
        List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
        MockDataSource db1 = new MockDataSource("db", "db1");
        MockDataSource db2 = new MockDataSource("db", "db2");
        DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "w", db1, DBType.MYSQL);
        DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
        dataSourceWrappers.add(dsw1);
        dataSourceWrappers.add(dsw2);
        tgds.init(dataSourceWrappers);
View Full Code Here

  public void test_no_trans() {
        MockDataSource.clearTrace();
    TGroupDataSource tgds = new TGroupDataSource();
    tgds.setDbGroupKey("dbKey0");
    List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
    MockDataSource db1 = new MockDataSource("db", "db1");
    MockDataSource db2 = new MockDataSource("db", "db2");
    DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "w", db1, DBType.MYSQL);
    DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
    dataSourceWrappers.add(dsw1);
    dataSourceWrappers.add(dsw2);
    tgds.init(dataSourceWrappers);
View Full Code Here

    public void test_write_trans() {
        MockDataSource.clearTrace();
        TGroupDataSource tgds = new TGroupDataSource();
        tgds.setDbGroupKey("dbKey0");
        List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
        MockDataSource db1 = new MockDataSource("db", "db1");
        MockDataSource db2 = new MockDataSource("db", "db2");
        DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "w", db1, DBType.MYSQL);
        DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
        dataSourceWrappers.add(dsw1);
        dataSourceWrappers.add(dsw2);
        tgds.init(dataSourceWrappers);
View Full Code Here

    public void test_read_trans() {
        MockDataSource.clearTrace();
        TGroupDataSource tgds = new TGroupDataSource();
        tgds.setDbGroupKey("dbKey0");
        List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
        MockDataSource db1 = new MockDataSource("db", "db1");
        MockDataSource db2 = new MockDataSource("db", "db2");
        DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "w", db1, DBType.MYSQL);
        DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
        dataSourceWrappers.add(dsw1);
        dataSourceWrappers.add(dsw2);
        tgds.init(dataSourceWrappers);
View Full Code Here

    public void test_write_and_read_trans() {
        MockDataSource.clearTrace();
        TGroupDataSource tgds = new TGroupDataSource();
        tgds.setDbGroupKey("dbKey0");
        List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
        MockDataSource db1 = new MockDataSource("db", "db1");
        MockDataSource db2 = new MockDataSource("db", "db2");
        DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "w", db1, DBType.MYSQL);
        DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
        dataSourceWrappers.add(dsw1);
        dataSourceWrappers.add(dsw2);
        tgds.init(dataSourceWrappers);
View Full Code Here

    public void test_read_and_write_trans() {
        MockDataSource.clearTrace();
        TGroupDataSource tgds = new TGroupDataSource();
        tgds.setDbGroupKey("dbKey0");
        List<DataSourceWrapper> dataSourceWrappers = new ArrayList<DataSourceWrapper>();
        MockDataSource db1 = new MockDataSource("db", "db1");
        MockDataSource db2 = new MockDataSource("db", "db2");
        DataSourceWrapper dsw1 = new DataSourceWrapper("db1", "w", db1, DBType.MYSQL);
        DataSourceWrapper dsw2 = new DataSourceWrapper("db2", "r", db2, DBType.MYSQL);
        dataSourceWrappers.add(dsw1);
        dataSourceWrappers.add(dsw2);
        tgds.init(dataSourceWrappers);
View Full Code Here

    private MockDataSource mds;
    private JdbcTemplate jt;

    @Before
  public void setUp() throws Exception {
    mds = new MockDataSource();
    mds.setDbIndex("dbindex0");
    jt = new JdbcTemplate(mds);
    handler = new MetaDataQueryForMapHandler();
  }
View Full Code Here

  @BeforeClass
  public static void beforeClass() {
  }

  private static MockDataSource createMockDataSource(String name) {
    MockDataSource mds = new MockDataSource();
    mds.setName(name);
    mds.setDbIndex("");
    return mds;
  }
View Full Code Here

TOP

Related Classes of com.taobao.tddl.common.mockdatasource.MockDataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.