Search in sources :

Example 21 with AbstractQueryTest

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

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

        public void testCase() throws Exception {
            for (int i = 100; i < 120; 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");
            // 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 >= 100 and e1 < 120");
    test.assertRowCount(0);
    test = new QueryExecution(userTxn.getSource("pm2"));
    test.execute("select * from g1 where e1 >= 100 and e1 < 120");
    test.assertRowCount(0);
    test.execute("select * from g2 where e1 >= 100 and e1 < 120");
    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 22 with AbstractQueryTest

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

the class LocalTransactionTests 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 < 220; 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 and e1 < 220");
    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 23 with AbstractQueryTest

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

the class LocalTransactionTests method testSingleSourceMultipleCommandsExplicitRollback.

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

        @Override
        public void testCase() throws Exception {
            for (int i = 200; i < 220; i++) {
                execute("insert into pm1.g1 (e1, e2) values(" + i + ",'" + i + "')");
                execute("insert into pm1.g2 (e1, e2) values(" + i + ",'" + i + "')");
            }
        }

        @Override
        public boolean rollbackAllways() {
            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 < 220");
    test.assertRowCount(0);
    test.execute("select * from g2 where e1 >= 200 and e1 < 220");
    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 24 with AbstractQueryTest

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

the class LocalTransactionTests method testMultipleSourceMultipleVirtualCommandsRollback.

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

        public void testCase() throws Exception {
            for (int i = 600; i < 615; 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("insert into vm.g2 (pm1e1, pm1e2, pm2e1, pm2e2) values(?,?,?,?)", new Object[] { val, val.toString(), val, val.toString() });
            }
            execute("update vm.g1 set pm1e2='blah' where pm1e1 >= 605");
            execute("delete from vm.g2 where vm.g2.pm1e1 >= 610");
            execute("delete from vm.g1 where vm.g1.pm1e1 >= 610");
            execute("select * from vm.g1 where pm1e1 >= 600 and pm1e1 < 615");
            assertRowCount(10);
            // 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 >= 600 and e1 < 615");
    test.assertRowCount(0);
    test.execute("select * from g2 where e1 >= 600 and e1 < 615");
    test.assertRowCount(0);
    test.execute("select distinct e2 from g1 where e1 >= 600 and e1 < 615");
    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 25 with AbstractQueryTest

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

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