[jboss-svn-commits] JBL Code SVN: r23866 - in labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP: ArjunaJTA/jta and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Nov 13 12:02:42 EST 2008


Author: jhalliday
Date: 2008-11-13 12:02:42 -0500 (Thu, 13 Nov 2008)
New Revision: 23866

Added:
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestSynchronization.java
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestXAResource.java
Removed:
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java
Modified:
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/ActionManager.java
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
   labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/build.xml
Log:
Backported JBTM-430 subordinate tx tests from trunk to 4.2.3.SP.  Also backported fixes for JBTM-243 as the tests won't pass otherwise :-)


Modified: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/ActionManager.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/ActionManager.java	2008-11-13 16:26:33 UTC (rev 23865)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/ActionManager.java	2008-11-13 17:02:42 UTC (rev 23866)
@@ -33,42 +33,87 @@
 
 import com.arjuna.ats.arjuna.common.Uid;
 
+import java.util.Collection;
 import java.util.Hashtable;
 
 /*
  * @author Mark Little (mark_little at hp.com)
- * @version $Id: ActionManager.java 2342 2006-03-30 13:06:17Z  $
+ * 
+ * @version $Id: ActionManager.java 2342 2006-03-30 13:06:17Z $
  * @since JTS 3.0
  */
 
 public class ActionManager
 {
 
-    public static final ActionManager manager ()
-    {
-	return _theManager;
-    }
-    
-    public void put (BasicAction act)
-    {
-	_allActions.put(act.get_uid(), act);
-    }
-    
-    public BasicAction get (Uid id)
-    {
-	return (BasicAction) _allActions.get(id);
-    }
-    
-    public void remove (Uid id)
-    {
- 	_allActions.remove(id);
-    }
-    
-    private ActionManager ()
-    {
-    }
-    
-    private static ActionManager _theManager = new ActionManager();
-    private static Hashtable     _allActions = new Hashtable();
+	class Lifetime
+	{
+		public Lifetime (BasicAction act)
+		{
+			theAction = act;
+			timeAdded = System.currentTimeMillis();
+		}
+		
+		public BasicAction getAction ()
+		{
+			return theAction;
+		}
+		
+		public long getTimeAdded ()
+		{
+			return timeAdded;
+		}
+		
+		private BasicAction theAction;
+		private long timeAdded;
+	}
+	
+	public static final ActionManager manager()
+	{
+		return _theManager;
+	}
 
+	public void put(BasicAction act)
+	{
+		_allActions.put(act.get_uid(), new Lifetime(act));
+	}
+
+	public BasicAction get(Uid id)
+	{
+		Lifetime lt = (Lifetime) _allActions.get(id);
+		
+		if (lt != null)
+			return lt.getAction();
+		else
+			return null;
+	}
+
+	public long getTimeAdded (Uid id)
+	{
+		Lifetime lt = (Lifetime) _allActions.get(id);
+		
+		if (lt != null)
+			return lt.getTimeAdded();
+		else
+			return 0;
+	}
+	
+	public void remove(Uid id)
+	{
+		_allActions.remove(id);
+	}
+
+	public Collection inflightTransactions ()
+	{
+		return _allActions.values();
+	}
+	
+	private ActionManager()
+	{
+	}
+
+	private static final ActionManager _theManager = new ActionManager();
+
+	private static final Hashtable _allActions = new Hashtable();
+
 }

Modified: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java	2008-11-13 16:26:33 UTC (rev 23865)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java	2008-11-13 17:02:42 UTC (rev 23866)
@@ -1777,6 +1777,8 @@
 			if (doOnePhase())
 			{
 				onePhaseCommit(reportHeuristics);
+				
+				ActionManager.manager().remove(get_uid());
 			}
 			else
 			{			
@@ -1821,11 +1823,12 @@
 			}
 		}
 		else
+		{
+			ActionManager.manager().remove(get_uid());
+		
 			actionStatus = ActionStatus.COMMITTED;
+		}
 
-		//BasicAction.allActions.remove(get_uid());
-		ActionManager.manager().remove(get_uid());
-
 		boolean returnCurrentStatus = false;
 
 		if (reportHeuristics || (!reportHeuristics && !TxControl.asyncCommit))
@@ -2168,6 +2171,8 @@
 
 			updateState();
 
+			ActionManager.manager().remove(get_uid());
+			
 			criticalEnd();
 		}
 	}
@@ -2227,6 +2232,8 @@
 		updateState(); // we may end up saving more than the heuristic list
 					   // here!
 
+		ActionManager.manager().remove(get_uid());
+		
 		criticalEnd();
 	}
 
@@ -2722,6 +2729,8 @@
 
 		forgetHeuristics();
 
+		ActionManager.manager().remove(get_uid());
+		
 		criticalEnd();
 	}
 

Modified: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/build.xml
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/build.xml	2008-11-13 16:26:33 UTC (rev 23865)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/build.xml	2008-11-13 17:02:42 UTC (rev 23866)
@@ -203,6 +203,7 @@
                 <batchtest haltonerror="yes" haltonfailure="yes" fork="yes"
                     todir="${com.hp.mwlabs.ts.jta.reports.dest}">
                     <fileset dir="${com.hp.mwlabs.ts.jta.tests.src}" includes="**/LastResource*TestCase.java"/>
+                    <fileset dir="${com.hp.mwlabs.ts.jta.tests.src}" includes="**/SubordinateTestCase.java"/>
                 </batchtest>
             </junit>
 	</target>

Copied: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate (from rev 12950, labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate)

Deleted: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java	2007-06-29 15:51:21 UTC (rev 12950)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java	2008-11-13 17:02:42 UTC (rev 23866)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors 
- * as indicated by the @author tags. 
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors. 
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A 
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
- * MA  02110-1301, USA.
- * 
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-package com.hp.mwtests.ts.jta.subordinate;
-
-import java.io.File;
-import java.io.PrintWriter;
-
-import junit.framework.TestCase;
-
-import com.arjuna.ats.arjuna.coordinator.ActionManager;
-import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple;
-
-public class SubordinateTestCase extends TestCase
-{
-	public void testCleanupCommit () throws Exception
-	{
-		for (int i = 0; i < 1000; i++)
-		{
-			final TransactionImple tm = new TransactionImple(0); // implicit begin
-
-			tm.doPrepare();
-			tm.doCommit();
-		}
-		
-		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
-	}
-	
-	public void testCleanupRollback () throws Exception
-	{
-		for (int i = 0; i < 1000; i++)
-		{
-			final TransactionImple tm = new TransactionImple(0); // implicit begin
-
-			tm.doRollback();
-		}
-		
-		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
-	}
-	
-	public void testCleanupSecondPhaseRollback () throws Exception
-	{	
-		for (int i = 0; i < 1000; i++)
-		{
-			final TransactionImple tm = new TransactionImple(0); // implicit begin
-
-			tm.doPrepare();
-			tm.doRollback();
-		}
-		
-		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
-	}
-	
-	public void testCleanupOnePhaseCommit () throws Exception
-	{
-		for (int i = 0; i < 1000; i++)
-		{
-			final TransactionImple tm = new TransactionImple(0); // implicit begin
-
-			tm.doOnePhaseCommit();
-		}
-		
-		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
-	}
-}

Copied: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java (from rev 12950, labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTestCase.java	2008-11-13 17:02:42 UTC (rev 23866)
@@ -0,0 +1,271 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package com.hp.mwtests.ts.jta.subordinate;
+
+import junit.framework.TestCase;
+
+import com.arjuna.ats.arjuna.coordinator.ActionManager;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.TxImporter;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
+import com.arjuna.ats.jta.xa.XidImple;
+
+import javax.transaction.RollbackException;
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+import javax.resource.spi.XATerminator;
+
+public class SubordinateTestCase extends TestCase
+{
+	public void testCleanupCommit () throws Exception
+	{
+		for (int i = 0; i < 1000; i++)
+		{
+			final TransactionImple tm = new TransactionImple(0); // implicit begin
+
+			tm.doPrepare();
+			tm.doCommit();
+		}
+
+		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
+	}
+
+	public void testCleanupRollback () throws Exception
+	{
+		for (int i = 0; i < 1000; i++)
+		{
+			final TransactionImple tm = new TransactionImple(0); // implicit begin
+
+			tm.doRollback();
+		}
+
+		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
+	}
+
+	public void testCleanupSecondPhaseRollback () throws Exception
+	{
+		for (int i = 0; i < 1000; i++)
+		{
+			final TransactionImple tm = new TransactionImple(0); // implicit begin
+
+			tm.doPrepare();
+			tm.doRollback();
+		}
+
+		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
+	}
+
+	public void testCleanupOnePhaseCommit () throws Exception
+	{
+		for (int i = 0; i < 1000; i++)
+		{
+			final TransactionImple tm = new TransactionImple(0); // implicit begin
+
+			tm.doOnePhaseCommit();
+		}
+
+		assertEquals(ActionManager.manager().inflightTransactions().size(), 0);
+	}
+
+    /////////////
+
+    public void testOnePhaseCommitSync() throws Exception
+    {
+        final TransactionImple tm = new TransactionImple(0);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        tm.doOnePhaseCommit();
+        assertTrue(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
+    }
+
+    public void testOnePhaseCommitSyncViaXATerminator() throws Exception
+    {
+        final Xid xid = new XidImple(new Uid());
+        final TransactionImple tm = TxImporter.importTransaction(xid);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        final XATerminator xaTerminator = new XATerminatorImple();
+        xaTerminator.commit(xid, true);
+        assertTrue(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
+    }
+
+    public void testOnePhaseCommitSyncWithRollbackOnly() throws Exception
+    {
+        final TransactionImple tm = new TransactionImple(0);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        tm.setRollbackOnly();
+        try {
+            tm.doOnePhaseCommit();
+            fail("did not get expected rollback exception");
+        } catch(RollbackException e) {
+            // expected - we tried to commit a rollbackonly tx.
+        }
+        assertFalse(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
+    }
+
+    public void testOnePhaseCommitSyncWithRollbackOnlyViaXATerminator() throws Exception
+    {
+        final Xid xid = new XidImple(new Uid());
+        final TransactionImple tm = TxImporter.importTransaction(xid);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        tm.setRollbackOnly();
+        final XATerminator xaTerminator = new XATerminatorImple();
+        try {
+            xaTerminator.commit(xid, true);
+            tm.doOnePhaseCommit();
+            fail("did not get expected rollback exception");
+        } catch(XAException e) {
+            assertEquals("javax.transaction.RollbackException", e.getCause().getClass().getName());
+            assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
+            // expected - we tried to commit a rollbackonly tx.
+        }
+        assertFalse(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
+    }
+
+    public void testRollbackSync() throws Exception
+    {
+        final TransactionImple tm = new TransactionImple(0);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        tm.doRollback();
+        assertFalse(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
+    }
+
+    public void testRollbackSyncViaXATerminator() throws Exception
+    {
+        final Xid xid = new XidImple(new Uid());
+        final TransactionImple tm = TxImporter.importTransaction(xid);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        final XATerminator xaTerminator = new XATerminatorImple();
+        xaTerminator.rollback(xid);
+        assertFalse(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
+    }
+
+    public void testTwoPhaseCommitSync() throws Exception
+    {
+        final TransactionImple tm = new TransactionImple(0);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        assertEquals(TwoPhaseOutcome.PREPARE_READONLY, tm.doPrepare());
+        tm.doCommit();
+        assertTrue(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
+    }
+
+    public void testTwoPhaseCommitSyncViaXATerminator() throws Exception
+    {
+        final Xid xid = new XidImple(new Uid());
+        final TransactionImple tm = TxImporter.importTransaction(xid);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        final XATerminator xaTerminator = new XATerminatorImple();
+        assertEquals(XAResource.XA_RDONLY, xaTerminator.prepare(xid));
+        // note that unlike the above test we don't call commit - the XA_RDONLY means its finished, per XA semantics.
+        assertTrue(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
+    }
+
+    public void testTwoPhaseCommitSyncWithXAOK() throws Exception
+    {
+        final TransactionImple tm = new TransactionImple(0);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        final TestXAResource xaResource = new TestXAResource();
+        xaResource.setPrepareReturnValue(XAResource.XA_OK);
+        tm.enlistResource(xaResource);
+        assertEquals(TwoPhaseOutcome.PREPARE_OK, tm.doPrepare());
+        tm.doCommit();
+        assertTrue(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
+    }
+
+    public void testTwoPhaseCommitSyncWithXAOKViaXATerminator() throws Exception
+    {
+        final Xid xid = new XidImple(new Uid());
+        final TransactionImple tm = TxImporter.importTransaction(xid);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        final TestXAResource xaResource = new TestXAResource();
+        xaResource.setPrepareReturnValue(XAResource.XA_OK);
+        tm.enlistResource(xaResource);
+        final XATerminator xaTerminator = new XATerminatorImple();
+        assertEquals(XAResource.XA_OK, xaTerminator.prepare(xid));
+        xaTerminator.commit(xid, false);
+        assertTrue(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_COMMITTED, tm.getStatus());
+    }
+
+    public void testTwoPhaseCommitSyncWithRollbackOnly() throws Exception
+    {
+        final TransactionImple tm = new TransactionImple(0);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        tm.setRollbackOnly();
+        assertEquals(TwoPhaseOutcome.PREPARE_NOTOK, tm.doPrepare());
+        tm.doRollback();
+        assertFalse(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
+    }
+
+    public void testTwoPhaseCommitSyncWithRollbackOnlyViaXATerminator() throws Exception
+    {
+        final Xid xid = new XidImple(new Uid());
+        final TransactionImple tm = TxImporter.importTransaction(xid);
+        final TestSynchronization sync = new TestSynchronization();
+        tm.registerSynchronization(sync);
+        tm.setRollbackOnly();
+        final XATerminator xaTerminator = new XATerminatorImple();
+
+        try {
+            xaTerminator.prepare(xid);
+        } catch(XAException e) {
+            assertEquals(XAException.XA_RBROLLBACK, e.errorCode);
+            // expected - we tried to prepare a rollbackonly tx.
+        }
+        // no need to call rollback - the XA_RBROLLBACK code indicates it's been done.
+        assertFalse(sync.isBeforeCompletionDone());
+        assertTrue(sync.isAfterCompletionDone());
+        assertEquals(javax.transaction.Status.STATUS_ROLLEDBACK, tm.getStatus());
+    }
+}

Copied: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestSynchronization.java (from rev 23856, labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestSynchronization.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestSynchronization.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestSynchronization.java	2008-11-13 17:02:42 UTC (rev 23866)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package com.hp.mwtests.ts.jta.subordinate;
+
+import javax.transaction.Synchronization;
+
+/**
+ * Implementation of Synchronization for use in tx test cases.
+ */
+public class TestSynchronization implements Synchronization
+{
+    private boolean beforeCompletionDone = false;
+    private boolean afterCompletionDone = false;
+
+    public boolean isBeforeCompletionDone()
+    {
+        return beforeCompletionDone;
+    }
+
+    public boolean isAfterCompletionDone()
+    {
+        return afterCompletionDone;
+    }
+
+    public void beforeCompletion() {
+        beforeCompletionDone = true;
+        System.out.println("TestSynchronization.beforeCompletion()");
+    }
+
+    public void afterCompletion(int i) {
+        afterCompletionDone = true;
+        System.out.println("TestSynchronization.afterCompletion("+i+")");
+    }
+}
\ No newline at end of file

Copied: labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestXAResource.java (from rev 23856, labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestXAResource.java)
===================================================================
--- labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestXAResource.java	                        (rev 0)
+++ labs/jbosstm/branches/JBOSSTS_4_2_3_GA_SP/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/TestXAResource.java	2008-11-13 17:02:42 UTC (rev 23866)
@@ -0,0 +1,119 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2008,
+ * @author JBoss Inc.
+ */
+package com.hp.mwtests.ts.jta.subordinate;
+
+import javax.transaction.xa.XAResource;
+import javax.transaction.xa.Xid;
+import javax.transaction.xa.XAException;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: jhalli
+ * Date: Apr 4, 2008
+ * Time: 3:45:55 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class TestXAResource implements XAResource
+{
+    private int txTimeout;
+
+    private Xid currentXid;
+
+    private int prepareReturnValue = XAResource.XA_OK;
+
+    public int getPrepareReturnValue()
+    {
+        return prepareReturnValue;
+    }
+
+    public void setPrepareReturnValue(int prepareReturnValue)
+    {
+        this.prepareReturnValue = prepareReturnValue;
+    }
+
+    public void commit(Xid xid, boolean b) throws XAException
+    {
+        System.out.println("XAResourceImpl.commit(Xid="+xid+", b="+b+")");
+        if(!xid.equals(currentXid)) {
+            System.out.println("XAResourceImpl.commit - wrong Xid!");
+        }
+
+        currentXid = null;
+    }
+
+    public void end(Xid xid, int i) throws XAException {
+        System.out.println("XAResourceImpl.end(Xid="+xid+", b="+i+")");
+    }
+
+    public void forget(Xid xid) throws XAException {
+        System.out.println("XAResourceImpl.forget(Xid="+xid+")");
+        if(!xid.equals(currentXid)) {
+            System.out.println("XAResourceImpl.forget - wrong Xid!");
+        }
+        currentXid = null;
+    }
+
+    public int getTransactionTimeout() throws XAException {
+        System.out.println("XAResourceImpl.getTransactionTimeout() [returning "+txTimeout+"]");
+        return txTimeout;
+    }
+
+    public boolean isSameRM(XAResource xaResource) throws XAException {
+        System.out.println("XAResourceImpl.isSameRM(xaResource="+xaResource+")");
+        return false;
+    }
+
+    public int prepare(Xid xid) throws XAException {
+        System.out.println("XAResourceImpl.prepare(Xid="+xid+") returning "+prepareReturnValue);
+        return prepareReturnValue;
+    }
+
+    public Xid[] recover(int i) throws XAException {
+        System.out.println("XAResourceImpl.recover(i="+i+")");
+        return new Xid[0];
+    }
+
+    public void rollback(Xid xid) throws XAException {
+        System.out.println("XAResourceImpl.rollback(Xid="+xid+")");
+        if(!xid.equals(currentXid)) {
+            System.out.println("XAResourceImpl.rollback - wrong Xid!");
+        }
+        currentXid = null;
+    }
+
+    public boolean setTransactionTimeout(int i) throws XAException {
+        System.out.println("XAResourceImpl.setTransactionTimeout(i="+i+")");
+        txTimeout= i;
+        return true;
+    }
+
+    public void start(Xid xid, int i) throws XAException {
+        System.out.println("XAResourceImpl.start(Xid="+xid+", i="+i+")");
+        if(currentXid != null) {
+            System.out.println("XAResourceImpl.start - wrong Xid!");
+        }
+        currentXid = xid;
+    }
+
+    public String toString() {
+        return new String("XAResourceImple("+txTimeout+", "+currentXid+")");
+    }
+}




More information about the jboss-svn-commits mailing list