Search in sources :

Example 11 with AbstractQueryTransactionTest

use of org.teiid.test.framework.query.AbstractQueryTransactionTest in project teiid by teiid.

the class CommonTransactionTests method testMultipleSourcePreparedUpdate.

/**
 * Sources = 2
 * Commands = 1, Update(prepared statement)
 * Batching = Full Processing, Single Connector Batch
 * result = commit
 */
@Test
public void testMultipleSourcePreparedUpdate() throws Exception {
    AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourcePreparedUpdate") {

        public void testCase() throws Exception {
            Integer value = new Integer(500);
            execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] { value, value.toString(), value, value.toString() });
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 = 500");
    test.assertRowCount(1);
    test = new QueryExecution(userTxn.getSource("pm2"));
    test.execute("select * from g1 where e1 = 500");
    test.assertRowCount(1);
}
Also used : AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) QueryExecution(org.teiid.test.framework.query.QueryExecution) AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) Test(org.junit.Test)

Example 12 with AbstractQueryTransactionTest

use of org.teiid.test.framework.query.AbstractQueryTransactionTest in project teiid by teiid.

the class CommonTransactionTests method testMultipleSourceTimeout.

/**
 * Sources = 2
 * Commands = multiple - Success
 * Batching = Full Processing, Single Connector Batch
 * result = rollback
 */
@Test
public void testMultipleSourceTimeout() throws Exception {
    AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceTimeout") {

        public void testCase() throws Exception {
            // time out after 1 sec
            executeBatch(getMultipleSourceBatch(), 1);
        }

        public boolean exceptionExpected() {
            return true;
        }

        public void after() {
            if (!exceptionOccurred()) {
                Assert.assertTrue("should have failed with time out exception", false);
            } else {
                if (getLastException() != null) {
                    String msg = "NA";
                    SQLException s = getLastException();
                    Throwable t = s.getCause();
                    if (t instanceof TimeoutException) {
                        msg = t.getMessage();
                    } else if (s instanceof TeiidSQLException) {
                        TeiidSQLException mm = (TeiidSQLException) t;
                        if (mm.getNextException() != null) {
                            SQLException next = mm.getNextException();
                            msg = next.getMessage();
                        } else {
                            msg = mm.getMessage();
                        }
                    } else {
                        msg = s.getMessage();
                    }
                    boolean isfound = (msg.indexOf("Operation timed out before completion") != -1 ? true : false);
                    Assert.assertTrue("Exception Message didnt match 'Operation timed out before completion' found: " + msg, isfound);
                } else {
                    Assert.assertTrue("Program Error: it indicates exception occured, but no exception is found", false);
                }
            }
        }
    };
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results (this may finish under one second, then this test is not valid)
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 >= 600 and e1 < 750");
    test.assertRowCount(0);
    test.execute("select * from g2 where e1 >= 600 and e1 < 750");
    test.assertRowCount(0);
    test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 750");
    test.assertRowCount(0);
}
Also used : AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) SQLException(java.sql.SQLException) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) TeiidSQLException(org.teiid.jdbc.TeiidSQLException) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) QueryExecution(org.teiid.test.framework.query.QueryExecution) TimeoutException(java.util.concurrent.TimeoutException) AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) Test(org.junit.Test)

Example 13 with AbstractQueryTransactionTest

use of org.teiid.test.framework.query.AbstractQueryTransactionTest in project teiid by teiid.

the class CommonTransactionTests method testMultipleSourceVirtualSelect.

/**
 * Sources = 2
 * Commands = 1, Select
 * Batching = Full Processing, Single Connector Batch
 * result = commit
 */
@Test
public void testMultipleSourceVirtualSelect() throws Exception {
    AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceVirtualSelect") {

        public void testCase() throws Exception {
            execute("select * from vm.g1 where vm.g1.pm1e1 < 100");
            assertRowCount(100);
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
}
Also used : AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) Test(org.junit.Test)

Example 14 with AbstractQueryTransactionTest

use of org.teiid.test.framework.query.AbstractQueryTransactionTest in project teiid by teiid.

the class CommonTransactionTests method testMultipleSourceBulkRowInsert.

/**
 * Sources = 2
 * Commands = 1, Update
 * Batching = Full Processing, Single Connector Batch
 * result = commit
 */
@Test
public void testMultipleSourceBulkRowInsert() throws Exception {
    AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsert") {

        public void testCase() throws Exception {
            for (int i = 100; i < 112; i++) {
                Integer val = new Integer(i);
                execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] { val, val.toString(), val, val.toString() });
            }
            execute("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 >= 100 and e1 < 112");
    test.assertRowCount(12);
    test = new QueryExecution(userTxn.getSource("pm2"));
    test.execute("select * from g1 where e1 >= 100 and e1 < 112");
    test.assertRowCount(12);
    test.execute("select * from g2 where e1 >= 100 and e1 < 112");
    test.assertRowCount(12);
}
Also used : AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) QueryExecution(org.teiid.test.framework.query.QueryExecution) AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) Test(org.junit.Test)

Example 15 with AbstractQueryTransactionTest

use of org.teiid.test.framework.query.AbstractQueryTransactionTest in project teiid by teiid.

the class CommonTransactionTests method testSingleSourceUpdate.

/**
 * Sources = 1
 * Commands = 1, Update
 * Batching = Full Processing, Single Connector Batch
 * result = commit
 */
@Test
public void testSingleSourceUpdate() throws Exception {
    AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceUpdate") {

        public void testCase() throws Exception {
            execute("insert into pm1.g1 (e1, e2) values(100, '100')");
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 = 100");
    test.assertRowCount(1);
}
Also used : AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) QueryExecution(org.teiid.test.framework.query.QueryExecution) AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) AbstractQueryTransactionTest(org.teiid.test.framework.query.AbstractQueryTransactionTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)37 AbstractQueryTest (org.teiid.jdbc.AbstractQueryTest)37 AbstractQueryTransactionTest (org.teiid.test.framework.query.AbstractQueryTransactionTest)37 QueryExecution (org.teiid.test.framework.query.QueryExecution)29 ArrayList (java.util.ArrayList)5 SQLException (java.sql.SQLException)2 TeiidSQLException (org.teiid.jdbc.TeiidSQLException)2 TimeoutException (java.util.concurrent.TimeoutException)1