Author: vhalbert(a)redhat.com
Date: 2009-12-15 19:07:07 -0500 (Tue, 15 Dec 2009)
New Revision: 1672
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
Removed:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
Log:
Teiid 897 - changes to autowrap mode
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/client/TransactionFactory.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -25,12 +25,11 @@
import org.teiid.test.framework.TransactionContainer;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
+import org.teiid.test.framework.transaction.AutoWrapTransaction;
import org.teiid.test.framework.transaction.JNDITransaction;
import org.teiid.test.framework.transaction.LocalTransaction;
import org.teiid.test.framework.transaction.OffWrapTransaction;
import org.teiid.test.framework.transaction.OnWrapTransaction;
-import org.teiid.test.framework.transaction.OptimisticWrapTransaction;
-import org.teiid.test.framework.transaction.PessimisticWrapTransaction;
import org.teiid.test.framework.transaction.XATransaction;
@@ -58,8 +57,7 @@
public static final String JNDI_TRANSACTION = "jndi"; //$NON-NLS-1$
public static final String OFFWRAP_TRANSACTION = "offwrap"; //$NON-NLS-1$
public static final String ONWRAP_TRANSACTION = "onwrap"; //$NON-NLS-1$
- public static final String OPTIMISTICWRAP_TRANSACTION = "optwrap";
//$NON-NLS-1$
- public static final String PESSIMISTICWRAP_TRANSACTION = "pesswrap";
//$NON-NLS-1$
+ public static final String AUTOWRAP_TRANSACTION = "autowrap"; //$NON-NLS-1$
}
@@ -92,13 +90,9 @@
else if (type.equalsIgnoreCase(TRANSACTION_TYPES.ONWRAP_TRANSACTION)) {
transacton = new OnWrapTransaction();
}
- else if (type.equalsIgnoreCase(TRANSACTION_TYPES.OPTIMISTICWRAP_TRANSACTION))
{
- transacton = new OptimisticWrapTransaction();
- }
- else if (type.equalsIgnoreCase(TRANSACTION_TYPES.PESSIMISTICWRAP_TRANSACTION)) {
- transacton = new PessimisticWrapTransaction();
+ else if (type.equalsIgnoreCase(TRANSACTION_TYPES.AUTOWRAP_TRANSACTION)) {
+ transacton = new AutoWrapTransaction();
-
} else {
throw new TransactionRuntimeException("Invalid property value of " +
type + " for " + TRANSACTION_TYPE );
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -60,12 +60,10 @@
}
_instance = new ConfigPropertyLoader();
- try {
- _instance.initialize();
- } catch (TransactionRuntimeException e) {
- throw e;
- }
+ _instance.initialize();
+
+
return _instance;
}
@@ -148,8 +146,12 @@
Properties p = new Properties();
p.putAll(System.getProperties());
- p.putAll(props);
- p.putAll(overrides);
+ if (props != null) {
+ p.putAll(props);
+ }
+ if (overrides != null) {
+ p.putAll(overrides);
+ }
return p;
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyNames.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -120,11 +120,10 @@
}
public interface TXN_AUTO_WRAP_OPTIONS {
- public static final String AUTO_WRAP_OFF = "OFF"; //$NON-NLS-1$
- public static final String AUTO_WRAP_ON = "ON"; //$NON-NLS-1$
- public static final String AUTO_WRAP_PESSIMISTIC = "PESSIMISTIC";
//$NON-NLS-1$
- public static final String AUTO_WRAP_OPTIMISTIC = "OPTIMISTIC";
//$NON-NLS-1$
-
+ public static final String AUTO_WRAP_OFF = ExecutionProperties.TXN_WRAP_OFF;
//$NON-NLS-1$
+ public static final String AUTO_WRAP_ON = ExecutionProperties.TXN_WRAP_ON;
//$NON-NLS-1$
+ public static final String AUTO_WRAP_AUTO = ExecutionProperties.TXN_WRAP_AUTO;
//$NON-NLS-1$
+
}
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TestLogger.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -38,17 +38,17 @@
public static final Level DEBUG = Level.FINEST;
public static final Level IMPORTANT = Level.FINE;
- private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
+ // private static final Logger LOGGER = Logger.getLogger("org.teiid.test");
static {
BasicConfigurator.configure(new ConsoleAppender());
- LOGGER.setLevel(INFO);
+// LOGGER.setLevel(INFO);
}
public static final void setLogLevel(Level level) {
- LOGGER.setLevel(level);
+// LOGGER.setLevel(level);
}
public static final void logDebug(String msg) {
@@ -75,11 +75,11 @@
}
private static final void log(Level javaLevel, Object msg, Throwable t) {
-// System.out.println(msg);
- if (LOGGER.isLoggable(javaLevel)) {
-
- LOGGER.log(javaLevel, msg.toString(), t);
- }
+ System.out.println(msg);
+// if (LOGGER.isLoggable(javaLevel)) {
+//
+// LOGGER.log(javaLevel, msg.toString(), t);
+// }
}
}
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -130,26 +130,28 @@
if (this.isDataStoreDisabled()) {
return;
}
-
- com.metamatrix.jdbc.MMConnection c = null;
+
try {
// the the driver strategy is going to be used to connection directly to the
connector binding
// source, then no administration can be done
-
+ Admin admin = null;
+
java.sql.Connection conn = getConnection();
+
if ( conn instanceof com.metamatrix.jdbc.MMConnection) {
- c = (com.metamatrix.jdbc.MMConnection) conn;
+ com.metamatrix.jdbc.MMConnection c = (com.metamatrix.jdbc.MMConnection) conn;
+ admin = (Admin)c.getAdminAPI();
+ } else if (conn instanceof com.metamatrix.jdbc.api.Connection) {
+ com.metamatrix.jdbc.api.Connection c = (com.metamatrix.jdbc.api.Connection) conn;
+ admin = (Admin)c.getAdminAPI();
} else {
TestLogger.log("ConnectionStrategy configuration: connection is not of type
MMConnection and therefore no vdb setup will be performed");
return;
}
+
+ setupVDBConnectorBindings(admin);
- Admin admin = (Admin)c.getAdminAPI();
-
- setupVDBConnectorBindings(admin);
-
-
// admin.restart();
int sleep = 5;
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -107,7 +107,7 @@
public Connection getConnection() throws QueryTestFailedException {
try {
- return getXAConnection().getConnection();
+ return getXAConnection().getConnection();
} catch (QueryTestFailedException qtf) {
throw qtf;
} catch (Exception e) {
@@ -137,9 +137,9 @@
DataSource ds = (DataSource)Class.forName(this.driver).newInstance();
if (ds instanceof BaseDataSource) {
+
BaseDataSource dataSource = (BaseDataSource) ds;
- //Class.forName(this.driver).newInstance();
-
+
dataSource.setDatabaseName(this.databaseName);
if (this.applName != null) {
dataSource.setApplicationName(this.applName);
@@ -158,6 +158,7 @@
dataSource.setPassword(this.pwd);
}
+
return ((XADataSource) dataSource).getXAConnection(this.username,
this.pwd);
} else {
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
(rev 0)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
+import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
+
+
+/**
+ * This transction is only valid when
+ * AutoCommit = ON
+ * txnAutoWrap = Optimistic.
+ */
+public class AutoWrapTransaction extends TransactionContainer {
+ public AutoWrapTransaction() {
+ super();
+ }
+
+ public void before(TransactionQueryTestCase test) {
+ test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_AUTO);
+
+ }
+
+ public void after(TransactionQueryTestCase test) {
+
+ }
+}
Property changes on:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/AutoWrapTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/OptimisticWrapTransaction.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
-
-
-/**
- * This transction is only valid when
- * AutoCommit = ON
- * txnAutoWrap = Optimistic.
- */
-public class OptimisticWrapTransaction extends TransactionContainer {
- public OptimisticWrapTransaction() {
- super();
- }
-
- public void before(TransactionQueryTestCase test) {
- test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_OPTIMISTIC);
-
- }
-
- public void after(TransactionQueryTestCase test) {
-
- }
-}
Deleted:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/PessimisticWrapTransaction.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2000-2007 MetaMatrix, Inc.
- * All rights reserved.
- */
-package org.teiid.test.framework.transaction;
-
-import org.teiid.test.framework.TransactionContainer;
-import org.teiid.test.framework.TransactionQueryTestCase;
-import org.teiid.test.framework.ConfigPropertyNames.CONNECTION_STRATEGY_PROPS;
-import org.teiid.test.framework.ConfigPropertyNames.TXN_AUTO_WRAP_OPTIONS;
-
-
-/**
- * This transaction type only is valid when
- * AutoCommit = ON
- * txnAutoWrap = PESSIMISTIC
- */
-public class PessimisticWrapTransaction extends TransactionContainer {
- public PessimisticWrapTransaction() {
- super();
- }
-
- public void before(TransactionQueryTestCase test) {
- test.getConnectionStrategy().setEnvironmentProperty(CONNECTION_STRATEGY_PROPS.TXN_AUTO_WRAP,
TXN_AUTO_WRAP_OPTIONS.AUTO_WRAP_PESSIMISTIC);
-
- }
-
- public void after(TransactionQueryTestCase test) {
-
- }
-
-
-}
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-12-15
23:28:12 UTC (rev 1671)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -5,6 +5,7 @@
import java.util.Properties;
import org.teiid.test.framework.ConfigPropertyLoader;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
public class PropUtils {
@@ -25,10 +26,10 @@
}
else {
- throw new RuntimeException("Failed to load properties from file
'"+filename+ "' configuration file");
+ throw new TransactionRuntimeException("Failed to load properties from file
'"+filename+ "' configuration file");
}
} catch (IOException e) {
- throw new RuntimeException("Error loading properties from file
'"+filename+ "'" + e.getMessage());
+ throw new TransactionRuntimeException("Error loading properties from file
'"+filename+ "'" + e.getMessage());
} finally {
try {
in.close();
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
===================================================================
---
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
(rev 0)
+++
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -0,0 +1,492 @@
+/*
+ * 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.AutoWrapTransaction;
+
+import com.metamatrix.jdbc.api.AbstractQueryTest;
+
+
+
+/**
+ * The main thing to test in this is, when the single source should is involved it should
work
+ * fine, when multiple sources involved it should fail.
+ */
+public class AutoWrapTransactionTests extends BaseAbstractTransactionTestCase {
+
+ public AutoWrapTransactionTests(String testName) {
+ super(testName);
+ }
+
+ protected TransactionContainer getTransactionContainter() {
+ return new AutoWrapTransaction();
+ }
+
+
///////////////////////////////////////////////////////////////////////////////////////////////
+ // Single Source - Rows below 500 (for insert/update/delete)
+
///////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Sources = 1
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ 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(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("insert into pm1.g1 (e1, e2) values(?, ?)", new
Object[] {new Integer(102), "102"});
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+
+ // now verify the results
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 = 102");
+ 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() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new
Object[] {new Integer(100)});
+ 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 < 120; 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 and e1 < 120");
+ test.assertRowCount(20);
+ test.execute("select * from g2 where e1 >= 100 and e1 < 120");
+ test.assertRowCount(20);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 200; i < 205; i++) {
+ list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+ };
+
+ // 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 < 205");
+ test.assertRowCount(5);
+ test.execute("select * from g2 where e1 >= 200 and e1 < 205");
+ test.assertRowCount(5);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = 1, Update(prepared statement)
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourcePreparedUpdateRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ 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 g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceMultipleCommandsRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new
Object[] {new Integer(100)});
+ execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new
Object[] {new Integer(100)});
+
+ execute("select * from pm1.g1");
+ assertRowCount(100);
+
+ for (int i = 300; i < 310; 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()});
+ }
+
+ // this will make it rollback
+ 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 (since they are not bundled in single command they
should be treated individually)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 >= 300 and e1 < 310");
+ test.assertRowCount(10);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ test.closeConnection();
+ }
+
+ /**
+ * Sources = 1
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testSingleSourceBatchCommandRollback() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ for (int i = 400; i < 410; i++) {
+ list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
+ }
+
+ // this will make it 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 (all commands will trated as single under single
transaction)
+ AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
+ test.execute("select * from g1 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 >= 400 and e1 < 410");
+ test.assertRowCount(0);
+ test.execute("select * from g2 where e1 = 9999");
+ test.assertRowCount(0);
+ 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);
+ }
+
+ public void after() {
+ // selects are special case as they will not fail to use multiple
sources. The transaction
+ // source count only starts when there are updates to db, so this is OK
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under
optimistic txn");
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ 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()});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under
optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ // run test
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = multiple - Success
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourcesBatchCommand() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ ArrayList list = new ArrayList();
+ list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
+ list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
+
+ list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
+ list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
+
+ for (int i = 200; i < 210; i++) {
+ list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
+
+ list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
+ list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
+ }
+ executeBatch((String[])list.toArray(new String[list.size()]));
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under
optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.g1");
+ }
+
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should not have failed to involve multiple sources under
optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProceduralSelect() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p1");
+ }
+ // if vm.p1 needs a transaction, depends on transformation
+ //
+ public void after() {
+ if (exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under
optimistic txn");
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualProcedure() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 =
?", new Object[] {new Integer(200), "200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under
optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("exec vm.p2(?, ?)", new Object[] {new Integer(200),
"200"});
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under
optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+
+ /**
+ * Sources = 2
+ * Commands = 1, Select
+ * Batching = Full Processing, Single Connector Batch
+ * result = commit
+ */
+ public void testMultipleSourceVirtualUpdate() throws Exception {
+ AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
+ public void testCase() throws Exception {
+ execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
+ }
+
+ public void after() {
+ if (!exceptionOccurred()) {
+ fail("should have failed to involve multiple sources under
optimistic txn");
+ }
+ else {
+ assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
+ }
+ }
+
+ public boolean exceptionExpected() {
+ return true;
+ }
+
+ };
+
+ getTransactionContainter().runTransaction(userTxn);
+ }
+}
Property changes on:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/AutoWrapTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java
===================================================================
---
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/OptimisticWrapTransactionTests.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -1,491 +0,0 @@
-/*
- * 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.OptimisticWrapTransaction;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-
-/**
- * The main thing to test in this is, when the single source should is involved it should
work
- * fine, when multiple sources involved it should fail.
- */
-public class OptimisticWrapTransactionTests extends BaseAbstractTransactionTestCase {
-
- public OptimisticWrapTransactionTests(String testName) {
- super(testName);
- }
-
- protected TransactionContainer getTransactionContainter() {
- return new OptimisticWrapTransaction();
- }
-
-
///////////////////////////////////////////////////////////////////////////////////////////////
- // Single Source - Rows below 500 (for insert/update/delete)
-
///////////////////////////////////////////////////////////////////////////////////////////////
-
- /**
- * Sources = 1
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- 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(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("insert into pm1.g1 (e1, e2) values(?, ?)", new
Object[] {new Integer(102), "102"});
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
-
- // now verify the results
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 = 102");
- 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() {
- public void testCase() throws Exception {
- execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new
Object[] {new Integer(100)});
- 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 < 120; 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 and e1 < 120");
- test.assertRowCount(20);
- test.execute("select * from g2 where e1 >= 100 and e1 < 120");
- test.assertRowCount(20);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceBatchCommand() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- for (int i = 200; i < 205; i++) {
- list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
- }
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
- };
-
- // 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 < 205");
- test.assertRowCount(5);
- test.execute("select * from g2 where e1 >= 200 and e1 < 205");
- test.assertRowCount(5);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = 1, Update(prepared statement)
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourcePreparedUpdateRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- 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 g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceMultipleCommandsRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from pm1.g2 where pm1.g2.e1 >= ?", new
Object[] {new Integer(100)});
- execute("delete from pm1.g1 where pm1.g1.e1 >= ?", new
Object[] {new Integer(100)});
-
- execute("select * from pm1.g1");
- assertRowCount(100);
-
- for (int i = 300; i < 310; 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()});
- }
-
- // this will make it rollback
- 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 (since they are not bundled in single command they
should be treated individually)
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 300 and e1 < 310");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 >= 300 and e1 < 310");
- test.assertRowCount(10);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testSingleSourceBatchCommandRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- for (int i = 400; i < 410; i++) {
- list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
- }
-
- // this will make it 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 (all commands will trated as single under single
transaction)
- AbstractQueryTest test = new QueryExecution(userTxn.getSource("pm1"));
- test.execute("select * from g1 where e1 >= 400 and e1 < 410");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 >= 400 and e1 < 410");
- test.assertRowCount(0);
- test.execute("select * from g2 where e1 = 9999");
- test.assertRowCount(0);
- 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);
- }
-
- public void after() {
- // selects are special case as they will not fail to use multiple
sources. The transaction
- // source count only starts when there are updates to db, so this is OK
- if (exceptionOccurred()) {
- fail("should not have failed to involve multiple sources under
optimistic txn");
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- 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()});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under
optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- // run test
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourcesBatchCommand() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- ArrayList list = new ArrayList();
- list.add("delete from pm1.g2 where pm1.g2.e1 >= 100");
- list.add("delete from pm1.g1 where pm1.g1.e1 >= 100");
-
- list.add("delete from pm2.g2 where pm2.g2.e1 >= 100");
- list.add("delete from pm2.g1 where pm2.g1.e1 >= 100");
-
- for (int i = 200; i < 210; i++) {
- list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
-
- list.add("insert into pm1.g1 (e1, e2)
values("+i+",'"+i+"')");
- list.add("insert into pm1.g2 (e1, e2)
values("+i+",'"+i+"')");
- }
- executeBatch((String[])list.toArray(new String[list.size()]));
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under
optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.g1");
- }
-
- public void after() {
- if (exceptionOccurred()) {
- fail("should not have failed to involve multiple sources under
optimistic txn");
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualProceduralSelect() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.p1");
- }
-
- public void after() {
- if (exceptionOccurred()) {
- fail("should have failed to involve multiple sources under
optimistic txn");
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualProcedure() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("select * from vm.p2 where vm.p2.e1 = ? and vm.p2.e2 =
?", new Object[] {new Integer(200), "200"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under
optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- public void testMultipleSourceVirtualProceduralSelectWithUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("exec vm.p2(?, ?)", new Object[] {new Integer(200),
"200"});
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under
optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-
- /**
- * Sources = 2
- * Commands = 1, Select
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceVirtualUpdate() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- public void testCase() throws Exception {
- execute("delete from vm.g1 where vm.g1.pm1e1 > 100");
- }
-
- public void after() {
- if (!exceptionOccurred()) {
- fail("should have failed to involve multiple sources under
optimistic txn");
- }
- else {
- assertTrue(getLastException().getMessage(),
getLastException().getMessage().indexOf("txnAutoWrap=OPTIMISTIC") != -1);
- }
- }
-
- public boolean exceptionExpected() {
- return true;
- }
-
- };
-
- getTransactionContainter().runTransaction(userTxn);
- }
-}
Deleted:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java
===================================================================
---
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-12-15
23:28:12 UTC (rev 1671)
+++
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/PessimisticWrapTransactionTests.java 2009-12-16
00:07:07 UTC (rev 1672)
@@ -1,141 +0,0 @@
-/*
- * 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.PessimisticWrapTransaction;
-
-import com.metamatrix.jdbc.api.AbstractQueryTest;
-
-
-public class PessimisticWrapTransactionTests extends CommonTransactionTests {
-
- public PessimisticWrapTransactionTests(String testName) {
- super(testName);
- }
-
- protected TransactionContainer getTransactionContainter() {
- return new PessimisticWrapTransaction();
- }
-
- /**
- * 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()});
- }
-
- // 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);
- test.closeConnection();
- }
-
- /**
- * Sources = 1
- * Commands = multiple - Success
- * Batching = Full Processing, Single Connector Batch
- * result = rollback
- */
- public void testSingleSourceBatchCommandReferentialIntegrityRollback() throws
Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- 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);
- test.closeConnection();
- }
-
- /**
- * Sources = 2
- * Commands = 1, Update
- * Batching = Full Processing, Single Connector Batch
- * result = commit
- */
- public void testMultipleSourceBulkRowInsertRollback() throws Exception {
- AbstractQueryTransactionTest userTxn = new AbstractQueryTransactionTest() {
- 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.closeConnection();
-
- 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);
- test.closeConnection();
- }
-}