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

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Mar 24 11:50:09 EDT 2010


Author: mark.little at jboss.com
Date: 2010-03-24 11:50:05 -0400 (Wed, 24 Mar 2010)
New Revision: 32191

Modified:
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
   labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca/SubordinateAtomicAction.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/FailureXAResource.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java
   labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java
Log:
https://jira.jboss.org/jira/browse/JBTM-712

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/resources/arjunacore/XAResourceRecord.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -718,6 +718,8 @@
 	                "XAResourceRecord.topLevelOnePhaseCommit for " + _tranID);
 	    }
 
+	    boolean commit = true;
+	    
 	    if (_tranID == null)
 	    {
 	        if (jtaLogger.loggerI18N.isWarnEnabled())
@@ -738,7 +740,6 @@
 	            if (_heuristic != TwoPhaseOutcome.FINISH_OK)
 	                return _heuristic;
 
-	            boolean commit = true;
 	            XAException endHeuristic = null;
 
 	            try
@@ -901,7 +902,10 @@
 	            return TwoPhaseOutcome.ONE_PHASE_ERROR;
 	    }
 
-	    return TwoPhaseOutcome.FINISH_OK;
+	    if (commit)
+	        return TwoPhaseOutcome.FINISH_OK;
+	    else
+	        return TwoPhaseOutcome.FINISH_ERROR;
 	}
 
 	public boolean forgetHeuristic()

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/TransactionImple.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -404,7 +404,7 @@
 		}
 
 		int status = javax.transaction.Status.STATUS_NO_TRANSACTION;
-
+		
 		if (_theTransaction != null)
 		{
 			return StatusConverter.convert(_theTransaction.status());

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-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/classes/com/arjuna/ats/internal/jta/transaction/arjunacore/subordinate/jca/SubordinateAtomicAction.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -55,6 +55,7 @@
 		super();  // does start for us
 
 		_activated = true;
+		_theXid = new XidImple(Uid.nullUid());
 	}
 
 	public SubordinateAtomicAction (Uid actId)
@@ -62,6 +63,7 @@
 		super(actId);
 		
 		_activated = activate(); // if this fails, we'll retry later.
+		_theXid = new XidImple(actId);
 	}
 	
 	public SubordinateAtomicAction (int timeout, Xid xid)

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/FailureXAResource.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/FailureXAResource.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/common/FailureXAResource.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -26,26 +26,64 @@
 
 public class FailureXAResource implements XAResource
 {
-    public enum FailLocation { none, prepare, commit, rollback };
+    public enum FailLocation { none, prepare, commit, rollback, end, prepare_and_rollback };
+    public enum FailType { normal, timeout, heurcom, nota, inval, proto, rmfail, rollback };
     
     public FailureXAResource ()
     {
-        this(FailLocation.none);
+        this(FailLocation.none, FailType.normal);
     }
     
     public FailureXAResource (FailLocation loc)
     {
+        this(loc, FailType.normal);
+    }
+    
+    public FailureXAResource (FailLocation loc, FailType type)
+    {
         _locale = loc;
+        _type = type;
     }
     
     public void commit(Xid id, boolean onePhase) throws XAException
     {
 	if (_locale == FailLocation.commit)
-	    throw new XAException(XAException.XA_HEURMIX);
+	{
+	    if (_type == FailType.normal)
+	        throw new XAException(XAException.XA_HEURMIX);
+	    
+	    if (_type == FailType.heurcom)
+	        throw new XAException(XAException.XA_HEURCOM);
+	    
+	    if (_type == FailType.rollback)
+                throw new XAException(XAException.XA_HEURRB);
+	    
+	    if (_type == FailType.nota)
+	        throw new XAException(XAException.XAER_NOTA);
+	    
+	    if (_type == FailType.inval)
+                throw new XAException(XAException.XAER_INVAL);
+	    
+	    if (_type == FailType.proto)
+                throw new XAException(XAException.XAER_PROTO);
+	    
+	    if (_type == FailType.rmfail)
+                throw new XAException(XAException.XAER_RMFAIL);
+	    
+	    throw new XAException(XAException.XA_RBTIMEOUT);
+	}
     }
 
     public void end(Xid xid, int flags) throws XAException
     {
+        if (_locale == FailLocation.end)
+        {
+            if (_type == FailType.normal)
+                throw new XAException(XAException.XA_HEURRB);
+            
+            if (_type == FailType.timeout)
+                throw new XAException(XAException.XA_RBTIMEOUT);
+        }
     }
 
     public void forget(Xid xid) throws XAException
@@ -64,7 +102,7 @@
 
     public int prepare(Xid xid) throws XAException
     {
-        if (_locale == FailLocation.prepare)
+        if ((_locale == FailLocation.prepare) || (_locale == FailLocation.prepare_and_rollback))
             throw new XAException(XAException.XAER_INVAL);
         
         return XA_OK;
@@ -77,8 +115,31 @@
 
     public void rollback(Xid xid) throws XAException
     {
-        if (_locale == FailLocation.rollback)
+        if ((_locale == FailLocation.rollback) || (_locale == FailLocation.prepare_and_rollback))
+        {
+            if (_type == FailType.normal)
+                throw new XAException(XAException.XA_HEURMIX);
+            
+            if (_type == FailType.heurcom)
+                throw new XAException(XAException.XA_HEURCOM);
+            
+            if (_type == FailType.rollback)
+                throw new XAException(XAException.XA_HEURRB);
+            
+            if (_type == FailType.nota)
+                throw new XAException(XAException.XAER_NOTA);
+            
+            if (_type == FailType.inval)
+                throw new XAException(XAException.XAER_INVAL);
+            
+            if (_type == FailType.proto)
+                throw new XAException(XAException.XAER_PROTO);
+            
+            if (_type == FailType.rmfail)
+                throw new XAException(XAException.XAER_RMFAIL);
+
             throw new XAException(XAException.XA_HEURHAZ);
+        }
     }
 
     public boolean setTransactionTimeout(int seconds) throws XAException
@@ -91,4 +152,5 @@
     }
 
     private FailLocation _locale;
+    private FailType _type;
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/jca/XATerminatorUnitTest.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -37,10 +37,15 @@
 import org.junit.Test;
 
 import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
+import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinateTransaction;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.SubordinationManager;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.jca.XATerminatorImple;
 import com.arjuna.ats.jta.exceptions.UnexpectedConditionException;
 import com.arjuna.ats.jta.xa.XidImple;
+import com.hp.mwtests.ts.jta.common.FailureXAResource;
+import com.hp.mwtests.ts.jta.common.FailureXAResource.FailLocation;
+import com.hp.mwtests.ts.jta.common.FailureXAResource.FailType;
 
 import static org.junit.Assert.*;
 
@@ -67,10 +72,193 @@
         SubordinationManager.getTransactionImporter().importTransaction(xid);
         
         term.recover(XAResource.TMSTARTRSCAN);
+        
+        try
+        {
+            term.recover(XAResource.TMSTARTRSCAN);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
         term.recover(XAResource.TMENDRSCAN);
+        
+        term.forget(xid);
     }
     
     @Test
+    public void testFail () throws Exception
+    {
+        XATerminatorImple term = new XATerminatorImple();
+        XidImple xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        
+        SubordinateTransaction tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.rollback));
+        
+        try
+        {
+            term.commit(xid, false);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.heurcom));
+        
+        try
+        {
+            term.commit(xid, false);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.heurcom));
+        
+        term.prepare(xid);
+        
+        try
+        {
+            term.commit(xid, false);
+        }
+        catch (final XAException ex)
+        {
+            fail();
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.commit, FailType.normal));
+        
+        try
+        {
+            term.commit(xid, false);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.rollback, FailType.rollback));
+        
+        try
+        {
+            term.rollback(xid);
+        }
+        catch (final XAException ex)
+        {
+            fail();
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.rollback, FailType.heurcom));
+        
+        term.prepare(xid);
+        
+        try
+        {
+            term.rollback(xid);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.rollback, FailType.normal));
+        
+        term.prepare(xid);
+        
+        try
+        {
+            term.rollback(xid);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.prepare_and_rollback, FailType.normal));
+
+        try
+        {
+            term.prepare(xid);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.prepare_and_rollback, FailType.heurcom));
+
+        try
+        {
+            term.prepare(xid);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+        
+        xid = new XidImple(new Uid());
+        SubordinationManager.getTransactionImporter().importTransaction(xid);
+        tx = SubordinationManager.getTransactionImporter().getImportedTransaction(xid);
+        
+        tx.enlistResource(new FailureXAResource(FailLocation.prepare_and_rollback, FailType.rollback));
+
+        try
+        {
+            term.prepare(xid);
+            
+            fail();
+        }
+        catch (final XAException ex)
+        {
+        }
+    }
+    
+    @Test
     public void testUnknownTransaction () throws Exception
     {
         XATerminatorImple term = new XATerminatorImple();
@@ -126,4 +314,57 @@
         {
         }
     }
+    
+    @Test
+    public void testInvalid () throws Exception
+    {
+        XATerminatorImple term = new XATerminatorImple();
+        XidImple xid = new XidImple(new Uid());
+        
+        try
+        {
+            SubordinationManager.getTransactionImporter().importTransaction(null);
+            
+            fail();
+        }
+        catch (final IllegalArgumentException ex)
+        {
+        }
+        
+        try
+        {
+            SubordinationManager.getTransactionImporter().recoverTransaction(null);
+            
+            fail();
+        }
+        catch (final IllegalArgumentException ex)
+        {
+        }
+        
+        try
+        {
+            SubordinationManager.getTransactionImporter().getImportedTransaction(null);
+            
+            fail();
+        }
+        catch (final IllegalArgumentException ex)
+        {
+        }
+        
+        try
+        {
+            SubordinationManager.getTransactionImporter().removeImportedTransaction(null);
+            
+            fail();
+        }
+        catch (final IllegalArgumentException ex)
+        {
+        }
+        
+        Uid uid = new Uid();
+        Object obj = SubordinationManager.getTransactionImporter().recoverTransaction(uid);
+        
+        assertTrue(obj != null);
+        assertEquals(obj, SubordinationManager.getTransactionImporter().recoverTransaction(uid));
+    }
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/recovery/XARecoveryModuleUnitTest.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -35,8 +35,11 @@
 
 import com.arjuna.ats.jta.recovery.XAResourceOrphanFilter;
 import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
+import com.arjuna.ats.jta.xa.XidImple;
+
 import org.junit.Test;
 
+import com.arjuna.ats.arjuna.common.Uid;
 import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
 import com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule;
 import com.arjuna.ats.internal.jta.transaction.arjunacore.subordinate.TransactionImple;
@@ -80,6 +83,8 @@
             xarm.periodicWorkFirstPass();
             xarm.periodicWorkSecondPass();
         }
+        
+        assertTrue(xarm.getNewXAResource(new XidImple(new Uid())) == null);
     }
 
     @Test

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/TransactionImpleUnitTest.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -46,12 +46,18 @@
 import com.arjuna.ats.jta.utils.JTAHelper;
 import com.hp.mwtests.ts.jta.common.DummyXA;
 import com.hp.mwtests.ts.jta.common.FailureXAResource;
+import com.hp.mwtests.ts.jta.common.Synchronization;
 import com.hp.mwtests.ts.jta.common.FailureXAResource.FailLocation;
 
 import static org.junit.Assert.*;
 
 class TxImpleOverride extends TransactionImple
 {
+    public TxImpleOverride ()
+    {
+        super();
+    }
+    
     public static void put (TransactionImple tx)
     {
         TransactionImple.putTransaction(tx);
@@ -238,4 +244,59 @@
         {
         }
     }
+    
+    @Test
+    public void testInvalid () throws Exception
+    {
+        ThreadActionData.purgeActions();
+        
+        TxImpleOverride tx = new TxImpleOverride();
+        
+        assertEquals(tx.hashCode(), -1);
+        assertEquals(tx.getStatus(), Status.STATUS_NO_TRANSACTION);
+        
+        try
+        {
+            tx.commit();
+            
+            fail();
+        }
+        catch (final IllegalStateException ex)
+        {
+        }
+        
+        try
+        {
+            tx.rollback();
+            
+            fail();
+        }
+        catch (final IllegalStateException ex)
+        {
+        }
+        
+        try
+        {
+            tx.setRollbackOnly();
+            
+            fail();
+        }
+        catch (final IllegalStateException ex)
+        {
+        }
+        
+        try
+        {
+            tx.registerSynchronization(new Synchronization());
+            
+            fail();
+        }
+        catch (final IllegalStateException ex)
+        {
+        }
+        
+        tx.toString();
+        
+        assertFalse(tx.isAlive());
+    }
 }

Modified: labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java	2010-03-24 15:08:56 UTC (rev 32190)
+++ labs/jbosstm/trunk/ArjunaJTA/jta/tests/classes/com/hp/mwtests/ts/jta/twophase/XAResourceRecordUnitTest.java	2010-03-24 15:50:05 UTC (rev 32191)
@@ -31,6 +31,8 @@
 
 package com.hp.mwtests.ts.jta.twophase;
 
+import javax.transaction.xa.XAException;
+
 import org.junit.Test;
 
 import com.arjuna.ats.arjuna.ObjectType;
@@ -45,6 +47,8 @@
 import com.hp.mwtests.ts.jta.common.DummyXA;
 import com.hp.mwtests.ts.jta.common.FailureXAResource;
 import com.hp.mwtests.ts.jta.common.TestResource;
+import com.hp.mwtests.ts.jta.common.FailureXAResource.FailLocation;
+import com.hp.mwtests.ts.jta.common.FailureXAResource.FailType;
 
 import static org.junit.Assert.*;
 
@@ -93,6 +97,16 @@
         InputObjectState is = new InputObjectState(os);
         
         assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
+        
+        xares = new XAResourceRecord(new TransactionImple(0), new DummyXA(false), new XidImple(new Uid()), null);
+        
+        os = new OutputObjectState();
+        
+        assertTrue(xares.save_state(os, ObjectType.ANDPERSISTENT));
+        
+        is = new InputObjectState(os);
+        
+        assertTrue(xares.restore_state(is, ObjectType.ANDPERSISTENT));
     }
     
     @Test
@@ -131,7 +145,7 @@
         XAResourceRecord xares = new XAResourceRecord(tx, fxa, tx.getTxId(), null);
         
         assertEquals(xares.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
-        assertEquals(xares.topLevelAbort(), TwoPhaseOutcome.HEURISTIC_HAZARD);
+        assertEquals(xares.topLevelAbort(), TwoPhaseOutcome.HEURISTIC_MIXED);
         assertTrue(xares.forgetHeuristic());
     }
     
@@ -154,6 +168,38 @@
         XAResourceRecord xares = new XAResourceRecord(tx, res, tx.getTxId(), null);
         
         assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.end, FailType.normal), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.end, FailType.timeout), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.FINISH_ERROR);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.heurcom), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.timeout), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.nota), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.inval), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.HEURISTIC_HAZARD);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.proto), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.ONE_PHASE_ERROR);
+        
+        xares = new XAResourceRecord(tx, new FailureXAResource(FailLocation.commit, FailType.rmfail), tx.getTxId(), null);
+        
+        assertEquals(xares.topLevelOnePhaseCommit(), TwoPhaseOutcome.FINISH_ERROR);
     }
     
     @Test



More information about the jboss-svn-commits mailing list