Author: vhalbert(a)redhat.com
Date: 2009-11-25 16:45:09 -0500 (Wed, 25 Nov 2009)
New Revision: 1603
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java
Log:
Teiid 773 - added the standalone global transaction tests, no failures
Added:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
(rev 0)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java 2009-11-25
21:45:09 UTC (rev 1603)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.framework.transaction;
+
+import java.util.Random;
+
+import javax.transaction.xa.XAResource;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.TransactionQueryTestCase;
+import org.teiid.test.framework.exception.TransactionRuntimeException;
+
+import com.metamatrix.common.xa.MMXid;
+
+public class StandaloneGlobalTransaction extends TransactionContainer {
+ private static Random RANDOM = new Random();
+ private MMXid xid;
+
+ public StandaloneGlobalTransaction() {
+ super();
+ }
+
+ protected void before(TransactionQueryTestCase test) {
+ try {
+ xid = createXid();
+ XAResource xaResource =
this.getConnectionStrategy().getXAConnection().getXAResource();
+ // getXAConnection().getXAResource();
+ xaResource.setTransactionTimeout(120);
+ xaResource.start(xid, XAResource.TMNOFLAGS);
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+
+ public static MMXid createXid() {
+ byte[] gid = new byte[10];
+ byte[] bid = new byte[10];
+ RANDOM.nextBytes(gid);
+ RANDOM.nextBytes(bid);
+ return new MMXid(0, gid, bid);
+ }
+
+ protected void after(TransactionQueryTestCase test) {
+ boolean delistSuccessful = false;
+ boolean commit = false;
+ try {
+ XAResource xaResource =
this.getConnectionStrategy().getXAConnection().getXAResource();
+
+ xaResource.end(xid, XAResource.TMSUCCESS);
+
+ if (!test.exceptionExpected() && xaResource.prepare(xid) ==
XAResource.XA_OK) {
+ commit = true;
+ }
+ delistSuccessful = true;
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ } finally {
+ try {
+ if (!delistSuccessful || test.rollbackAllways()||
test.exceptionOccurred()) {
+
this.getConnectionStrategy().getXAConnection().getXAResource().rollback(xid);
+ //getXAConnection().getXAResource().rollback(xid);
+ }
+ else if (commit) {
+
this.getConnectionStrategy().getXAConnection().getXAResource().commit(xid, true);
+ }
+ } catch (Exception e) {
+ throw new TransactionRuntimeException(e);
+ }
+ }
+ }
+}
Property changes on:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/transaction/StandaloneGlobalTransaction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java
===================================================================
---
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java
(rev 0)
+++
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java 2009-11-25
21:45:09 UTC (rev 1603)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2000-2007 MetaMatrix, Inc.
+ * All rights reserved.
+ */
+package org.teiid.test.testcases;
+
+import org.teiid.test.framework.TransactionContainer;
+import org.teiid.test.framework.transaction.StandaloneGlobalTransaction;
+
+
+/**
+ * This is global transaction test to be used when transaction is external
+ * in places like inside app server
+ */
+public class StandaloneGlobalTransactionTests extends LocalTransactionTests {
+
+ public StandaloneGlobalTransactionTests(String testName) {
+ super(testName);
+ }
+
+ @Override
+ protected TransactionContainer getTransactionContainter() {
+
+ return new StandaloneGlobalTransaction();
+ }
+
+
+}
Property changes on:
trunk/test-integration/db/src/test/java/org/teiid/test/testcases/StandaloneGlobalTransactionTests.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date