Author: vhalbert(a)redhat.com
Date: 2009-11-16 15:59:49 -0500 (Mon, 16 Nov 2009)
New Revision: 1559
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
Log:
Teiid 773 - refactored back in the way jbedsp transaction classes where defined
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
===================================================================
---
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
(rev 0)
+++
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java 2009-11-16
20:59:49 UTC (rev 1559)
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import java.util.ArrayList;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.query.AbstractQueryTransactionTest;
+import org.teiid.test.framework.query.QueryExecution;
+import org.teiid.test.framework.transaction.OffWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+public class OffWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+
+
+ public OffWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected TransactionContainer getTransactionContainter() {
+ // TODO Auto-generated method stub
+ return new OffWrapTransaction();
+ }
+
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ 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);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ 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);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommands() throws Exception {
+ AbstractQueryTransactionTest userTxn = new
AbstractQueryTransactionTest("testSingleSourceMultipleCommands") {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new
Object[] {new Integer(100)});
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+ for (int i = 100; i < 110; 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()});
+ }
+ }
+ };
+
+ // 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(10);
+ test.execute("select * from g2 where e1 >= 100");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testSingleSourceMultipleCommandsReferentialIntegrityRollback() throws
Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ 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);
+ test.closeConnection();
+ }
+
+
///////////////////////////////////////////////////////////////////////////////////////////////
+ // Multiple Sources - Rows from 500
+
///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from pm1.g1 join pm2.g1 on pm1.g1.e1 = pm2.g1.e1
where pm1.g1.e1 < 100");
+ assertRowCount(100);
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into vm.g1 (pm1e1, pm1e2, pm2e1, pm2e2) values(500,
'500', 500, '500')");
+ }
+ };
+
+ // 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.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 = 500");
+ test.assertRowCount(1);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = rollback
+ */
+ public void testMultipleSourceMultipleCommandsReferentialIntegrityRollback() throws
Exception {
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+
+ for (int i = 700; i < 710; 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 < 710");
+ test.assertRowCount(10);
+ test.closeConnection();
+
+ test = new QueryExecution(userTxn.getSource("pm2"));
+ test.execute("select * from g1 where e1 >= 700 and e1 < 710");
+ test.assertRowCount(10);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Update
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceBulkRowInsert() throws Exception {
+
+
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ 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.closeConnection();
+
+ 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);
+ test.closeConnection();
+ }
+}
Property changes on:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OffWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain