[jboss-svn-commits] JBL Code SVN: r31656 - in labs/jbosstm/trunk/ArjunaCore/arjuna: tests/classes/com/hp/mwtests/ts/arjuna/atomicaction and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Feb 13 07:48:04 EST 2010


Author: mark.little at jboss.com
Date: 2010-02-13 07:48:04 -0500 (Sat, 13 Feb 2010)
New Revision: 31656

Added:
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/RecordListUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/SynchronizationUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TxControlUnitTest.java
Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordList.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/AtomicActionUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SyncRecord.java
Log:
https://jira.jboss.org/jira/browse/JBTM-698

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java	2010-02-13 01:00:43 UTC (rev 31655)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/BasicAction.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -800,14 +800,7 @@
 
 			if (save_state(oState, ObjectType.ANDPERSISTENT))
 			{
-				if (aaStore.write_committed(getSavingUid(), type(), oState))
-				{
-					deactivated = true;
-				}
-				else
-				{
-					deactivated = false;
-				}
+				deactivated = aaStore.write_committed(getSavingUid(), type(), oState);
 
 				oState = null;
 			}
@@ -1621,7 +1614,7 @@
 
 	public final Object[] childTransactions ()
 	{
-		int size = _childActions.size();
+		int size = ((_childActions == null) ? 0 : _childActions.size());
 
 		if (size > 0)
 		{

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordList.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordList.java	2010-02-13 01:00:43 UTC (rev 31655)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/RecordList.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -39,467 +39,500 @@
 import com.arjuna.common.util.logging.*;
 
 /**
- * This class manages instances of the classes derived from AbstractRecord
- * in the form of an ordered doubly-linked list.
- * The ordering and insertion criteria
- * are not particularly standard - see the comment on 'insert' for the
- * actual algorithm used in insertion. The algorithm assumes that one or
- * more different record type instances (LockRecords, RecoveryRecords, etc.)
- * will be inserted into the list at different times. Each such record
- * contains specific information managing certain properties of any
- * particular object. As execution progresses newly created records may
- * need to be merged with, replace entirely, or be added to existing
- * records that relate to an object.
- *
+ * This class manages instances of the classes derived from AbstractRecord in
+ * the form of an ordered doubly-linked list. The ordering and insertion
+ * criteria are not particularly standard - see the comment on 'insert' for the
+ * actual algorithm used in insertion. The algorithm assumes that one or more
+ * different record type instances (LockRecords, RecoveryRecords, etc.) will be
+ * inserted into the list at different times. Each such record contains specific
+ * information managing certain properties of any particular object. As
+ * execution progresses newly created records may need to be merged with,
+ * replace entirely, or be added to existing records that relate to an object.
  * Note, the methods of this class do not need to be synchronized because
  * instances of this class are only used from within synchronized classes.
  * Applications should not use this class.
- *
+ * 
  * @author Mark Little (mark at arjuna.com)
- * @version $Id: RecordList.java 2342 2006-03-30 13:06:17Z  $
+ * @version $Id: RecordList.java 2342 2006-03-30 13:06:17Z $
  * @since JTS 1.0.
- *
- * @message com.arjuna.ats.arjuna.coordinator.RecordList_1 [com.arjuna.ats.arjuna.coordinator.RecordList_1] - RecordList::insert({0}) : merging {1} and {2} for {3}
- * @message com.arjuna.ats.arjuna.coordinator.RecordList_2 [com.arjuna.ats.arjuna.coordinator.RecordList_2] - RecordList::insert({0}) : replacing {1} and {2} for {3}
- * @message com.arjuna.ats.arjuna.coordinator.RecordList_3 [com.arjuna.ats.arjuna.coordinator.RecordList_3] - RecordList::insert({0}) : adding extra record of type {1} before {2} for {3}
- * @message com.arjuna.ats.arjuna.coordinator.RecordList_4 [com.arjuna.ats.arjuna.coordinator.RecordList_4] - RecordList::insert({0}) : inserting {1} for {2} before {3}
- * @message com.arjuna.ats.arjuna.coordinator.RecordList_5 [com.arjuna.ats.arjuna.coordinator.RecordList_5] - RecordList::insert({0}) : appending {1} for {2}
- * @message com.arjuna.ats.arjuna.coordinator.RecordList_6 [com.arjuna.ats.arjuna.coordinator.RecordList_6] - RecordList::insert({0}) : inserting {1} for {2} before {3} for {4}
+ * @message com.arjuna.ats.arjuna.coordinator.RecordList_1
+ *          [com.arjuna.ats.arjuna.coordinator.RecordList_1] -
+ *          RecordList::insert({0}) : merging {1} and {2} for {3}
+ * @message com.arjuna.ats.arjuna.coordinator.RecordList_2
+ *          [com.arjuna.ats.arjuna.coordinator.RecordList_2] -
+ *          RecordList::insert({0}) : replacing {1} and {2} for {3}
+ * @message com.arjuna.ats.arjuna.coordinator.RecordList_3
+ *          [com.arjuna.ats.arjuna.coordinator.RecordList_3] -
+ *          RecordList::insert({0}) : adding extra record of type {1} before {2}
+ *          for {3}
+ * @message com.arjuna.ats.arjuna.coordinator.RecordList_4
+ *          [com.arjuna.ats.arjuna.coordinator.RecordList_4] -
+ *          RecordList::insert({0}) : inserting {1} for {2} before {3}
+ * @message com.arjuna.ats.arjuna.coordinator.RecordList_5
+ *          [com.arjuna.ats.arjuna.coordinator.RecordList_5] -
+ *          RecordList::insert({0}) : appending {1} for {2}
+ * @message com.arjuna.ats.arjuna.coordinator.RecordList_6
+ *          [com.arjuna.ats.arjuna.coordinator.RecordList_6] -
+ *          RecordList::insert({0}) : inserting {1} for {2} before {3} for {4}
  */
 
 public class RecordList
 {
 
-    public RecordList ()
+    public RecordList()
     {
-	listHead = null;
-	listTail = null;
-	noEntries = 0;
+        listHead = null;
+        listTail = null;
+        noEntries = 0;
     }
 
-    public RecordList (RecordList copy)
+    public RecordList(RecordList copy)
     {
-	listHead = copy.listHead;
-	listTail = copy.listTail;
-	noEntries = copy.noEntries;
+        listHead = copy.listHead;
+        listTail = copy.listTail;
+        noEntries = copy.noEntries;
     }
 
     /**
      * Remove and return the element at the front of the list.
-     *
+     * 
      * @return the front element.
      */
 
-public final AbstractRecord getFront ()
+    public final AbstractRecord getFront ()
     {
-	AbstractRecord temp = listHead;
+        AbstractRecord temp = listHead;
 
-	if (noEntries == 1)
-	{
-	    listHead = listTail = null;
-	    noEntries = 0;
-	}
-	else if (noEntries > 1)
-	{
-	    listHead = listHead.getNext();
-	    listHead.setPrevious(null);
-	    temp.setNext(null);
-	    temp.setPrevious(null);
-	    noEntries--;
-	}
+        if (noEntries == 1)
+        {
+            listHead = listTail = null;
+            noEntries = 0;
+        }
+        else if (noEntries > 1)
+        {
+            listHead = listHead.getNext();
+            listHead.setPrevious(null);
+            temp.setNext(null);
+            temp.setPrevious(null);
+            noEntries--;
+        }
 
-	return temp;
+        return temp;
     }
 
     /**
      * Remove and return the element at the tail of the list.
-     *
+     * 
      * @return the last element.
      */
 
-public final AbstractRecord getRear ()
+    public final AbstractRecord getRear ()
     {
-	AbstractRecord temp = listTail;
+        AbstractRecord temp = listTail;
 
-	if (noEntries == 1)
-	{
-	    listHead = listTail = null;
-	    noEntries = 0;
-	}
-	else if (noEntries > 1)
-	{
-	    listTail = listTail.getPrevious();
-	    listTail.setNext(null);
-	    temp.setPrevious(null);
-	    noEntries--;
-	}
+        if (noEntries == 1)
+        {
+            listHead = listTail = null;
+            noEntries = 0;
+        }
+        else if (noEntries > 1)
+        {
+            listTail = listTail.getPrevious();
+            listTail.setNext(null);
+            temp.setPrevious(null);
+            noEntries--;
+        }
 
-	return temp;
+        return temp;
     }
 
-public AbstractRecord getNext (AbstractRecord current)
+    public AbstractRecord getNext (AbstractRecord current)
     {
-	AbstractRecord rec = current.getNext();
+        AbstractRecord rec = current.getNext();
 
-	if (remove(rec))
-	    return rec;
-	else
-	    return null;
+        if (remove(rec))
+            return rec;
+        else
+            return null;
     }
 
     /**
      * Insert the entry at the head of the list.
      */
 
-public final boolean insert (AbstractRecord newRecord)
+    public final boolean insert (AbstractRecord newRecord)
     {
-	/* Do the insert starting at the head of the list */
-	return insert(newRecord, listHead);
+        /* Do the insert starting at the head of the list */
+        return insert(newRecord, listHead);
     }
 
-public final void print (PrintWriter strm)
+    public final void print (PrintWriter strm)
     {
-	AbstractRecord arp = listHead;
+        AbstractRecord arp = listHead;
 
-	for (int i = 0; i < noEntries; i++)
-	{
-	    strm.print(arp);
-	    arp = arp.getNext();
-	}
+        for (int i = 0; i < noEntries; i++)
+        {
+            strm.print(arp);
+            arp = arp.getNext();
+        }
     }
 
     /**
      * Explicit push onto front of list.
      */
 
-public final void putFront (AbstractRecord newRecord)
+    public final void putFront (AbstractRecord newRecord)
     {
-	if (listHead == null)
-	{
-	    listHead = listTail = newRecord;
-	    newRecord.setNext(null);
-	    newRecord.setPrevious(null);
-	}
-	else
-	{
-	    listHead.setPrevious(newRecord);
-	    newRecord.setPrevious(null);
-	    newRecord.setNext(listHead);
-	    listHead = newRecord;
-	}
+        if (listHead == null)
+        {
+            listHead = listTail = newRecord;
+            newRecord.setNext(null);
+            newRecord.setPrevious(null);
+        }
+        else
+        {
+            listHead.setPrevious(newRecord);
+            newRecord.setPrevious(null);
+            newRecord.setNext(listHead);
+            listHead = newRecord;
+        }
 
-	noEntries++;
+        noEntries++;
     }
 
     /**
      * Explicit push onto rear of list.
      */
 
-public final void putRear (AbstractRecord newRecord)
+    public final void putRear (AbstractRecord newRecord)
     {
-	if (listTail == null)
-	{
-	    listHead = listTail = newRecord;
-	    newRecord.setNext(null);
-	    newRecord.setPrevious(null);
-	}
-	else
-	{
-	    listTail.setNext(newRecord);
-	    newRecord.setPrevious(listTail);
-	    newRecord.setNext(null);
-	    listTail = newRecord;
-	}
+        if (listTail == null)
+        {
+            listHead = listTail = newRecord;
+            newRecord.setNext(null);
+            newRecord.setPrevious(null);
+        }
+        else
+        {
+            listTail.setNext(newRecord);
+            newRecord.setPrevious(listTail);
+            newRecord.setNext(null);
+            listTail = newRecord;
+        }
 
-	noEntries++;
+        noEntries++;
     }
 
-public final AbstractRecord peekFront ()
+    public final AbstractRecord peekFront ()
     {
-	return listHead;
+        return listHead;
     }
 
-public final AbstractRecord peekRear ()
+    public final AbstractRecord peekRear ()
     {
-	return listTail;
+        return listTail;
     }
 
-public final AbstractRecord peekNext (AbstractRecord curr)
+    public final AbstractRecord peekNext (AbstractRecord curr)
     {
-	return curr.getNext();
+        return curr.getNext();
     }
 
     /*
      * Assume it's in this list!
      */
 
-public final boolean remove (AbstractRecord oldRecord)
+    public final boolean remove (AbstractRecord oldRecord)
     {
-	if (oldRecord == null)
-	    return false;
+        if (oldRecord == null)
+            return false;
 
-	if (noEntries == 1)
-	{
-	    listHead = listTail = null;
-	    noEntries = 0;
-	}
-	else if (noEntries > 1)
-	{
-	    if (listHead == oldRecord)
-	    {
-		listHead = listHead.getNext();
+        if (noEntries == 1)
+        {
+            listHead = listTail = null;
+            noEntries = 0;
+        }
+        else if (noEntries > 1)
+        {
+            if (listHead == oldRecord)
+            {
+                listHead = listHead.getNext();
 
-		if (listHead != null)
-		    listHead.setPrevious(null);
+                if (listHead != null)
+                    listHead.setPrevious(null);
 
-		oldRecord.setNext(null);
-		oldRecord.setPrevious(null);
-	    }
-	    else
-	    {
-		if (listTail == oldRecord)
-		{
-		    listTail = listTail.getPrevious();
+                oldRecord.setNext(null);
+                oldRecord.setPrevious(null);
+            }
+            else
+            {
+                if (listTail == oldRecord)
+                {
+                    listTail = listTail.getPrevious();
 
-		    if (listTail != null)
-			listTail.setNext(null);
-		    
-		    oldRecord.setNext(null);
-		    oldRecord.setPrevious(null);
-		}
-		else
-		{
-		    if (oldRecord.getPrevious() != null)
-			oldRecord.getPrevious().setNext(oldRecord.getNext());
+                    if (listTail != null)
+                        listTail.setNext(null);
 
-		    if (oldRecord.getNext() != null)
-			oldRecord.getNext().setPrevious(oldRecord.getPrevious());
-		}
-	    }
+                    oldRecord.setNext(null);
+                    oldRecord.setPrevious(null);
+                }
+                else
+                {
+                    if (oldRecord.getPrevious() != null)
+                        oldRecord.getPrevious().setNext(oldRecord.getNext());
 
-	    noEntries--;
-	}
+                    if (oldRecord.getNext() != null)
+                        oldRecord.getNext()
+                                .setPrevious(oldRecord.getPrevious());
+                }
+            }
 
-	return true;
+            noEntries--;
+        }
+
+        return true;
     }
 
     /**
      * @return the number of items in the current list.
      */
 
-public final int size ()
+    public final int size ()
     {
-	return noEntries;
+        return noEntries;
     }
 
-public String toString ()
+    public String toString ()
     {
-	AbstractRecord rec = listHead;
-	String s = "RecordList:";
+        AbstractRecord rec = listHead;
+        String s = "RecordList:";
 
-	if (rec == null)
-	    s += " empty";
-	else
-	{
-	    while (rec != null)
-	    {
-		s += " "+rec.order();
-		rec = rec.getNext();
-	    }
-	}
+        if (rec == null)
+            s += " empty";
+        else
+        {
+            while (rec != null)
+            {
+                s += " " + rec.order();
+                rec = rec.getNext();
+            }
+        }
 
-	return s;
+        return s;
     }
 
     /**
-     * This is a variation on ordered insertion.
-     * Insertion obeys the following algorithm.
-     *
-     * Starting at the record indicated by 'startat' examine each
-     * entry in the list in turn and perform the following code
-     * 1) If the new record should be merged with the old, call
-     *    nr.merge passing the old record as an argument and then
-     *    INSERT the new record IN PLACE OF the old and exit
-     * 2) If the new record should replace the old then
-     *    INSERT the new record IN PLACE OF the old and exit
-     * 3) If the new record should be added in addition to the old then
-     *    INSERT the new record BEFORE the old and exit
-     * 4) If the two records are the same (determined by the
-     *    == operator) simply exit
-     * 5) Otherwise determine if the new record should be added here
-     *    regardless due to the ordering constraints on the list and if so
-     *    add and exit, otherwise step on to the next element and repeat
-     *    all the steps.
-     *
+     * This is a variation on ordered insertion. Insertion obeys the following
+     * algorithm. Starting at the record indicated by 'startat' examine each
+     * entry in the list in turn and perform the following code 1) If the new
+     * record should be merged with the old, call nr.merge passing the old
+     * record as an argument and then INSERT the new record IN PLACE OF the old
+     * and exit 2) If the new record should replace the old then INSERT the new
+     * record IN PLACE OF the old and exit 3) If the new record should be added
+     * in addition to the old then INSERT the new record BEFORE the old and exit
+     * 4) If the two records are the same (determined by the == operator) simply
+     * exit 5) Otherwise determine if the new record should be added here
+     * regardless due to the ordering constraints on the list and if so add and
+     * exit, otherwise step on to the next element and repeat all the steps.
      * Steps 1-4 effectively ensure that information maintained in any two
      * records for the same object is current either by merging in new
      * information, replacing the old with new, adding in new, or leaving the
-     * old alone.
-     * Step 5 ensures that if no existing record exists insertion takes
-     * place at the correct point
-     *
+     * old alone. Step 5 ensures that if no existing record exists insertion
+     * takes place at the correct point
+     * 
      * @return <code>true</code> if insertion/replacement took place,
-     * <code>false</code> otherwise.
+     *         <code>false</code> otherwise.
      */
 
-private final boolean insert (AbstractRecord newRecord, AbstractRecord startAt)
+    private final boolean insert (AbstractRecord newRecord,
+            AbstractRecord startAt)
     {
-	AbstractRecord current = startAt;
+        AbstractRecord current = startAt;
 
-	/*
-	 * Step through the existing list one record at a time
-	 */
+        /*
+         * Step through the existing list one record at a time
+         */
 
-	while (current != null)
-	{
-	    if (newRecord.shouldMerge(current))
-	    {
-		if (tsLogger.arjLoggerI18N.isDebugEnabled())
-		{
-		    tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PRIVATE,
-						 FacilityCode.FAC_ABSTRACT_REC, "com.arjuna.ats.arjuna.coordinator.RecordList_1",
-						 new Object[]{this, newRecord.type(),
-							      current.type(), newRecord.order()});
-		}
+        while (current != null)
+        {
+            if (newRecord.shouldMerge(current))
+            {
+                if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                {
+                    tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS,
+                            VisibilityLevel.VIS_PRIVATE,
+                            FacilityCode.FAC_ABSTRACT_REC,
+                            "com.arjuna.ats.arjuna.coordinator.RecordList_1",
+                            new Object[]
+                            { this, newRecord.type(), current.type(),
+                                    newRecord.order() });
+                }
 
-		newRecord.merge(current);
-		replace(newRecord, current);
+                newRecord.merge(current);
+                replace(newRecord, current);
 
-		return true;
-	    }
-	    else
-	    {
-		if (newRecord.shouldReplace(current))
-		{
-		    if (tsLogger.arjLoggerI18N.isDebugEnabled())
-		    {
-			tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PRIVATE,
-						     FacilityCode.FAC_ABSTRACT_REC, "com.arjuna.ats.arjuna.coordinator.RecordList_2",
-						     new Object[]{this, current.type(),
-								  newRecord.type(), newRecord.order()});
-		    }
+                return true;
+            }
+            else
+            {
+                if (newRecord.shouldReplace(current))
+                {
+                    if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                    {
+                        tsLogger.arjLoggerI18N
+                                .debug(
+                                        DebugLevel.FUNCTIONS,
+                                        VisibilityLevel.VIS_PRIVATE,
+                                        FacilityCode.FAC_ABSTRACT_REC,
+                                        "com.arjuna.ats.arjuna.coordinator.RecordList_2",
+                                        new Object[]
+                                        { this, current.type(),
+                                                newRecord.type(),
+                                                newRecord.order() });
+                    }
 
-		    replace(newRecord, current);
+                    replace(newRecord, current);
 
-		    return true;
-		}
-		else
-		{
-		    if (newRecord.shouldAdd(current))
-		    {
-			if (tsLogger.arjLoggerI18N.isDebugEnabled())
-			{
-			    tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PRIVATE,
-							 FacilityCode.FAC_ABSTRACT_REC, "com.arjuna.ats.arjuna.coordinator.RecordList_3",
-							 new Object[]{this, newRecord.type(),
-								      current.type(), newRecord.order()});
-			}
+                    return true;
+                }
+                else
+                {
+                    if (newRecord.shouldAdd(current))
+                    {
+                        if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                        {
+                            tsLogger.arjLoggerI18N
+                                    .debug(
+                                            DebugLevel.FUNCTIONS,
+                                            VisibilityLevel.VIS_PRIVATE,
+                                            FacilityCode.FAC_ABSTRACT_REC,
+                                            "com.arjuna.ats.arjuna.coordinator.RecordList_3",
+                                            new Object[]
+                                            { this, newRecord.type(),
+                                                    current.type(),
+                                                    newRecord.order() });
+                        }
 
-			insertBefore(newRecord, current);
+                        insertBefore(newRecord, current);
 
-			return true;
-		    }
-		    else
-		    {
-			if (newRecord.shouldAlter(current))
-			    newRecord.alter(current);
+                        return true;
+                    }
+                    else
+                    {
+                        if (newRecord.shouldAlter(current))
+                            newRecord.alter(current);
 
-			if (newRecord.equals(current))
-			{
-			    return false;
-			}
-			else if (newRecord.lessThan(current))
-			{
-			    if (tsLogger.arjLoggerI18N.isDebugEnabled())
-			    {
-				tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PRIVATE,
-							     FacilityCode.FAC_ABSTRACT_REC, "com.arjuna.ats.arjuna.coordinator.RecordList_4",
-							     new Object[]{this, newRecord.type(),
-									  newRecord.order(), current.type()});
-			    }
+                        if (newRecord.equals(current))
+                        {
+                            return false;
+                        }
+                        else if (newRecord.lessThan(current))
+                        {
+                            if (tsLogger.arjLoggerI18N.isDebugEnabled())
+                            {
+                                tsLogger.arjLoggerI18N
+                                        .debug(
+                                                DebugLevel.FUNCTIONS,
+                                                VisibilityLevel.VIS_PRIVATE,
+                                                FacilityCode.FAC_ABSTRACT_REC,
+                                                "com.arjuna.ats.arjuna.coordinator.RecordList_4",
+                                                new Object[]
+                                                { this, newRecord.type(),
+                                                        newRecord.order(),
+                                                        current.type() });
+                            }
 
-			    insertBefore(newRecord, current);
+                            insertBefore(newRecord, current);
 
-			    return true;
-			}
+                            return true;
+                        }
 
-			current = current.getNext();
-		    }
-		}
-	    }
-	}
+                        current = current.getNext();
+                    }
+                }
+            }
+        }
 
-	if (current == null)
-	{
-	    if (tsLogger.arjLoggerI18N.isDebugEnabled())
-	    {
-		tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PRIVATE,
-					     FacilityCode.FAC_ABSTRACT_REC,
-					     "com.arjuna.ats.arjuna.coordinator.RecordList_5",new Object[]{this,newRecord.type(),newRecord.order()});
-	    }
+        if (current == null)
+        {
+            if (tsLogger.arjLoggerI18N.isDebugEnabled())
+            {
+                tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS,
+                        VisibilityLevel.VIS_PRIVATE,
+                        FacilityCode.FAC_ABSTRACT_REC,
+                        "com.arjuna.ats.arjuna.coordinator.RecordList_5",
+                        new Object[]
+                        { this, newRecord.type(), newRecord.order() });
+            }
 
-	    putRear(newRecord);
-	}
-	else
-	{
-	    if (tsLogger.arjLoggerI18N.isDebugEnabled())
-	    {
-		tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PRIVATE,
-					     FacilityCode.FAC_ABSTRACT_REC,
-					     "com.arjuna.ats.arjuna.coordinator.RecordList_6", new Object[]{this, newRecord.type(),newRecord.order(),
-									  current.type(), current.order()});
-	    }
+            putRear(newRecord);
+        }
+        else
+        {
+            if (tsLogger.arjLoggerI18N.isDebugEnabled())
+            {
+                tsLogger.arjLoggerI18N.debug(DebugLevel.FUNCTIONS,
+                        VisibilityLevel.VIS_PRIVATE,
+                        FacilityCode.FAC_ABSTRACT_REC,
+                        "com.arjuna.ats.arjuna.coordinator.RecordList_6",
+                        new Object[]
+                        { this, newRecord.type(), newRecord.order(),
+                                current.type(), current.order() });
+            }
 
-	    insertBefore(newRecord, current);
-	}
+            insertBefore(newRecord, current);
+        }
 
-	return true;
+        return true;
     }
 
     /**
      * Insert the first parameter before the second in the list.
      */
 
-private final void insertBefore (AbstractRecord newRecord, AbstractRecord before)
+    private final void insertBefore (AbstractRecord newRecord,
+            AbstractRecord before)
     {
-	/* first do the main link chaining */
+        /* first do the main link chaining */
 
-	newRecord.setPrevious(before.getPrevious());
-	newRecord.setNext(before);
-	before.setPrevious(newRecord);
+        newRecord.setPrevious(before.getPrevious());
+        newRecord.setNext(before);
+        before.setPrevious(newRecord);
 
-	/* determine if insert was at list head */
+        /* determine if insert was at list head */
 
-	if (newRecord.getPrevious() != null)
-	    (newRecord.getPrevious()).setNext(newRecord);
-	else
-	    /* must be pointing to the head of the list  */
-	    listHead = newRecord;
+        if (newRecord.getPrevious() != null)
+            (newRecord.getPrevious()).setNext(newRecord);
+        else
+            /* must be pointing to the head of the list */
+            listHead = newRecord;
 
-	noEntries++;
+        noEntries++;
     }
 
-private final void replace (AbstractRecord newRecord, AbstractRecord oldRecord)
+    private final void replace (AbstractRecord newRecord,
+            AbstractRecord oldRecord)
     {
-	newRecord.setPrevious(oldRecord.getPrevious());
-	newRecord.setNext(oldRecord.getNext());
+        newRecord.setPrevious(oldRecord.getPrevious());
+        newRecord.setNext(oldRecord.getNext());
 
-	if (newRecord.getPrevious() != null)
-	    (newRecord.getPrevious()).setNext(newRecord);
-	else
-	    listHead = newRecord;
+        if (newRecord.getPrevious() != null)
+            (newRecord.getPrevious()).setNext(newRecord);
+        else
+            listHead = newRecord;
 
-	if (newRecord.getNext() != null)
-	    (newRecord.getNext()).setPrevious(newRecord);
-	else
-	    listTail = newRecord;
+        if (newRecord.getNext() != null)
+            (newRecord.getNext()).setPrevious(newRecord);
+        else
+            listTail = newRecord;
 
-	oldRecord = null;
+        oldRecord = null;
     }
 
     protected AbstractRecord listHead;
 
     private AbstractRecord listTail;
-    private int            noEntries;
 
+    private int noEntries;
+
 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/AtomicActionUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/AtomicActionUnitTest.java	2010-02-13 01:00:43 UTC (rev 31655)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/AtomicActionUnitTest.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -20,13 +20,19 @@
  */
 package com.hp.mwtests.ts.arjuna.atomicaction;
 
+import java.util.Hashtable;
+
 import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.common.Uid;
 import com.arjuna.ats.arjuna.coordinator.ActionStatus;
 import com.arjuna.ats.arjuna.coordinator.BasicAction;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
 
+
 public class AtomicActionUnitTest
 {
     @Test
@@ -36,11 +42,24 @@
         
         A.begin();
         
+        assertEquals(A.hierarchyDepth(), 1);
+        
+        assertEquals(A.topLevelActionUid(), A.get_uid());
+        
         A.end(true);
         
         assertEquals(A.status(), ActionStatus.COMMITTED);
         assertEquals(A.getTimeout(), AtomicAction.NO_TIMEOUT);
         assertTrue(BasicAction.Current() != null);
+        
+        ThreadActionData.purgeActions();
+        
+        assertEquals(BasicAction.Current(), null);
+        
+        assertTrue(A.type() != null);
+        assertTrue(BasicAction.maintainHeuristics());
+        
+        assertTrue(A.destroy());
     }
     
     @Test
@@ -48,13 +67,70 @@
     {
         AtomicAction A = new AtomicAction();
         
-        A.begin();
+        A.begin();      
         
+        assertEquals(A.status(), ActionStatus.RUNNING);
+
+        assertTrue(A.addChildThread());
+        
         A.addThread();
         A.addThread(new Thread());
-        A.end(true);
         
+        assertEquals(A.activeThreads(), 1);
+        
+        A.removeChildThread();
+        
+        assertEquals(A.activeThreads(), 0);
+        
+        A.commit(true);
+        
+        assertEquals(A.status(), ActionStatus.COMMITTED);
+        
+        ThreadActionData.purgeActions();
+    }
+    
+    @Test
+    public void testPreventCommit () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        
+        A.begin();
+        
+        A.preventCommit();
+        
+        A.commit();
+        
         assertEquals(A.status(), ActionStatus.ABORTED);
-        assertTrue(BasicAction.Current() != null);
     }
+    
+    @Test
+    public void testNested () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        AtomicAction B = new AtomicAction();
+        
+        A.begin();
+        B.begin();
+        
+        assertTrue(A.childTransactions().length == 1);
+        
+        B.commit();
+        A.abort();
+        
+        assertEquals(A.deactivate(), true);
+    }
+    
+    @Test
+    public void testActivateDeactivate () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        
+        A.begin();
+        
+        assertEquals(A.activate(), false);
+        
+        A.abort();
+        
+        assertEquals(A.deactivate(), true);
+    }
 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java	2010-02-13 01:00:43 UTC (rev 31655)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -20,12 +20,31 @@
  */
 package com.hp.mwtests.ts.arjuna.atomicaction;
 
+import java.util.Hashtable;
+
 import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.common.Uid;
 import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.coordinator.CheckedAction;
 
 import org.junit.Test;
 import static org.junit.Assert.*;
 
+class DummyCheckedAction extends CheckedAction
+{
+    public void check (boolean isCommit, Uid actUid, Hashtable list)
+    {
+        _called = true;
+    }
+    
+    public boolean called ()
+    {
+        return _called;
+    }
+    
+    private boolean _called;
+}
+
 public class CheckedActionTest
 {
     @Test
@@ -41,6 +60,28 @@
 
         assertTrue(success);
     }
+    
+    @Test
+    public void testCheckedAction ()
+    {
+        AtomicAction A = new AtomicAction();
+        DummyCheckedAction dca = new DummyCheckedAction();
+        
+        A.begin();
+        
+        /*
+         * CheckedAction only called if there are multiple
+         * threads active in the transaction. Simulate this.
+         */
+        
+        A.addChildThread(new Thread());
+        
+        A.setCheckedAction(dca);
 
+        A.commit();
+
+        assertTrue(dca.called());
+    }
+
     public static boolean success = false;
 }

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/RecordListUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/RecordListUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/RecordListUnitTest.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -0,0 +1,67 @@
+/*
+ * 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.arjuna.atomicaction;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.coordinator.RecordList;
+import com.arjuna.ats.internal.arjuna.abstractrecords.ActivationRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord;
+
+import static org.junit.Assert.*;
+
+public class RecordListUnitTest
+{
+    @Test
+    public void test () throws Exception
+    {
+        RecordList rl = new RecordList();
+        DisposeRecord dr = new DisposeRecord();
+        
+        rl.insert(dr);
+        
+        assertEquals(rl.getFront(), dr);
+        
+        rl.insert(dr);
+        
+        assertEquals(rl.getRear(), dr);
+        
+        RecordList copy = new RecordList(rl);
+        ActivationRecord ar = new ActivationRecord();
+        
+        rl.insert(ar);
+        
+        rl.print(new PrintWriter(new ByteArrayOutputStream()));
+        
+        assertTrue(rl.toString() != null);
+        
+        assertEquals(rl.getNext(dr), null);
+        
+        assertTrue(rl.peekFront() != null);
+        assertTrue(rl.peekRear() != null);
+        assertEquals(rl.peekNext(dr), null);
+        
+        assertTrue(rl.remove(dr));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/SynchronizationUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/SynchronizationUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/SynchronizationUnitTest.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -0,0 +1,61 @@
+/*
+ * 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.arjuna.atomicaction;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.TopLevelAction;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.AddOutcome;
+import com.hp.mwtests.ts.arjuna.resources.SyncRecord;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class SynchronizationUnitTest
+{
+    @Test
+    public void tes () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        SyncRecord sr = new SyncRecord();
+        
+        A.begin();
+        
+        assertEquals(A.addSynchronization(sr), AddOutcome.AR_ADDED);
+        assertEquals(A.getSynchronizations().size(), 1);
+        
+        A.commit();
+        
+        assertTrue(sr.called());
+    }
+    
+    @Test
+    public void testInvalid () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        
+        A.begin();
+        
+        assertEquals(A.addSynchronization(null), AddOutcome.AR_REJECTED);
+        
+        A.abort();
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TxControlUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TxControlUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TxControlUnitTest.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -0,0 +1,77 @@
+/*
+ * 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.arjuna.atomicaction;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+
+import static org.junit.Assert.*;
+
+public class TxControlUnitTest
+{
+    @Test
+    public void testDisable () throws Exception
+    {
+        AtomicAction A = new AtomicAction();
+        
+        TxControl.disable();
+        
+        A.begin();
+        A.commit();
+        
+        assertEquals(A.status(), ActionStatus.ABORTED);
+        
+        TxControl.enable();
+        
+        A = new AtomicAction();
+        
+        A.begin();
+        A.commit();
+        
+        assertEquals(A.status(), ActionStatus.COMMITTED);
+    }
+    
+    @Test
+    public void testGetSet () throws Exception
+    {
+        assertEquals(TxControl.getActionStoreType(), arjPropertyManager.getCoordinatorEnvironmentBean().getActionStore());
+        
+        assertTrue(TxControl.getRecoveryStore() != null);
+        
+        TxControl.setDefaultTimeout(1000);
+        
+        assertEquals(TxControl.getDefaultTimeout(), 1000);
+        
+        assertEquals(TxControl.getAsyncPrepare(), arjPropertyManager.getCoordinatorEnvironmentBean().isAsyncPrepare());
+        
+        assertEquals(TxControl.getMaintainHeuristics(), arjPropertyManager.getCoordinatorEnvironmentBean().isMaintainHeuristics());
+        
+        String nodeName = "NodeName";
+        
+        TxControl.setXANodeName(nodeName.getBytes());
+        
+        assertEquals(new String(TxControl.getXANodeName()), nodeName);
+    }
+}

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java	2010-02-13 01:00:43 UTC (rev 31655)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -120,6 +120,8 @@
         AddOutcome.print(pw, AddOutcome.AR_ADDED);
         
         assertEquals(AddOutcome.printString(AddOutcome.AR_DUPLICATE), "AddOutcome.AR_DUPLICATE");
+        assertEquals(AddOutcome.printString(AddOutcome.AR_ADDED), "AddOutcome.AR_ADDED");
+        assertEquals(AddOutcome.printString(AddOutcome.AR_REJECTED), "AddOutcome.AR_REJECTED");
     }
     
     @Test
@@ -131,6 +133,9 @@
         
         assertEquals(TwoPhaseOutcome.stringForm(TwoPhaseOutcome.FINISH_OK), "TwoPhaseOutcome.FINISH_OK");
         
+        for (int i = 0; i < TwoPhaseOutcome.INVALID_TRANSACTION; i++)
+            TwoPhaseOutcome.stringForm(i);
+        
         TwoPhaseOutcome o = new TwoPhaseOutcome(TwoPhaseOutcome.HEURISTIC_COMMIT);
         
         o.setOutcome(TwoPhaseOutcome.NOT_PREPARED);

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SyncRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SyncRecord.java	2010-02-13 01:00:43 UTC (rev 31655)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SyncRecord.java	2010-02-13 12:48:04 UTC (rev 31656)
@@ -43,15 +43,23 @@
 
     public boolean afterCompletion(int status)
     {
+        _called = true;
+        
         return true;
     }
 
+    public boolean called ()
+    {
+        return _called;
+    }
+    
     public Uid get_uid()
     {
         return _theUid;
     }
 
     private Uid _theUid = new Uid();
+    private boolean _called = false;
 
     public int compareTo(Object o)
     {



More information about the jboss-svn-commits mailing list