[jboss-svn-commits] JBL Code SVN: r31473 - in labs/jbosstm/trunk/ArjunaCore/arjuna: classes/com/arjuna/ats/arjuna/thread and 10 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Feb 6 11:36:35 EST 2010
Author: mark.little at jboss.com
Date: 2010-02-06 11:36:34 -0500 (Sat, 06 Feb 2010)
New Revision: 31473
Added:
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/CrashAction.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TopLevelActionUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ExceptionsUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/LoggingUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ProcessIdUnitTest.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/recovery/RecordTypeManagerUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/CrashRecord.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
Removed:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/thread/TransactionalThread.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/state/OutputByteStream.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/TopLevelAction.java
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/TxLogWritePersistenceRecord.java
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/common/UidHelper.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/destroy/DestroyTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicObject.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/BasicTest.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-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/StateManager.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -439,7 +439,7 @@
public boolean deactivate ()
{
- return deactivate(null, true);
+ return deactivate(null);
}
/**
@@ -1112,7 +1112,7 @@
synchronized (usingActions)
{
- if (usingActions != null)
+ if (usingActions.size() > 0)
{
Enumeration e = usingActions.keys();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/TopLevelAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/TopLevelAction.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/TopLevelAction.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -34,25 +34,22 @@
import com.arjuna.ats.arjuna.coordinator.ActionType;
/**
- * This class provides a (nested) top-level transaction. So, no
- * matter how deeply nested a thread may be within a transaction
- * hierarchy, creating an instance of this class will always start
- * a new top-level transaction.
- *
- * Derived from AtomicAction so we can get the action-to-thread
- * tracking.
- *
+ * This class provides a (nested) top-level transaction. So, no matter how
+ * deeply nested a thread may be within a transaction hierarchy, creating an
+ * instance of this class will always start a new top-level transaction. Derived
+ * from AtomicAction so we can get the action-to-thread tracking.
+ *
* @author Mark Little (mark at arjuna.com)
- * @version $Id: TopLevelAction.java 2342 2006-03-30 13:06:17Z $
+ * @version $Id: TopLevelAction.java 2342 2006-03-30 13:06:17Z $
* @since JTS 1.0.
*/
public class TopLevelAction extends AtomicAction
{
-public TopLevelAction ()
+ public TopLevelAction()
{
- super(ActionType.TOP_LEVEL);
+ super(ActionType.TOP_LEVEL);
}
}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/thread/TransactionalThread.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/thread/TransactionalThread.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/thread/TransactionalThread.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -1,126 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: TransactionalThread.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.arjuna.thread;
-
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.utils.ThreadUtil;
-
-import java.util.Hashtable;
-import java.lang.Thread;
-
-import java.lang.IllegalArgumentException;
-
-/**
- * A transactional thread is automatically registered with the transaction
- * that is in scope when it is created (i.e., the transaction that is
- * associated with the creating thread). The transactional thread is also
- * automatically unregistered from the transaction when the thread
- * terminates.
- *
- * @author Mark Little (mark at arjuna.com)
- * @version $Id: TransactionalThread.java 2342 2006-03-30 13:06:17Z $
- * @since JTS 1.0.
- */
-
-public class TransactionalThread extends Thread
-{
-
-public void finalize ()
- {
- if (action != null)
- {
- action.removeChildThread(ThreadUtil.getThreadId(this));
- action = null;
- }
- }
-
-public static void create (Thread thread) throws IllegalArgumentException
- {
- /*
- * New thread should not be running yet, so this
- * should work!
- */
-
- final String threadId = ThreadUtil.getThreadId(thread) ;
- if (actions.get(threadId) == null)
- {
- BasicAction currentAction = BasicAction.Current();
-
- if (currentAction != null)
- {
- currentAction.addChildThread(thread);
- actions.put(threadId, currentAction);
-
- currentAction = null;
- }
- }
- else
- throw new IllegalArgumentException();
- }
-
-public static void destroy (Thread thread) throws IllegalArgumentException
- {
- final String threadId = ThreadUtil.getThreadId(thread) ;
- BasicAction currentAction = (BasicAction) actions.remove(threadId);
-
- if (currentAction != null)
- {
- if (currentAction != null)
- {
- currentAction.removeChildThread(threadId);
- currentAction = null;
- }
- }
- else
- throw new IllegalArgumentException();
- }
-
-protected TransactionalThread ()
- {
- /*
- * New thread should not be running yet, so this
- * should work!
- */
-
- action = BasicAction.Current();
-
- if (action != null)
- {
- action.addChildThread(this);
- }
- }
-
-private BasicAction action = null;
-
-private static Hashtable actions = new Hashtable();
-
-}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/TxLogWritePersistenceRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/TxLogWritePersistenceRecord.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/TxLogWritePersistenceRecord.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -44,6 +44,7 @@
import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
/**
+ * Needs further consideration and then completion.
*/
public class TxLogWritePersistenceRecord extends PersistenceRecord
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-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/abstractrecords/PersistenceRecord.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -81,7 +81,7 @@
* PersistenceRecord::topLevelCommit - commit_state error
* @message com.arjuna.ats.arjuna.PersistenceRecord_7
* [com.arjuna.ats.arjuna.PersistenceRecord_7] PersistenceRecord
- * deactivate error
+ * deactivate error, object probably already deactivated!
* @message com.arjuna.ats.arjuna.PersistenceRecord_8
* [com.arjuna.ats.arjuna.PersistenceRecord_8]
* PersistenceRecord.topLevelPrepare - setup error!
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/UidHelper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/UidHelper.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/common/UidHelper.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -26,7 +26,7 @@
* Tyne and Wear,
* UK.
*
- * $Id: CadaverRecordSetup.java 2342 2006-03-30 13:06:17Z $
+ * $Id$
*/
package com.arjuna.ats.internal.arjuna.common;
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/state/OutputByteStream.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/state/OutputByteStream.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/internal/arjuna/state/OutputByteStream.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA 02110-1301, USA.
- *
- * (C) 2005-2006,
- * @author JBoss Inc.
- */
-/*
- * Copyright (C) 2003,
- *
- * Arjuna Technologies Ltd,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: OutputByteStream.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.arjuna.ats.internal.arjuna.state;
-
-import java.io.*;
-
-public class OutputByteStream
-{
-
- public OutputByteStream ()
- {
- }
-
- public OutputByteStream (int size)
- {
- }
-
- // private ByteBuffer[] _bytes;
-
-}
-
Added: 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 (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/AtomicActionUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,60 @@
+/*
+ * 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.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.coordinator.BasicAction;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class AtomicActionUnitTest
+{
+ @Test
+ public void testBasic () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+
+ A.begin();
+
+ A.end(true);
+
+ assertEquals(A.status(), ActionStatus.COMMITTED);
+ assertEquals(A.getTimeout(), AtomicAction.NO_TIMEOUT);
+ assertTrue(BasicAction.Current() != null);
+ }
+
+ @Test
+ public void testThreading () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+
+ A.begin();
+
+ A.addThread();
+ A.addThread(new Thread());
+ A.end(true);
+
+ assertEquals(A.status(), ActionStatus.ABORTED);
+ assertTrue(BasicAction.Current() != null);
+ }
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CrashAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CrashAction.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CrashAction.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: BadAction.java 2342 2006-03-30 13:06:17Z $
+ */
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.coordinator.*;
+import com.hp.mwtests.ts.arjuna.resources.CrashRecord;
+import com.hp.mwtests.ts.arjuna.resources.CrashRecord.CrashLocation;
+import com.hp.mwtests.ts.arjuna.resources.CrashRecord.CrashType;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class CrashAction
+{
+ @Test
+ public void test()
+ {
+ AtomicAction A = new AtomicAction();
+
+ A.begin();
+
+ A.add(new CrashRecord(CrashLocation.NoCrash, CrashType.Normal));
+ A.add(new CrashRecord(CrashLocation.CrashInCommit, CrashType.HeuristicHazard));
+
+ int outcome = A.commit();
+
+ System.out.println("Transaction "+A+" committed with "+ActionStatus.stringForm(outcome));
+ }
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TopLevelActionUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TopLevelActionUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/TopLevelActionUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+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 org.junit.Test;
+import static org.junit.Assert.*;
+
+public class TopLevelActionUnitTest
+{
+ @Test
+ public void test() throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ AtomicAction B = new AtomicAction();
+ TopLevelAction tl = new TopLevelAction();
+
+ A.begin(); // top level
+ B.begin(); // nested
+
+ tl.begin(); // nested top level
+
+ A.abort(); // not recommended in practice!
+
+ assertEquals(A.status(), ActionStatus.ABORTED);
+ assertEquals(B.status(), ActionStatus.ABORTED);
+
+ assertEquals(tl.status(), ActionStatus.RUNNING);
+
+ tl.abort();
+ }
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ExceptionsUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ExceptionsUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ExceptionsUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,54 @@
+/*
+ * 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.common;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.exceptions.FatalError;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreError;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+
+import static org.junit.Assert.*;
+
+public class ExceptionsUnitTest
+{
+ @Test
+ public void test ()
+ {
+ FatalError fe = new FatalError();
+
+ fe = new FatalError("problem");
+ fe = new FatalError("problem", new NullPointerException());
+ fe = new FatalError(new NullPointerException());
+
+ ObjectStoreError os = new ObjectStoreError();
+
+ os = new ObjectStoreError("problem");
+ os = new ObjectStoreError("problem", new NullPointerException());
+ os = new ObjectStoreError(new NullPointerException());
+
+ ObjectStoreException ox = new ObjectStoreException();
+
+ ox = new ObjectStoreException("problem");
+ ox = new ObjectStoreException("problem", new NullPointerException());
+ ox = new ObjectStoreException(new NullPointerException());
+ }
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/LoggingUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/LoggingUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/LoggingUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,44 @@
+/*
+ * 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.common;
+
+import com.arjuna.ats.arjuna.logging.FacilityCode;
+import com.arjuna.ats.arjuna.logging.tsLogger;
+import com.arjuna.common.util.logging.DebugLevel;
+import com.arjuna.common.util.logging.VisibilityLevel;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class LoggingUnitTest
+{
+ @Test
+ public void testFacilityCode()
+ {
+ tsLogger.arjLogger.debug(DebugLevel.FUNCTIONS, VisibilityLevel.VIS_PUBLIC, FacilityCode.FAC_ATOMIC_ACTION, "hello world");
+ tsLogger.arjLogger.debug(DebugLevel.ALL_NON_TRIVIAL, VisibilityLevel.VIS_PACKAGE, FacilityCode.FAC_ABSTRACT_REC, "another test");
+
+ FacilityCode fc = new FacilityCode();
+
+ assertEquals(fc.getLevel("FAC_CRASH_RECOVERY"), FacilityCode.FAC_CRASH_RECOVERY);
+ assertEquals(fc.printString(FacilityCode.FAC_JDBC), "FAC_JDBC");
+ }
+}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ProcessIdUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ProcessIdUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/ProcessIdUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,68 @@
+/*
+ * 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.common;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.internal.arjuna.utils.ExecProcessId;
+import com.arjuna.ats.internal.arjuna.utils.FileProcessId;
+import com.arjuna.ats.internal.arjuna.utils.MBeanProcessId;
+import com.arjuna.ats.internal.arjuna.utils.ManualProcessId;
+
+import static org.junit.Assert.*;
+
+public class ProcessIdUnitTest
+{
+ @Test
+ public void testFileProcessId()
+ {
+ FileProcessId fp = new FileProcessId();
+
+ assertTrue(fp.getpid() != -1);
+ }
+
+ @Test
+ public void testManualProcessId()
+ {
+ arjPropertyManager.getCoreEnvironmentBean().setPid(1);
+
+ ManualProcessId mp = new ManualProcessId();
+
+ assertTrue(mp.getpid() == 1);
+ }
+
+ @Test
+ public void testExecProcessId()
+ {
+ ExecProcessId xp = new ExecProcessId();
+
+ assertTrue(xp.getpid() > 0);
+ }
+
+ @Test
+ public void testMBeanProcessId()
+ {
+ MBeanProcessId mp = new MBeanProcessId();
+
+ assertTrue(mp.getpid() > 0);
+ }
+}
Added: 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 (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TypesUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,92 @@
+/*
+ * 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.common;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.ObjectModel;
+import com.arjuna.ats.arjuna.ObjectStatus;
+import com.arjuna.ats.arjuna.ObjectType;
+import com.arjuna.ats.arjuna.objectstore.StateStatus;
+import com.arjuna.ats.arjuna.objectstore.StateType;
+
+import static org.junit.Assert.*;
+
+public class TypesUnitTest
+{
+ @Test
+ public void testObjectModel ()
+ {
+ new ObjectModel();
+
+ PrintWriter pw = new PrintWriter(new StringWriter());
+
+ ObjectModel.print(pw, ObjectModel.MULTIPLE);
+ ObjectModel.print(pw, ObjectModel.SINGLE);
+ }
+
+ @Test
+ public void testObjectStatus ()
+ {
+ new ObjectStatus();
+
+ PrintWriter pw = new PrintWriter(new StringWriter());
+
+ ObjectStatus.print(pw, ObjectStatus.ACTIVE);
+
+ assertEquals(ObjectStatus.toString(ObjectStatus.ACTIVE_NEW), "ACTIVE_NEW");
+ }
+
+ @Test
+ public void testObjectType ()
+ {
+ new ObjectType();
+
+ PrintWriter pw = new PrintWriter(new StringWriter());
+
+ ObjectType.print(pw, ObjectType.ANDPERSISTENT);
+
+ assertEquals(ObjectType.toString(ObjectType.NEITHER), "NEITHER");
+ }
+
+ @Test
+ public void testStateStatus ()
+ {
+ PrintWriter pw = new PrintWriter(new StringWriter());
+
+ StateStatus.printStateStatus(pw, StateStatus.OS_COMMITTED);
+
+ assertEquals(StateStatus.stateStatusString(StateStatus.OS_HIDDEN), "StateStatus.OS_HIDDEN");
+ }
+
+ @Test
+ public void testStateType ()
+ {
+ PrintWriter pw = new PrintWriter(new StringWriter());
+
+ StateType.printStateType(pw, StateType.OS_INVISIBLE);
+
+ assertEquals(StateType.stateTypeString(StateType.OS_ORIGINAL), "StateType.OS_ORIGINAL");
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/destroy/DestroyTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/destroy/DestroyTest.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/destroy/DestroyTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -55,14 +55,17 @@
A.commit();
AtomicAction B = new AtomicAction();
-
+ AtomicAction C = new AtomicAction();
+
B.begin();
-
+ C.begin();
+
bo.destroy();
+ C.commit();
B.abort();
- AtomicAction C = new AtomicAction();
+ C = new AtomicAction();
C.begin();
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecordTypeManagerUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecordTypeManagerUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecordTypeManagerUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: CallbackRecoveryTest.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.arjuna.recovery;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.coordinator.AbstractRecord;
+import com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeManager;
+import com.arjuna.ats.arjuna.coordinator.abstractrecord.RecordTypeMap;
+import com.arjuna.ats.internal.arjuna.abstractrecords.PersistenceRecord;
+
+import static org.junit.Assert.*;
+
+
+class DummyMap implements RecordTypeMap
+{
+
+ public Class<? extends AbstractRecord> getRecordClass ()
+ {
+ return PersistenceRecord.class;
+ }
+
+ public int getType ()
+ {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+}
+public class RecordTypeManagerUnitTest
+{
+ @Test
+ public void test()
+ {
+ DummyMap map = new DummyMap();
+ RecordTypeManager.manager().add(map);
+
+ assertEquals(RecordTypeManager.manager().getClass(0), PersistenceRecord.class);
+ assertEquals(RecordTypeManager.manager().getType(PersistenceRecord.class), 0);
+
+ RecordTypeManager.manager().remove(map);
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicObject.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicObject.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -84,7 +84,7 @@
public String type()
{
- return "StateManager/BasicObject";
+ return super.type()+"/BasicObject";
}
public boolean deactivate()
@@ -107,7 +107,7 @@
return false;
}
- return true;
+ return super.save_state(os, type);
}
public boolean restore_state(InputObjectState os, int type)
@@ -129,7 +129,7 @@
return false;
}
- return true;
+ return super.restore_state(os, type);
}
private int state;
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/CrashRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/CrashRecord.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/CrashRecord.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,175 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 2004,
+ *
+ * Arjuna Technologies Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: BasicRecord.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.arjuna.resources;
+
+import com.arjuna.ats.arjuna.coordinator.*;
+import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.arjuna.state.*;
+
+
+public class CrashRecord extends AbstractRecord
+{
+ public enum CrashLocation { NoCrash, CrashInPrepare, CrashInCommit, CrashInAbort };
+ public enum CrashType { Normal, HeuristicHazard };
+
+ public CrashRecord (CrashLocation cl, CrashType ct)
+ {
+ super(new Uid());
+
+ _cl = cl;
+ _ct = ct;
+ }
+
+ public int typeIs()
+ {
+ return RecordType.USER_DEF_FIRST0;
+ }
+
+ public int nestedAbort()
+ {
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int nestedCommit()
+ {
+ return TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ public int nestedPrepare()
+ {
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ }
+
+ public int topLevelAbort()
+ {
+ if (_cl == CrashLocation.CrashInAbort)
+ {
+ if (_ct == CrashType.Normal)
+ return TwoPhaseOutcome.FINISH_ERROR;
+ else
+ return TwoPhaseOutcome.HEURISTIC_HAZARD;
+ }
+ else
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int topLevelCommit()
+ {
+ if (_cl == CrashLocation.CrashInCommit)
+ {
+ if (_ct == CrashType.Normal)
+ return TwoPhaseOutcome.FINISH_ERROR;
+ else
+ return TwoPhaseOutcome.HEURISTIC_HAZARD;
+ }
+ else
+ return TwoPhaseOutcome.FINISH_OK;
+ }
+
+ public int topLevelPrepare()
+ {
+ if (_cl == CrashLocation.CrashInAbort)
+ {
+ if (_ct == CrashType.Normal)
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ else
+ return TwoPhaseOutcome.HEURISTIC_HAZARD;
+ }
+ else
+ return TwoPhaseOutcome.PREPARE_OK;
+ }
+
+ public boolean doSave()
+ {
+ return true;
+ }
+
+ public boolean save_state(OutputObjectState os, int ot)
+ {
+ return true;
+ }
+
+ public boolean restore_state(InputObjectState os, int ot)
+ {
+ return true;
+ }
+
+ public String type()
+ {
+ return "/StateManager/AbstractRecord/CrashRecord";
+ }
+
+ public boolean shouldAdd(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldMerge(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldReplace(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public boolean shouldAlter(AbstractRecord a)
+ {
+ return false;
+ }
+
+ public void merge(AbstractRecord a)
+ {
+ }
+
+ public void alter(AbstractRecord a)
+ {
+ }
+
+ /**
+ * @return <code>Object</code> to be used to order.
+ */
+
+ public Object value()
+ {
+ return null;
+ }
+
+ public void setValue(Object o)
+ {
+ }
+
+ private CrashLocation _cl;
+ private CrashType _ct;
+}
+
Added: 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 (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ExtendedObject.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,156 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: BasicObject.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.arjuna.resources;
+
+import com.arjuna.ats.arjuna.*;
+import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.arjuna.state.*;
+
+public class ExtendedObject extends StateManager
+{
+
+ public ExtendedObject()
+ {
+ super(ObjectType.ANDPERSISTENT);
+
+ state = 0;
+
+ lockMutex();
+
+ activate();
+ modified();
+ deactivate();
+
+ setStatus(status());
+
+ unlockMutex();
+ }
+
+ public ExtendedObject(Uid u)
+ {
+ super(u, ObjectType.ANDPERSISTENT);
+
+ state = -1;
+
+ getMutex().tryLock();
+
+ activate();
+
+ getMutex().unlock();
+ }
+
+ public void incr(int value)
+ {
+ modified();
+
+ state += value;
+ }
+
+ public void set(int value)
+ {
+ modified();
+
+ state = value;
+ }
+
+ public int get()
+ {
+ if (activate())
+ return state;
+ else
+ return -1;
+ }
+
+ public String type()
+ {
+ return super.type()+"/BasicObject";
+ }
+
+ public void toggle ()
+ {
+ super.disable();
+ super.persist();
+ }
+
+ public void terminate ()
+ {
+ super.terminate();
+ }
+
+ public boolean deactivate()
+ {
+ return super.deactivate();
+ }
+
+ public boolean activate()
+ {
+ return super.activate();
+ }
+
+ public boolean save_state(OutputObjectState os, int type)
+ {
+ try {
+ os.packInt(state);
+ os.packBytes(moreState);
+ }
+ catch (Exception ex) {
+ return false;
+ }
+
+ return super.save_state(os, type);
+ }
+
+ public boolean restore_state(InputObjectState os, int type)
+ {
+ try {
+ state = -1;
+ moreState = null;
+
+ state = os.unpackInt();
+ moreState = os.unpackBytes();
+
+ if ((moreState[0] == 'a') && (moreState[1] == 'b')
+ && (moreState[2] == 'c') && (moreState[3] == 'd')) {
+ // ok
+ } else
+ return false;
+ }
+ catch (Exception ex) {
+ return false;
+ }
+
+ return super.restore_state(os, type);
+ }
+
+ private int state;
+ private byte[] moreState = {'a', 'b', 'c', 'd'};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/BasicTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/BasicTest.java 2010-02-06 16:32:20 UTC (rev 31472)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/BasicTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -51,5 +51,8 @@
bo.set(2);
A.commit();
+
+ assertTrue(bo.getStore() != null);
+ assertTrue(bo.getStoreRoot() != null);
}
}
Added: 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 (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/ExtendedUnitTest.java 2010-02-06 16:36:34 UTC (rev 31473)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+/*
+ * Copyright (C) 1998, 1999, 2000,
+ *
+ * Arjuna Solutions Limited,
+ * Newcastle upon Tyne,
+ * Tyne and Wear,
+ * UK.
+ *
+ * $Id: BasicTest.java 2342 2006-03-30 13:06:17Z $
+ */
+
+package com.hp.mwtests.ts.arjuna.statemanager;
+
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.ObjectStatus;
+import com.arjuna.ats.arjuna.common.Uid;
+
+import com.hp.mwtests.ts.arjuna.resources.*;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ExtendedUnitTest
+{
+ @Test
+ public void test() throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ ExtendedObject bo = new ExtendedObject();
+ Uid u = bo.get_uid();
+
+ A.begin();
+
+ bo.set(2);
+
+ bo.toggle();
+
+ A.commit();
+
+ bo.terminate();
+
+ bo = new ExtendedObject(u);
+
+ assertEquals(bo.status(), ObjectStatus.PASSIVE);
+ assertTrue(bo.getStore() != null);
+ assertTrue(bo.getStoreRoot() != null);
+ }
+
+ @Test
+ public void testCadaver () throws Exception
+ {
+ AtomicAction A = new AtomicAction();
+ AtomicAction B = new AtomicAction();
+
+ A.begin();
+ B.begin();
+
+ ExtendedObject bo = new ExtendedObject();
+
+ bo.set(2);
+
+ bo.terminate();
+
+ B.commit();
+ A.commit();
+ }
+}
More information about the jboss-svn-commits
mailing list