[jboss-svn-commits] JBL Code SVN: r31845 - in labs/jbosstm/trunk/ArjunaJTA/jta: classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca and 9 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Feb 25 17:34:59 EST 2010


Author: mark.little at jboss.com
Date: 2010-02-25 17:34:58 -0500 (Thu, 25 Feb 2010)
New Revision: 31845

Added:
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/XID.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/SubordinateTxUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryResourceUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTxUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/TxInfoUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/XAUtilsUnitTest.java
Removed:
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java
Modified:
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca/SubordinateAtomicAction.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/TxInfo.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java
Log:
https://jira.jboss.org/jira/browse/JBTM-712

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/SubordinateAtomicAction.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -47,9 +47,7 @@
 
 	public SubordinateAtomicAction ()
 	{
-		super();
-
-		start();
+		this(AtomicAction.NO_TIMEOUT);
 	}
 
 	public SubordinateAtomicAction (int timeout)
@@ -73,7 +71,7 @@
 
 	public int commit ()
 	{
-		return ActionStatus.INVALID;
+		return commit(true);
 	}
 
 	/**

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca/SubordinateAtomicAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca/SubordinateAtomicAction.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca/SubordinateAtomicAction.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -99,25 +99,29 @@
 
 	public boolean save_state (OutputObjectState os, int t)
 	{
-		if (_theXid != null)
-		{
-			try
-			{
-				os.packBoolean(true);
-				
-				((XidImple) _theXid).packInto(os);
-			}
-			catch (IOException ex)
-			{
-				return false;
-			}
-		}
+	    try
+	    {
+	        if (_theXid != null)
+	        {
+	            os.packBoolean(true);
 
-		return super.save_state(os, t);
+	            ((XidImple) _theXid).packInto(os);
+	        }
+	        else
+	            os.packBoolean(false);
+	    }
+	    catch (IOException ex)
+	    {
+	        return false;
+	    }
+
+	    return super.save_state(os, t);
 	}
 	
 	public boolean restore_state (InputObjectState os, int t)
 	{
+	    _theXid = null;
+	    
 		try
 		{
 			boolean haveXid = os.unpackBoolean();

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/TxInfo.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/TxInfo.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/TxInfo.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -51,10 +51,7 @@
     
     public TxInfo (Xid xid)
     {
-	_xid = xid;
-	_thread = Thread.currentThread();
-
-	setState(TxInfo.ASSOCIATED);
+        this(xid, TxInfo.ASSOCIATED);
     }
 
     public TxInfo (Xid xid, int state)

Copied: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/XID.java (from rev 31770, labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java)
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/XID.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/xa/XID.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: XID.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.arjuna.ats.internal.jta.xa;
+
+import java.io.Serializable;
+
+import com.arjuna.ats.jta.xa.XATxConverter;
+
+/**
+ * An X/Open XID implementation.
+ *
+ * @author Mark Little (mark at arjuna.com)
+ * @version $Id: XID.java 2342 2006-03-30 13:06:17Z  $
+ * @since JTS 1.0.
+ */
+
+public class XID implements Serializable
+{
+    private static final long serialVersionUID = 1L;
+
+    public static final int XIDDATASIZE = 128; /* size in bytes */
+
+	public static final int MAXGTRIDSIZE = 64; /*
+												 * maximum size in bytes of
+												 * gtrid
+												 */
+
+	public static final int MAXBQUALSIZE = 64; /*
+												 * maximum size in bytes of
+												 * bqual
+												 */
+
+	public static final int NULL_XID = -1;
+
+	public XID ()
+	{
+		formatID = NULL_XID;
+		gtrid_length = 0;
+		bqual_length = 0;
+	}
+
+	/**
+	 * Check for equality, then check transaction id only.
+	 */
+
+	public final boolean isSameTransaction (XID xid)
+	{
+		if (formatID == xid.formatID)
+		{
+			if (gtrid_length == xid.gtrid_length)
+			{
+				if (equals(xid))
+					return true;
+				else
+				{
+					for (int i = 0; i < gtrid_length; i++)
+					{
+						if (data[i] != xid.data[i])
+							return false;
+					}
+
+					return true;
+				}
+			}
+		}
+
+		return false;
+	}
+
+	public void copy (XID toCopy)
+	{
+		if ((toCopy == null) || (toCopy.formatID == NULL_XID))
+		{
+			formatID = NULL_XID;
+			gtrid_length = 0;
+			bqual_length = 0;
+		}
+		else
+		{
+			formatID = toCopy.formatID;
+			gtrid_length = toCopy.gtrid_length;
+			bqual_length = toCopy.bqual_length;
+
+			System.arraycopy(toCopy.data, 0, data, 0, toCopy.data.length);
+		}
+	}
+
+	public boolean equals (XID other)
+	{
+		if (other == null)
+			return false;
+
+		if (other == this)
+			return true;
+		else
+		{
+			if ((formatID == other.formatID)
+					&& (gtrid_length == other.gtrid_length)
+					&& (bqual_length == other.bqual_length))
+			{
+				for (int i = 0; i < (gtrid_length + bqual_length); i++)
+				{
+					if (data[i] != other.data[i])
+						return false;
+				}
+
+				return true;
+			}
+			else
+				return false;
+		}
+	}
+
+	public String toString ()
+	{
+        // controversial and not too robust. see JBTM-297 before messing with this.
+
+        if(formatID == XATxConverter.FORMAT_ID) {
+            // it's one of ours, we know how to inspect it:
+            return XATxConverter.getXIDString(this);
+        }
+
+        // it's a foreign id format, use a general algorithm:
+
+        StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append("< ");
+        stringBuilder.append(formatID);
+        stringBuilder.append(", ");
+        stringBuilder.append(gtrid_length);
+        stringBuilder.append(", ");
+        stringBuilder.append(bqual_length);
+        stringBuilder.append(", ");
+
+        for (int i = 0; i < gtrid_length; i++) {
+            stringBuilder.append(data[i]);
+        }
+        stringBuilder.append(", ");
+        for (int i = 0; i < bqual_length; i++) {
+            stringBuilder.append(gtrid_length+data[i]);
+        }
+
+        stringBuilder.append(" >");
+        return stringBuilder.toString();
+	}
+
+	public int formatID; /* format identifier (0 for OSI) */
+	public int gtrid_length; /* value not to exceed 64 */
+	public int bqual_length; /* value not to exceed 64 */
+	public byte[] data = new byte[XIDDATASIZE];
+
+}

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/utils/XAHelper.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -104,6 +104,8 @@
 				return "XAException.XAER_OUTSIDE";
 			case XAException.XA_RETRY:
 				return "XAException.XA_RETRY";
+			case XAException.XAER_ASYNC:
+			    return "XAException.XAER_ASYNC";
 			default:
 				return jtaLogger.loggerI18N.getString("com.arjuna.ats.jta.utils.unknownerrorcode")
 						+ e.errorCode;

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XATxConverter.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -33,6 +33,7 @@
 
 import com.arjuna.ats.arjuna.common.Uid;
 import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.internal.jta.xa.XID;
 
 import javax.transaction.xa.Xid;
 import java.io.UnsupportedEncodingException;

Deleted: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XID.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -1,177 +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.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: XID.java 2342 2006-03-30 13:06:17Z  $
- */
-
-package com.arjuna.ats.jta.xa;
-
-import java.io.Serializable;
-
-/**
- * An X/Open XID implementation.
- *
- * @author Mark Little (mark at arjuna.com)
- * @version $Id: XID.java 2342 2006-03-30 13:06:17Z  $
- * @since JTS 1.0.
- */
-// package private, arguably should be inner class of XidImple.
-class XID implements Serializable
-{
-
-	public static final int XIDDATASIZE = 128; /* size in bytes */
-
-	public static final int MAXGTRIDSIZE = 64; /*
-												 * maximum size in bytes of
-												 * gtrid
-												 */
-
-	public static final int MAXBQUALSIZE = 64; /*
-												 * maximum size in bytes of
-												 * bqual
-												 */
-
-	public static final int NULL_XID = -1;
-
-	public XID ()
-	{
-		formatID = NULL_XID;
-		gtrid_length = 0;
-		bqual_length = 0;
-	}
-
-	/**
-	 * Check for equality, then check transaction id only.
-	 */
-
-	public final boolean isSameTransaction (XID xid)
-	{
-		if (formatID == xid.formatID)
-		{
-			if (gtrid_length == xid.gtrid_length)
-			{
-				if (equals(xid))
-					return true;
-				else
-				{
-					for (int i = 0; i < gtrid_length; i++)
-					{
-						if (data[i] != xid.data[i])
-							return false;
-					}
-
-					return true;
-				}
-			}
-		}
-
-		return false;
-	}
-
-	public void copy (XID toCopy)
-	{
-		if ((toCopy == null) || (toCopy.formatID == NULL_XID))
-		{
-			formatID = NULL_XID;
-			gtrid_length = 0;
-			bqual_length = 0;
-		}
-		else
-		{
-			formatID = toCopy.formatID;
-			gtrid_length = toCopy.gtrid_length;
-			bqual_length = toCopy.bqual_length;
-
-			System.arraycopy(toCopy.data, 0, data, 0, toCopy.data.length);
-		}
-	}
-
-	public boolean equals (XID other)
-	{
-		if (other == null)
-			return false;
-
-		if (other == this)
-			return true;
-		else
-		{
-			if ((formatID == other.formatID)
-					&& (gtrid_length == other.gtrid_length)
-					&& (bqual_length == other.bqual_length))
-			{
-				for (int i = 0; i < (gtrid_length + bqual_length); i++)
-				{
-					if (data[i] != other.data[i])
-						return false;
-				}
-
-				return true;
-			}
-			else
-				return false;
-		}
-	}
-
-	public String toString ()
-	{
-        // controversial and not too robust. see JBTM-297 before messing with this.
-
-        if(formatID == XATxConverter.FORMAT_ID) {
-            // it's one of ours, we know how to inspect it:
-            return XATxConverter.getXIDString(this);
-        }
-
-        // it's a foreign id format, use a general algorithm:
-
-        StringBuilder stringBuilder = new StringBuilder();
-        stringBuilder.append("< ");
-        stringBuilder.append(formatID);
-        stringBuilder.append(", ");
-        stringBuilder.append(gtrid_length);
-        stringBuilder.append(", ");
-        stringBuilder.append(bqual_length);
-        stringBuilder.append(", ");
-
-        for (int i = 0; i < gtrid_length; i++) {
-            stringBuilder.append(data[i]);
-        }
-        stringBuilder.append(", ");
-        for (int i = 0; i < bqual_length; i++) {
-            stringBuilder.append(gtrid_length+data[i]);
-        }
-
-        stringBuilder.append(" >");
-        return stringBuilder.toString();
-	}
-
-	public int formatID; /* format identifier (0 for OSI) */
-	public int gtrid_length; /* value not to exceed 64 */
-	public int bqual_length; /* value not to exceed 64 */
-	public byte[] data = new byte[XIDDATASIZE];
-
-}

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/jta/xa/XidImple.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -31,6 +31,7 @@
 
 package com.arjuna.ats.jta.xa;
 
+import com.arjuna.ats.internal.jta.xa.XID;
 import com.arjuna.ats.jta.logging.jtaLogger;
 
 import com.arjuna.ats.arjuna.common.*;

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/basic/UtilsUnitTest.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -21,10 +21,14 @@
 
 package com.hp.mwtests.ts.jta.basic;
 
+import javax.transaction.xa.XAException;
+
 import org.junit.Test;
 
+import com.arjuna.ats.arjuna.common.Uid;
 import com.arjuna.ats.jta.utils.JTAHelper;
 import com.arjuna.ats.jta.utils.XAHelper;
+import com.arjuna.ats.jta.xa.XidImple;
 
 import static org.junit.Assert.*;
 
@@ -46,7 +50,88 @@
     
     @Test
     public void testXAHelper () throws Exception
-    {
+    {   
         assertTrue(XAHelper.printXAErrorCode(null) != null);
+        
+        XAException ex = new XAException(XAException.XA_HEURCOM);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURCOM");
+        
+        ex = new XAException(XAException.XA_HEURHAZ);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURHAZ");
+        
+        ex = new XAException(XAException.XA_HEURMIX);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURMIX");
+        
+        ex = new XAException(XAException.XA_HEURRB);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_HEURRB");
+        
+        ex = new XAException(XAException.XA_NOMIGRATE);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_NOMIGRATE");
+        
+        ex = new XAException(XAException.XA_RBCOMMFAIL);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBCOMMFAIL");
+        
+        ex = new XAException(XAException.XA_RBDEADLOCK);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBDEADLOCK");
+        
+        ex = new XAException(XAException.XA_RBINTEGRITY);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBINTEGRITY");
+        
+        ex = new XAException(XAException.XA_RBOTHER);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBOTHER");
+        
+        ex = new XAException(XAException.XA_RBPROTO);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBPROTO");
+        
+        ex = new XAException(XAException.XA_RBROLLBACK);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBROLLBACK");
+        
+        ex = new XAException(XAException.XA_RBTIMEOUT);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBTIMEOUT");
+        
+        ex = new XAException(XAException.XA_RBTRANSIENT);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RBTRANSIENT");
+        
+        ex = new XAException(XAException.XA_RDONLY);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RDONLY");
+        
+        ex = new XAException(XAException.XA_RETRY);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XA_RETRY");
+        
+        ex = new XAException(XAException.XAER_RMERR);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_RMERR");
+        
+        ex = new XAException(XAException.XAER_ASYNC);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_ASYNC");
+        
+        ex = new XAException(XAException.XAER_DUPID);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_DUPID");       
+        
+        ex = new XAException(XAException.XAER_INVAL);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_INVAL");
+        
+        ex = new XAException(XAException.XAER_NOTA);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_NOTA");
+        
+        ex = new XAException(XAException.XAER_OUTSIDE);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_OUTSIDE");
+        
+        ex = new XAException(XAException.XAER_PROTO);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_PROTO");
+        
+        ex = new XAException(XAException.XAER_RMFAIL);
+        assertEquals(XAHelper.printXAErrorCode(ex), "XAException.XAER_RMFAIL");
+        
+        XidImple xid1 = new XidImple(new Uid());
+        XidImple xid2 = new XidImple(new Uid());
+        XidImple xid3 = new XidImple(xid1);
+        
+        assertFalse(XAHelper.sameXID(xid1, xid2));
+        assertTrue(XAHelper.sameXID(xid1, xid3));
+        
+        assertTrue(XAHelper.sameTransaction(xid1, xid1));
+        assertTrue(XAHelper.sameTransaction(xid1, xid3));
+        
+        assertTrue(XAHelper.xidToString(xid1) != null);
     }
 }

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/SubordinateTxUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/SubordinateTxUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/SubordinateTxUnitTest.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.hp.mwtests.ts.jta.jca;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.SubordinateAtomicAction;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.jca.TransactionImple;
+
+import static org.junit.Assert.*;
+
+public class SubordinateTxUnitTest
+{
+    @Test
+    public void testTransactionImple () throws Exception
+    {
+        TransactionImple tx = new TransactionImple(new Uid());
+        TransactionImple dummy = new TransactionImple(new Uid());
+        
+        tx.recordTransaction();
+        
+        assertFalse(tx.equals(dummy));
+        
+        assertTrue(tx.toString() != null);
+        
+        tx.recover();
+    }
+    
+    @Test
+    public void testAtomicAction () throws Exception
+    {
+        SubordinateAtomicAction saa1 = new SubordinateAtomicAction();
+        SubordinateAtomicAction saa2 = new SubordinateAtomicAction(new Uid());
+        OutputObjectState os = new OutputObjectState();
+        
+        assertTrue(saa1.save_state(os, ObjectType.ANDPERSISTENT));
+        
+        InputObjectState is = new InputObjectState(os);
+        
+        assertTrue(saa2.restore_state(is, ObjectType.ANDPERSISTENT));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryResourceUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryResourceUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryResourceUnitTest.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.hp.mwtests.ts.jta.recovery;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryResourceManagerImple;
+
+import static org.junit.Assert.*;
+
+public class XARecoveryResourceUnitTest
+{
+    @Test
+    public void test()
+    {
+        XARecoveryResourceManagerImple xarr = new XARecoveryResourceManagerImple();
+        
+        assertTrue(xarr.getResource(new Uid()) != null);
+        assertTrue(xarr.getResource(new Uid(), null) != null);
+        assertTrue(xarr.type() != null);
+    }
+}

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTxUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTxUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/subordinate/SubordinateTxUnitTest.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -0,0 +1,151 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.hp.mwtests.ts.jta.subordinate;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.SubordinateAtomicAction;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple;
+import com.arjuna.ats.jta.exceptions.InvalidTerminationStateException;
+
+import static org.junit.Assert.*;
+
+class DummyTransactionImple extends TransactionImple
+{
+    public DummyTransactionImple()
+    {
+        super(0);
+    }
+    
+    protected void commitAndDisassociate () throws javax.transaction.RollbackException, javax.transaction.HeuristicMixedException, javax.transaction.HeuristicRollbackException, java.lang.SecurityException, javax.transaction.SystemException, java.lang.IllegalStateException
+    {
+        super.commitAndDisassociate();
+    }
+
+    protected void rollbackAndDisassociate () throws java.lang.IllegalStateException, java.lang.SecurityException, javax.transaction.SystemException
+    {
+        super.rollbackAndDisassociate();
+    }
+}
+
+public class SubordinateTxUnitTest
+{
+    @Test
+    public void testTransactionImple () throws Exception
+    {
+        TransactionImple tx = new TransactionImple(0);
+        TransactionImple dummy = new TransactionImple(0);
+        
+        assertFalse(tx.equals(dummy));
+        
+        try
+        {
+            tx.commit();
+            
+            fail();
+        }
+        catch (final IllegalStateException ex)
+        {
+        }
+        
+        try
+        {
+            tx.rollback();
+            
+            fail();
+        }
+        catch (InvalidTerminationStateException ex)
+        {
+        }
+        
+        assertEquals(tx.doPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        
+        tx.doCommit();
+        
+        dummy.doRollback();
+        
+        tx = new TransactionImple(10);
+        
+        tx.doOnePhaseCommit();
+        tx.doForget();
+        
+        tx.doBeforeCompletion();
+        
+        assertTrue(tx.toString() != null);
+        assertTrue(tx.activated());
+    }
+    
+    @Test
+    public void testAtomicAction () throws Exception
+    {
+        SubordinateAtomicAction saa = new SubordinateAtomicAction();
+        AtomicAction A = new AtomicAction();
+        
+        assertEquals(saa.commit(), ActionStatus.INVALID);
+        assertEquals(saa.abort(), ActionStatus.INVALID);
+        
+        assertTrue(saa.type() != A.type());
+        
+        assertTrue(saa.activated());
+        
+        saa.doForget();
+    }
+    
+    @Test
+    public void testError () throws Exception
+    {
+        DummyTransactionImple dti = new DummyTransactionImple();
+        
+        try
+        {
+            dti.commitAndDisassociate();
+            
+            fail();
+        }
+        catch (final InvalidTerminationStateException ex)
+        {   
+        }
+        
+        try
+        {
+            dti.rollbackAndDisassociate();
+            
+            fail();
+        }
+        catch (final InvalidTerminationStateException ex)
+        {
+        }
+    }
+}

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/TxInfoUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/TxInfoUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/TxInfoUnitTest.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.hp.mwtests.ts.jta.xa;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.jta.xa.TxInfo;
+import com.arjuna.ats.jta.xa.XidImple;
+
+import static org.junit.Assert.*;
+
+public class TxInfoUnitTest
+{
+    @Test
+    public void test()
+    {
+        TxInfo tx = new TxInfo(new XidImple(new Uid()));
+        
+        tx.setState(-1);
+        
+        assertEquals(tx.getState(), TxInfo.UNKNOWN);
+    }
+}

Added: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/XAUtilsUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/XAUtilsUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/XAUtilsUnitTest.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -0,0 +1,54 @@
+/*
+ * 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.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Ltd,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.  
+ *
+ * $Id: xidcheck.java 2342 2006-03-30 13:06:17Z  $
+ */
+
+package com.hp.mwtests.ts.jta.xa;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.jta.utils.XAUtils;
+import com.arjuna.ats.jta.xa.XidImple;
+import com.hp.mwtests.ts.jta.common.DummyXA;
+
+import static org.junit.Assert.*;
+
+public class XAUtilsUnitTest
+{
+    @Test
+    public void test()
+    {
+        DummyXA xa = new DummyXA(false);
+        
+        assertFalse(XAUtils.mustEndSuspendedRMs(xa));
+        assertTrue(XAUtils.canOptimizeDelist(xa));      
+        assertTrue(XAUtils.getXANodeName(new XidImple(new Uid())) != null);
+    }
+}

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java	2010-02-25 22:24:47 UTC (rev 31844)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/xa/xidcheck.java	2010-02-25 22:34:58 UTC (rev 31845)
@@ -31,7 +31,11 @@
 
 package com.hp.mwtests.ts.jta.xa;
 
+import com.arjuna.ats.arjuna.AtomicAction;
 import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.jta.xa.XID;
 import com.arjuna.ats.jta.xa.XidImple;
 
 import org.junit.Test;
@@ -52,4 +56,69 @@
 
         assertEquals(test, convertedUid);
     }
+    
+    @Test
+    public void testBasic ()
+    {
+        XidImple xid1 = new XidImple();
+        AtomicAction A = new AtomicAction();
+        
+        assertEquals(xid1.getFormatId(), -1);
+        
+        xid1 = new XidImple(A);
+        
+        XidImple xid2 = new XidImple(new Uid());
+        
+        assertFalse(xid1.isSameTransaction(xid2));
+        
+        XidImple xid3 = new XidImple(xid1);
+        
+        assertTrue(xid3.isSameTransaction(xid1));
+        
+        assertTrue(xid1.getFormatId() != -1);
+        
+        assertTrue(xid1.getBranchQualifier().length > 0);
+        assertTrue(xid1.getGlobalTransactionId().length > 0);
+        
+        assertEquals(xid1.getTransactionUid(), A.get_uid());
+        
+        assertTrue(xid1.getNodeName() != null);
+        
+        assertTrue(xid1.getXID() != null);
+        
+        assertTrue(xid1.equals(xid3));
+        
+        XID x = new XID();
+        
+        assertFalse(xid1.equals(x));
+        
+        xid1 = new XidImple(x);
+    }
+    
+    @Test
+    public void testPackUnpack () throws Exception
+    {
+        XidImple xid1 = new XidImple(new Uid());
+        OutputObjectState os = new OutputObjectState();
+        
+        assertTrue(xid1.packInto(os));
+        
+        InputObjectState is = new InputObjectState(os);
+        
+        XidImple xid2 = new XidImple();
+        
+        assertTrue(xid2.unpackFrom(is));
+        
+        assertTrue(xid1.equals(xid2));
+        
+        os = new OutputObjectState();
+        
+        XidImple.pack(os, xid1);
+        
+        is = new InputObjectState(os);
+        
+        xid2 = (XidImple) XidImple.unpack(is);
+        
+        assertTrue(xid1.equals(xid2));
+    }
 }



More information about the jboss-svn-commits mailing list