[jboss-svn-commits] JBL Code SVN: r31664 - in labs/jbosstm/trunk/ArjunaCore/arjuna: classes/com/arjuna/ats/arjuna/coordinator and 5 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Feb 14 18:56:21 EST 2010


Author: mark.little at jboss.com
Date: 2010-02-14 18:56:21 -0500 (Sun, 14 Feb 2010)
New Revision: 31664

Added:
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/ActivationRecordUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverActivationUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverRecordUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/DisposeRecordUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/LastResourceUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/PersistenceRecordUnitTest.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/RecoveryRecordUnitTest.java
Modified:
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/OnePhaseResource.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ExtendedObject.java
   labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/ExtendedUnitTest.java
Log:
https://jira.jboss.org/jira/browse/JBTM-698

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java	2010-02-14 19:18:58 UTC (rev 31663)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -82,7 +82,7 @@
  *          object-id {0}
  * @message com.arjuna.ats.arjuna.StateManager_6
  *          [com.arjuna.ats.arjuna.StateManager_6] - StateManager.destroy -
- *          failed to add abstract record.
+ *          failed to add abstract record to transaction {0}; check transaction status.
  * @message com.arjuna.ats.arjuna.StateManager_7
  *          [com.arjuna.ats.arjuna.StateManager_7] - StateManager.destroy -
  *          caught object store exception: {0}
@@ -598,7 +598,7 @@
                     if (tsLogger.arjLoggerI18N.isWarnEnabled())
                     {
                         tsLogger.arjLoggerI18N
-                                .warn("com.arjuna.ats.arjuna.StateManager_6");
+                                .warn("com.arjuna.ats.arjuna.StateManager_6", new Object[] { action.get_uid() });
                     }
                 }
                 else
@@ -1193,7 +1193,15 @@
                                 currentStatus = ObjectStatus.PASSIVE;
                             }
                             else
+                            {
+                                if (tsLogger.arjLoggerI18N.isWarnEnabled())
+                                {
+                                    tsLogger.arjLoggerI18N
+                                            .warn("com.arjuna.ats.arjuna.StateManager_6", new Object[] { action.get_uid() });
+                                }
+                                
                                 record = null;
+                            }
                         }
                     }
                 }

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/OnePhaseResource.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/OnePhaseResource.java	2010-02-14 19:18:58 UTC (rev 31663)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/coordinator/OnePhaseResource.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -31,11 +31,8 @@
 
 package com.arjuna.ats.arjuna.coordinator;
 
-import com.arjuna.ats.arjuna.common.*;
 import com.arjuna.ats.arjuna.state.*;
 
-import java.io.PrintWriter;
-
 import java.io.IOException;
 
 /*

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java	2010-02-14 19:18:58 UTC (rev 31663)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/CadaverRecord.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -286,8 +286,9 @@
 			    tlpOk = TwoPhaseOutcome.PREPARE_OK;
 		    }
 		}
-		catch (ObjectStoreException e)
+		catch (final ObjectStoreException e)
 		{
+		    e.printStackTrace();
 		}
 	    }
 	    else

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java	2010-02-14 19:18:58 UTC (rev 31663)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -116,6 +116,9 @@
  * @message com.arjuna.ats.arjuna.PersistenceRecord_18
  *          [com.arjuna.ats.arjuna.PersistenceRecord_18]
  *          PersistenceRecord::topLevelAbort() - Expecting state but found none!
+ * @message com.arjuna.ats.arjuna.PersistenceRecord_19
+ *          [com.arjuna.ats.arjuna.PersistenceRecord_19]
+ *          PersistenceRecord::topLevelAbort() - Could not remove state from object store!
  * @message com.arjuna.ats.arjuna.PersistenceRecord_20
  *          [com.arjuna.ats.arjuna.PersistenceRecord_20]
  *          PersistenceRecord::topLevelAbort() - Received ObjectStoreException

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/ActivationRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/ActivationRecordUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/ActivationRecordUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.ActivationRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class ActivationRecordUnitTest
+{
+    @Test
+    public void test ()
+    {
+        ActivationRecord cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), new AtomicAction());
+        
+        assertFalse(cr.propagateOnAbort());
+        assertTrue(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.ACTIVATION);
+        
+        assertTrue(cr.type() != null);
+        assertEquals(cr.doSave(), false);
+        
+        assertEquals((Integer) cr.value(), new Integer(ObjectType.ANDPERSISTENT));
+
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
+
+        cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), new AtomicAction());
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), new AtomicAction());
+
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
+ 
+        cr = new ActivationRecord(ObjectType.ANDPERSISTENT, new ExtendedObject(), new AtomicAction());
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new ActivationRecord();
+        
+        cr.merge(new ActivationRecord());
+        cr.alter(new ActivationRecord());
+        
+        assertTrue(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
+        assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverActivationUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverActivationUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverActivationUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class CadaverActivationUnitTest
+{
+    @Test
+    public void test ()
+    {
+        CadaverActivationRecord cr = new CadaverActivationRecord(new ExtendedObject());
+        
+        assertTrue(cr.propagateOnAbort());
+        assertTrue(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.ACTIVATION);
+        
+        assertTrue(cr.type() != null);
+        assertEquals(cr.doSave(), false);
+
+        assertFalse(cr.shouldReplace(new PersistenceRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject())));
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
+
+        cr = new CadaverActivationRecord(new ExtendedObject());
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new CadaverActivationRecord(new ExtendedObject());
+
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
+ 
+        cr = new CadaverActivationRecord(new ExtendedObject());
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverRecordUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/CadaverRecordUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class CadaverRecordUnitTest
+{
+    @Test
+    public void test ()
+    {
+        CadaverRecord cr = new CadaverRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject());
+        
+        assertTrue(cr.propagateOnAbort());
+        assertTrue(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.PERSISTENCE);
+        
+        assertTrue(cr.type() != null);
+        assertEquals(cr.doSave(), false);
+
+        cr.merge(new PersistenceRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject()));
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
+
+        cr = new CadaverRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject());
+        cr.merge(new PersistenceRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject()));
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new CadaverRecord(new OutputObjectState(new Uid(), "foobar"), TxControl.getStore(), new ExtendedObject());
+        cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), TxControl.getStore(), new ExtendedObject()));
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
+ 
+        cr = new CadaverRecord(new OutputObjectState(new Uid(), "foobar"), TxControl.getStore(), new ExtendedObject());
+        cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), TxControl.getStore(), new ExtendedObject()));
+        cr.merge(new PersistenceRecord(new OutputObjectState(new Uid(), "foobar"), TxControl.getStore(), new ExtendedObject()));
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
+
+        cr = new CadaverRecord();
+        
+        cr.print(new PrintWriter(new ByteArrayOutputStream()));
+        
+        assertFalse(cr.shouldMerge(new DisposeRecord()));
+        assertFalse(cr.shouldReplace(new DisposeRecord()));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/DisposeRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/DisposeRecordUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/DisposeRecordUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.DisposeRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class DisposeRecordUnitTest
+{
+    @Test
+    public void test ()
+    {
+        DisposeRecord cr = new DisposeRecord(TxControl.getStore(), new ExtendedObject());
+        
+        assertFalse(cr.propagateOnAbort());
+        assertTrue(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.DISPOSE);
+        
+        assertTrue(cr.type() != null);
+        assertEquals(cr.doSave(), true);
+
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
+
+        cr = new DisposeRecord(TxControl.getStore(), new ExtendedObject());
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new DisposeRecord(TxControl.getStore(), new ExtendedObject());
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
+ 
+        cr = new DisposeRecord(TxControl.getStore(), new ExtendedObject());
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_ERROR);
+        
+        cr = new DisposeRecord();
+        
+        assertFalse(cr.shouldAdd(new PersistenceRecord()));
+        assertFalse(cr.shouldAlter(new PersistenceRecord()));
+        assertFalse(cr.shouldMerge(new PersistenceRecord()));
+        assertFalse(cr.shouldReplace(new PersistenceRecord()));
+        
+        assertFalse(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
+        assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/LastResourceUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/LastResourceUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/LastResourceUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.CadaverActivationRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.LastResourceRecord;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class LastResourceUnitTest
+{
+    @Test
+    public void test ()
+    {
+        LastResourceRecord cr = new LastResourceRecord(null); // force errors!
+        
+        assertFalse(cr.propagateOnAbort());
+        assertFalse(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.LASTRESOURCE);
+        
+        assertTrue(cr.type() != null);
+        assertFalse(cr.doSave());
+
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
+        assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_OK);
+
+        cr = new LastResourceRecord(null);
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
+        assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_ERROR);
+        
+        cr = new LastResourceRecord(null);
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
+ 
+        cr = new LastResourceRecord(null);
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new LastResourceRecord(null);
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_NOTOK);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_OK);
+
+        cr.print(new PrintWriter(new ByteArrayOutputStream()));
+        
+        assertEquals(cr.value(), null);
+        cr.setValue(null);
+        
+        assertTrue(cr.shouldAdd(new PersistenceRecord()));
+        assertFalse(cr.shouldAlter(new PersistenceRecord()));
+        assertFalse(cr.shouldMerge(new PersistenceRecord()));
+        assertFalse(cr.shouldReplace(new PersistenceRecord()));
+        
+        cr = new LastResourceRecord();
+        
+        cr.merge(new PersistenceRecord());
+        cr.alter(new PersistenceRecord());
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/PersistenceRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/PersistenceRecordUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/PersistenceRecordUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class PersistenceRecordUnitTest
+{
+    @Test
+    public void test ()
+    {
+        PersistenceRecord cr = new PersistenceRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject());
+        
+        arjPropertyManager.getCoordinatorEnvironmentBean().setClassicPrepare(true);
+        
+        assertFalse(cr.propagateOnAbort());
+        assertTrue(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.PERSISTENCE);
+        
+        assertTrue(cr.type() != null);
+        assertEquals(cr.doSave(), true);
+
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
+ 
+        cr = new PersistenceRecord(new OutputObjectState(), TxControl.getStore(), new ExtendedObject());
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_OK);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
+
+        cr.print(new PrintWriter(new ByteArrayOutputStream()));
+        
+        OutputObjectState os = new OutputObjectState();
+        
+        assertTrue(cr.save_state(os, ObjectType.ANDPERSISTENT));
+        assertTrue(cr.restore_state(new InputObjectState(os), ObjectType.ANDPERSISTENT));
+        
+        assertEquals(cr.topLevelCleanup(), TwoPhaseOutcome.FINISH_OK);
+    }
+}

Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/RecoveryRecordUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/RecoveryRecordUnitTest.java	                        (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/abstractrecords/RecoveryRecordUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, 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) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.abstractrecords;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.coordinator.RecordType;
+import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+import com.arjuna.ats.internal.arjuna.abstractrecords.RecoveryRecord;
+import com.hp.mwtests.ts.arjuna.resources.ExtendedObject;
+
+import static org.junit.Assert.*;
+
+public class RecoveryRecordUnitTest
+{
+    @Test
+    public void test ()
+    {
+        RecoveryRecord cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
+        
+        assertFalse(cr.propagateOnAbort());
+        assertTrue(cr.propagateOnCommit());
+        assertEquals(cr.typeIs(), RecordType.RECOVERY);
+        
+        assertTrue(cr.type() != null);
+        assertEquals(cr.doSave(), false);
+        assertTrue(cr.value() != null);
+        
+        cr.setValue(new OutputObjectState());
+
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedAbort(), TwoPhaseOutcome.FINISH_ERROR);
+
+        cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
+        
+        assertEquals(cr.nestedPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.nestedCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
+
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.topLevelAbort(), TwoPhaseOutcome.FINISH_ERROR);
+ 
+        cr = new RecoveryRecord(new OutputObjectState(), new ExtendedObject());
+        
+        assertEquals(cr.topLevelPrepare(), TwoPhaseOutcome.PREPARE_READONLY);
+        assertEquals(cr.topLevelCommit(), TwoPhaseOutcome.FINISH_OK);
+        
+        cr = new RecoveryRecord();
+        
+        cr.merge(new RecoveryRecord());
+        cr.alter(new RecoveryRecord());
+        
+        assertTrue(cr.save_state(new OutputObjectState(), ObjectType.ANDPERSISTENT));
+        assertFalse(cr.restore_state(new InputObjectState(), ObjectType.ANDPERSISTENT));
+    }
+}

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ExtendedObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ExtendedObject.java	2010-02-14 19:18:58 UTC (rev 31663)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ExtendedObject.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -46,7 +46,7 @@
 
         state = 0;
 
-        lockMutex();
+        lock();
         
         activate();
         modified();
@@ -54,7 +54,7 @@
         
         setStatus(status());
         
-        unlockMutex();
+        unlock();
     }
 
     public ExtendedObject(Uid u)
@@ -62,12 +62,6 @@
         super(u, ObjectType.ANDPERSISTENT);
 
         state = -1;
-
-        getMutex().tryLock();
-        
-        activate();
-        
-        getMutex().unlock();
     }
     
     public void set_status ()

Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/ExtendedUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/ExtendedUnitTest.java	2010-02-14 19:18:58 UTC (rev 31663)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/ExtendedUnitTest.java	2010-02-14 23:56:21 UTC (rev 31664)
@@ -38,6 +38,7 @@
 import com.arjuna.ats.arjuna.ObjectStatus;
 import com.arjuna.ats.arjuna.ObjectType;
 import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
 import com.arjuna.ats.internal.arjuna.thread.ThreadActionData;
 
 import com.hp.mwtests.ts.arjuna.resources.*;
@@ -80,14 +81,19 @@
     @Test
     public void testCadaver () throws Exception
     {
+        arjPropertyManager.getCoordinatorEnvironmentBean().setReadonlyOptimisation(false);
+        
         AtomicAction A = new AtomicAction();
         AtomicAction B = new AtomicAction();
         
+        ExtendedObject bo = new ExtendedObject();
+        Uid id = bo.get_uid();
+        
+        bo = new ExtendedObject(id);
+        
         A.begin();
         B.begin();
         
-        ExtendedObject bo = new ExtendedObject();
-        
         bo.set(2);
        
         bo.terminate();



More information about the jboss-svn-commits mailing list