Package org.teiid.test.framework.query

Examples of org.teiid.test.framework.query.AbstractQueryTransactionTest


     * 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 pessimistic 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);       
     
View Full Code Here


     * Batching = Full Processing, Single Connector Batch
     * result = rollback
     */
    @Test
    public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws Exception {
        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceBatchCommandReferentialIntegrityRollback") {
            public void testCase() throws Exception {
                ArrayList list = new ArrayList();
                for (int i = 200; i < 210; i++) {
                    list.add("insert into pm1.g1 (e1, e2) values("+i+",'"+i+"')");
                }
               
                // try to rollback, since we are in single batch it must rollback
                list.add("insert into pm1.g2 (e1, e2) values(9999,'9999')");
                executeBatch((String[])list.toArray(new String[list.size()]));
            }
           
            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(0);
        test.execute("select * from g2 where e1 = 9999");
        test.assertRowCount(0);       
    
View Full Code Here

     * Batching = Full Processing, Single Connector Batch
     * result = commit
     */
    @Test
    public void testMultipleSourceBulkRowInsertRollback() throws Exception {
        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceBulkRowInsertRollback") {
            ArrayList list = new ArrayList();
            public void testCase() throws Exception {
                for (int i = 100; i < 120; 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((String[])list.toArray(new String[list.size()]));
            }
           
            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);       
    }    
View Full Code Here

     * 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);       
     
View Full Code Here

     * 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);
   
    }   
View Full Code Here

     * Batching = Full Processing, Single Connector Batch
     * result = rollback
     */
    @Test
    public void testMultipleSourceMultipleCommandsExplicitRollback() throws Exception {
        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsExplicitRollback") {
            public void testCase() throws Exception {

                for (int i = 700; i < 720; 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()});
                   
                    execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
                    execute("insert into pm2.g2 (e1, e2) values(?,?)", new Object[] {val, val.toString()});                   
                }               
            }
           
            // force the rollback
            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 >= 700 and e1 < 720");
        test.assertRowCount(0);       
       
        test = new QueryExecution(userTxn.getSource("pm2"));
        test.execute("select * from g1 where e1 >= 700 and e1 < 720");
        test.assertRowCount(0);       
    
    }
View Full Code Here

     * Batching = Full Processing, Single Connector Batch
     * result = rollback
     */
    @Test
    public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws Exception {
        AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testMultipleSourceMultipleCommandsReferentialIntegrityRollback") {
            public void testCase() throws Exception {

                for (int i = 700; i < 720; 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()});
                   
                    execute("insert into pm2.g1 (e1, e2) values(?,?)", new Object[] {val, val.toString()});
                    execute("insert into pm2.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 >= 700 and e1 < 720");
        test.assertRowCount(0);
 
       
        test = new QueryExecution(userTxn.getSource("pm2"));
        test.execute("select * from g1 where e1 >= 700 and e1 < 720");
        test.assertRowCount(0);       
    
    }
View Full Code Here

     * 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);       
    }
View Full Code Here

     * 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");
View Full Code Here

     * result = commit
     */
    @Test
    public void testSingleSourceSelect() throws Exception {

  AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest("testSingleSourceSelect") {
            public void testCase() throws Exception {
                execute("select * from pm1.g1 where pm1.g1.e1 < 100");
                assertRowCount(100);
            }
        };       
View Full Code Here

TOP

Related Classes of org.teiid.test.framework.query.AbstractQueryTransactionTest

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.