Search in sources :

Example 26 with AbstractQueryTest

use of org.teiid.jdbc.AbstractQueryTest in project teiid by teiid.

the class OffWrapTransactionTests method testSingleSourceMultipleCommandsReferentialIntegrityRollback.

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

        public void testCase() throws Exception {
            for (int i = 200; i < 210; i++) {
                Integer val = new Integer(i);
                execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] { val, val.toString() });
                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] { val, val.toString() });
            }
            // force the rollback by trying to insert an invalid row.
            execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] { new Integer(9999), "9999" });
        }

        public boolean exceptionExpected() {
            return true;
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 >= 200");
    test.assertRowCount(10);
}
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 27 with AbstractQueryTest

use of org.teiid.jdbc.AbstractQueryTest in project teiid by teiid.

the class OffWrapTransactionTests 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") {

        ArrayList list = new ArrayList();

        public void testCase() throws Exception {
            for (int i = 800; i < 807; i++) {
                list.add("insert into pm1.g1 (e1, e2) values(" + i + ",'" + i + "')");
                list.add("insert into pm2.g1 (e1, e2) values(" + i + ",'" + i + "')");
            }
            list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 800");
            // force the rollback by trying to insert an invalid row.
            list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
            // execute((String[])list.toArray(new String[list.size()]));
            executeBatch((String[]) list.toArray(new String[list.size()]), -1);
        }

        public boolean exceptionExpected() {
            return true;
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 >= 800 and e1 < 807");
    test.assertRowCount(7);
    test = new QueryExecution(userTxn.getSource("pm2"));
    test.execute("select * from g1 where e1 >= 800 and e1 < 807");
    test.assertRowCount(7);
    test.execute("select * from g2 where e1 >= 800 and e1 < 807");
    test.assertRowCount(7);
}
Also used : AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) ArrayList(java.util.ArrayList) 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 28 with AbstractQueryTest

use of org.teiid.jdbc.AbstractQueryTest in project teiid by teiid.

the class OnWrapTransactionTests method testSingleSourceMultipleCommandsReferentialIntegrityRollback.

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

        public void testCase() throws Exception {
            for (int i = 200; i < 210; i++) {
                Integer val = new Integer(i);
                execute("insert into pm1.g1 (e1, e2) values(?,?)", new Object[] { val, val.toString() });
                execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] { val, val.toString() });
            }
            // try to rollback, however since this autocommit=on above two
            // are already commited
            execute("insert into pm1.g2 (e1, e2) values(?,?)", new Object[] { new Integer(9999), "9999" });
        }

        public boolean exceptionExpected() {
            return true;
        }
    };
    // run test
    getTransactionContainter().runTransaction(userTxn);
    // now verify the results
    AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
    test.execute("select * from g1 where e1 >= 200 and e1 < 210");
    test.assertRowCount(10);
    test.execute("select * from g2 where e1 = 9999");
    test.assertRowCount(0);
}
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 29 with AbstractQueryTest

use of org.teiid.jdbc.AbstractQueryTest in project teiid by teiid.

the class OnWrapTransactionTests method testMultipleSourceBulkRowInsertRollback.

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

        ArrayList<String> list = new ArrayList<String>();

        @Override
        public void testCase() throws Exception {
            for (int i = 100; i < 110; i++) {
                list.add("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(" + i + ",'" + i + "'," + i + ",'" + i + "')");
            }
            list.add("select pm1.g1.e1, pm1.g1.e2 into pm2.g2 from pm1.g1 where pm1.g1.e1 >= 100");
            // force the rollback by trying to insert an invalid row.
            list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
            executeBatch(list.toArray(new String[list.size()]));
        }

        @Override
        public boolean exceptionExpected() {
            return true;
        }
    };
    // 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 < 110");
    test.assertRowCount(0);
    test = new QueryExecution(userTxn.getSource("pm2"));
    test.execute("select * from g1 where e1 >= 100 and e1 < 110");
    test.assertRowCount(0);
    test.execute("select * from g2 where e1 >= 100 and e1 < 110");
    test.assertRowCount(0);
}
Also used : AbstractQueryTest(org.teiid.jdbc.AbstractQueryTest) ArrayList(java.util.ArrayList) 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)29 AbstractQueryTest (org.teiid.jdbc.AbstractQueryTest)29 AbstractQueryTransactionTest (org.teiid.test.framework.query.AbstractQueryTransactionTest)29 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