[jboss-svn-commits] JBL Code SVN: r27448 - in labs/jbosstm/trunk/ArjunaCore/arjuna: tests/classes/com/hp/mwtests/ts/arjuna/atomicaction and 16 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jul 2 12:34:57 EDT 2009
Author: jhalliday
Date: 2009-07-02 12:34:55 -0400 (Thu, 02 Jul 2009)
New Revision: 27448
Removed:
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/exceptions/TestException.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/security/SecurityTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/testframework/Wrapper.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/ActionScope.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/BadAction.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/atomicaction/DummyCheckedActionFactory.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/LastResource.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/PersistenceUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TxControlUnitTest.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/file/FileLocking.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/JNSTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/PNSTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/AllObjUidsTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/JDBCInventory.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/MyAccess.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance1.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance3.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase3.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionStatusServiceTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestClient.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestServer.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/BasicCrashRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CallbackRecoveryTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordImpl.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordSetup.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DestroyRecoverTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DummyRecoveryModule.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/EmbeddedRecoveryTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ListenerTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/LogMoveTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryLifecycleTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryManagerStartStopTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryTransaction.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusConnectorTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusManagerItemTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/UserDefFirst0Setup.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/resources/BasicRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicThreadedObject.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhase.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ShutdownRecord.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SimpleObject.java
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/statemanager/BasicTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/threadaction/ThreadActionTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUniqueness.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/xa/xidcheck.java
Log:
Updated unit tests. JBTM-576
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml 2009-07-02 16:34:55 UTC (rev 27448)
@@ -22,8 +22,10 @@
<property name="modulename" value="arjuna"/>
- <property name="global.ext.test.libs" value="junit.jar,TestingFramework.jar"/>
+ <property name="global.ext.test.libs" value="junit-4.6.jar"/>
+ <!--<property name="global.ext.test.libs" value="junit.jar,TestingFramework.jar"/>-->
+
<import file="../../sharedbuild.xml"/>
<target name="init" depends="sharedbuild.init">
@@ -40,7 +42,44 @@
</target>
<target name="run.tests">
+
<run.tests.macro>
+ <tests>
+ <fileset dir="tests/classes" includes="**/*.java">
+ <exclude name="**/resources/**"/>
+ <exclude name="**/DummyCheckedActionFactory.java"/>
+ <exclude name="**/LogStressTest2.java"/>
+ <exclude name="**/MyAccess.java"/>
+ <exclude name="**/Worker.java"/>
+ <exclude name="**/ReaperTestCase2.java"/>
+ <exclude name="**/ReaperTestCase3.java"/>
+ <exclude name="**/BasicCrashRecord.java"/>
+ <exclude name="**/DummyRecoveryModule.java"/>
+ <exclude name="**/CrashAbstractRecord*.java"/>
+ <exclude name="**/RecoveryTransaction.java"/>
+ <exclude name="**/UserDefFirst0Setup.java"/>
+
+ <!-- these ones should work but dont.
+ Need to investigate why -->
+ <exclude name="**/LastResource.java"/>
+ <exclude name="**/CachedTest.java"/>
+ <exclude name="**/JDBCInventory.java"/>
+ <exclude name="**/LogStoreTest2.java"/>
+ <exclude name="**/ActionTestClient.java"/>
+ <exclude name="**/ActionTestServer.java"/>
+ <exclude name="**/CallbackRecoveryTest.java"/>
+ <exclude name="**/DestroyRecoverTest.java"/>
+ <exclude name="**/LogMoveTest.java"/>
+ <exclude name="**/RecoveryLifecycleTest.java"/>
+ <exclude name="**/RecoveryManagerStartStopTest.java"/>
+ <exclude name="**/xidcheck.java"/>
+ </fileset>
+ </tests>
+ </run.tests.macro>
+
+
+
+ <run.tests.macro>
<tests><fileset dir="tests/classes" includes="**/ReaperTestCase.java"/></tests>
</run.tests.macro>
<!--<run.tests.macro>
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/ActionScope.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/ActionScope.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/ActionScope.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,49 +32,21 @@
*/
import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
-public class ActionScope extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class ActionScope
+{
+ @Test
+ public void test() throws Exception
{
- try
- {
- test();
+ AtomicAction atomicAction = new AtomicAction();
- assertSuccess();
- }
- catch (Exception e)
- {
- logInformation("Unexpected exception thrown - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ atomicAction.begin();
+ atomicAction.commit();
-
- System.gc();
-
- System.runFinalization();
+ assertEquals(ActionStatus.COMMITTED, atomicAction.status());
}
-
-private void test () throws Exception
- {
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- A = null;
-
- System.gc();
- }
-
-public static void main(String[] args)
- {
- ActionScope test = new ActionScope();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/BadAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/BadAction.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/BadAction.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,58 +33,24 @@
import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
-import org.jboss.dtf.testframework.unittest.Test;
-public class BadAction extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class BadAction
+{
+ @Test
+ public void test()
{
- try
- {
- AtomicAction A = new AtomicAction();
- AtomicAction B = new AtomicAction();
+ AtomicAction A = new AtomicAction();
+ AtomicAction B = new AtomicAction();
- logInformation("Starting top-level action.");
+ A.begin();
+ B.begin();
- A.begin();
+ A.commit();
+ B.commit();
- logInformation(A.toString());
-
- logInformation("Starting nested action.");
-
- B.begin();
-
- logInformation(B.toString());
-
- logInformation("Committing top-level action. This should fail.");
-
- A.commit();
-
- logInformation("Committing nested action. This should fail.");
-
- B.commit();
-
- BasicAction current = BasicAction.Current();
-
- logInformation("Current action is " + current);
-
- assertSuccess();
- }
- catch (Exception e)
- {
- logInformation("Unexpected Exception - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ BasicAction current = BasicAction.Current();
}
-
-public static void main(String[] args)
- {
- BadAction test = new BadAction();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-
-};
+}
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 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/CheckedActionTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -24,27 +24,24 @@
import com.arjuna.ats.arjuna.common.Environment;
import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class CheckedActionTest
{
- public static void main (String[] args)
+ @Test
+ public void test()
{
- try
- {
- arjPropertyManager.getPropertyManager().setProperty(Environment.CHECKEDACTION_FACTORY, DummyCheckedActionFactory.class.getCanonicalName());
-
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- A.commit();
-
- System.out.println("Test completed "+((success) ? "successfully" : "unsuccessfully"));
- }
- catch (final Exception e)
- {
-
- }
+ arjPropertyManager.getPropertyManager().setProperty(Environment.CHECKEDACTION_FACTORY, DummyCheckedActionFactory.class.getCanonicalName());
+
+ AtomicAction A = new AtomicAction();
+
+ A.begin();
+
+ A.commit();
+
+ assertTrue(success);
}
-
+
public static boolean success = false;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/DummyCheckedActionFactory.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -26,8 +26,8 @@
public class DummyCheckedActionFactory implements CheckedActionFactory
{
- public CheckedAction getCheckedAction (final Uid txId,
- final String actionType)
+ public CheckedAction getCheckedAction(final Uid txId,
+ final String actionType)
{
CheckedActionTest.success = true;
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/LastResource.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/LastResource.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/atomicaction/LastResource.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -36,95 +36,41 @@
import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.LastResourceRecord;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
-import org.jboss.dtf.testframework.unittest.Test;
-public class LastResource extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
- public void run (String[] args)
+public class LastResource
+{
+ @Test
+ public void run()
{
- try
- {
- boolean success = false;
- AtomicAction A = new AtomicAction();
- OnePhase opRes = new OnePhase();
+ AtomicAction A = new AtomicAction();
+ OnePhase opRes = new OnePhase();
- System.err.println("Starting top-level action.");
+ A.begin();
+ A.add(new LastResourceRecord(opRes));
+ A.add(new ShutdownRecord(ShutdownRecord.FAIL_IN_PREPARE));
+ A.commit();
- A.begin();
+ assertEquals(OnePhase.ROLLEDBACK, opRes.status());
- A.add(new LastResourceRecord(opRes));
- A.add(new ShutdownRecord(ShutdownRecord.FAIL_IN_PREPARE));
+ A = new AtomicAction();
+ opRes = new OnePhase();
- A.commit();
+ A.begin();
+ A.add(new LastResourceRecord(opRes));
+ A.add(new ShutdownRecord(ShutdownRecord.FAIL_IN_COMMIT));
+ A.commit();
- if (opRes.status() != OnePhase.COMMITTED)
- {
- System.err.println("Confirmed that one-phase record is last in prepare.");
+ assertEquals(OnePhase.COMMITTED, opRes.status());
- A = new AtomicAction();
- opRes = new OnePhase();
+ A = new AtomicAction();
+ A.begin();
+ A.add(new LastResourceRecord(new OnePhase()));
+
+ assertEquals(AddOutcome.AR_DUPLICATE, A.add(new LastResourceRecord(new OnePhase())) );
- A.begin();
-
- System.err.println("\nStarting new top-level action.");
-
- A.add(new LastResourceRecord(opRes));
- A.add(new ShutdownRecord(ShutdownRecord.FAIL_IN_COMMIT));
-
- A.commit();
-
- if (opRes.status() == OnePhase.COMMITTED)
- {
- System.err.println("Confirmed that one-phase record is first in commit.");
-
- A = new AtomicAction();
-
- A.begin();
-
- A.add(new LastResourceRecord(new OnePhase()));
-
- if (A.add(new LastResourceRecord(new OnePhase())) == AddOutcome.AR_DUPLICATE)
- {
- System.err.println("\nConfirmed that only one such resource can be added.");
-
- assertSuccess();
- }
- else
- {
- System.err.println("\nMultiple such resources can be added!");
-
- assertFailure();
- }
- }
- else
- {
- System.err.println("One-phase record is last in commit!");
-
- assertFailure();
- }
- }
- else
- {
- System.err.println("One-phase record is first in prepare!");
-
- assertFailure();
- }
- }
- catch (Exception e)
- {
- logInformation("Unexpected Exception - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ A.abort();
}
-
- public static void main(String[] args)
- {
- LastResource test = new LastResource();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/PersistenceUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/PersistenceUnitTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/PersistenceUnitTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -20,38 +20,26 @@
*/
package com.hp.mwtests.ts.arjuna.common;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
-import com.arjuna.ats.arjuna.coordinator.Reapable;
-import com.arjuna.ats.arjuna.coordinator.TxControl;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.internal.arjuna.coordinator.ReaperElement;
import com.hp.mwtests.ts.arjuna.resources.BasicObject;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class PersistenceUnitTest extends TestCase
+public class PersistenceUnitTest
{
- public static Test suite ()
+ @Test
+ public void testSaveRestore()
{
- return new TestSuite(PersistenceUnitTest.class);
- }
-
- public void testSaveRestore () throws Exception
- {
final BasicObject obj = new BasicObject();
final Uid objUid = obj.get_uid();
obj.set(1234);
obj.deactivate();
-
+
final BasicObject rec = new BasicObject(objUid);
int res = rec.get();
- assertEquals(res, 1234);
+ assertEquals(1234, res);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TxControlUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TxControlUnitTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/TxControlUnitTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -20,37 +20,26 @@
*/
package com.hp.mwtests.ts.arjuna.common;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
-import com.arjuna.ats.arjuna.coordinator.Reapable;
import com.arjuna.ats.arjuna.coordinator.TxControl;
-import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.internal.arjuna.coordinator.ReaperElement;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class TxControlUnitTest extends TestCase
+public class TxControlUnitTest
{
- public static Test suite ()
+ @Test
+ public void testStartStop() throws Exception
{
- return new TestSuite(TxControlUnitTest.class);
- }
-
- public void testStartStop () throws Exception
- {
TxControl.enable();
-
+
assertTrue(TxControl.isEnabled());
-
+
TxControl.disable(true);
-
+
assertFalse(TxControl.isEnabled());
-
+
TxControl.enable();
-
+
assertTrue(TxControl.isEnabled());
}
}
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 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/destroy/DestroyTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,73 +32,43 @@
package com.hp.mwtests.ts.arjuna.destroy;
import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
import com.hp.mwtests.ts.arjuna.resources.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class DestroyTest extends Test
+public class DestroyTest
{
-
-public void run(String[] args)
+ @Test
+ public void test()
{
- try
- {
- test();
+ for (int i = 0; i < 100; i++) {
+ AtomicAction A = new AtomicAction();
- assertSuccess();
- }
- catch (Exception e)
- {
- logInformation("Unexpected exception thrown - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ A.begin();
- System.gc();
+ BasicObject bo = new BasicObject();
- System.runFinalization();
- }
+ bo.set(2);
-private void test () throws Exception
- {
- for (int i = 0; i < 100; i++)
- {
- AtomicAction A = new AtomicAction();
+ A.commit();
- A.begin();
+ AtomicAction B = new AtomicAction();
- BasicObject bo = new BasicObject();
+ B.begin();
- bo.set(2);
+ bo.destroy();
- A.commit();
+ B.abort();
- AtomicAction B = new AtomicAction();
+ AtomicAction C = new AtomicAction();
- B.begin();
+ C.begin();
- bo.destroy();
+ bo.destroy();
- B.abort();
-
- AtomicAction C = new AtomicAction();
-
- C.begin();
-
- bo.destroy();
-
- C.commit();
- }
+ C.commit();
+ }
}
-
-public static void main(String[] args)
- {
- DestroyTest test = new DestroyTest();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-
}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/exceptions/TestException.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/exceptions/TestException.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/exceptions/TestException.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -1,49 +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: TestException.java 2342 2006-03-30 13:06:17Z $
- */
-
-package com.hp.mwtests.ts.arjuna.exceptions;
-
-import java.lang.Exception;
-
-public class TestException extends Exception
-{
-
-public TestException ()
- {
- super();
- }
-
-public TestException (String s)
- {
- super(s);
- }
-
-}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/file/FileLocking.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/file/FileLocking.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/file/FileLocking.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,10 +31,11 @@
* $Id: FileLocking.java 2342 2006-03-30 13:06:17Z $
*/
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.utils.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.io.*;
import java.io.IOException;
@@ -48,117 +49,78 @@
class FileContender extends Thread
{
-public FileContender (File file, int id, int lmode)
+ public FileContender(File file, int id, int lmode)
{
- _theFile = file;
- _id = id;
- _mode = lmode;
+ _theFile = file;
+ _id = id;
+ _mode = lmode;
}
-public void run ()
+ public void run()
{
- FileLock fileLock = new FileLock(_theFile);
+ FileLock fileLock = new FileLock(_theFile);
- for (int i = 0; i < 100; i++)
- {
- if (fileLock.lock(_mode, false))
- {
- System.out.println("thread "+_id+" locked file.");
+ for (int i = 0; i < 100; i++) {
+ if (fileLock.lock(_mode, false)) {
+ System.out.println("thread " + _id + " locked file.");
- Thread.yield();
+ Thread.yield();
- fileLock.unlock();
+ fileLock.unlock();
- System.out.println("thread "+_id+" unlocked file.");
+ System.out.println("thread " + _id + " unlocked file.");
- Thread.yield();
- }
- else
- {
- System.out.println("thread "+_id+" could not lock file.");
+ Thread.yield();
+ } else {
+ System.out.println("thread " + _id + " could not lock file.");
- Thread.yield();
- }
- }
+ Thread.yield();
+ }
+ }
}
-private File _theFile;
-private int _id;
-private int _mode;
+ private File _theFile;
+ private int _id;
+ private int _mode;
-};
+}
-public class FileLocking extends Test
+public class FileLocking
{
-
-public void run(String[] args)
+ @Test
+ public void test() throws IOException
{
- int lmode = FileLock.F_WRLCK;
+ int lmode = FileLock.F_WRLCK;
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-read") == 0)
- lmode = FileLock.F_RDLCK;
- }
+ /*
+ * Create the file to contend over.
+ */
- /*
- * Create the file to contend over.
- */
+ File theFile = new File("foobar");
+ theFile.deleteOnExit();
- File theFile = new File("foobar");
+ DataOutputStream ofile = new DataOutputStream(new FileOutputStream(theFile));
- try
- {
- DataOutputStream ofile = new DataOutputStream(new FileOutputStream(theFile));
+ ofile.writeInt(0);
- ofile.writeInt(0);
- }
- catch (IOException e)
- {
- logInformation("An error occurred while creating file.");
- e.printStackTrace(System.err);
- assertFailure();
- }
+ /*
+ * Now create the threads.
+ */
- /*
- * Now create the threads.
- */
+ FileContender thread1 = new FileContender(theFile, 1, lmode);
+ FileContender thread2 = new FileContender(theFile, 2, lmode);
- FileContender thread1 = new FileContender(theFile, 1, lmode);
- FileContender thread2 = new FileContender(theFile, 2, lmode);
+ thread1.start();
+ thread2.start();
- thread1.start();
- thread2.start();
-
- try
- {
- thread1.join();
- thread2.join();
-
- logInformation("Test completed successfully.");
-
- assertSuccess();
- }
- catch (InterruptedException e)
- {
- logInformation("Test did not complete successfully.");
- e.printStackTrace(System.err);
- assertFailure();
- }
-
- /*
- * Now tidy up.
- */
-
- theFile.delete();
+ try {
+ thread1.join();
+ thread2.join();
+ }
+ catch (InterruptedException e) {
+ fail("Test did not complete successfully.");
+ }
}
- public static void main(String[] args)
- {
- FileLocking fileTest = new FileLocking();
- fileTest.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
-
- fileTest.run(args);
- }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/JNSTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/JNSTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/JNSTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,42 +32,32 @@
*/
import com.arjuna.ats.arjuna.ArjunaNames;
-import com.arjuna.ats.arjuna.common.*;
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
import com.arjuna.ats.arjuna.gandiva.nameservice.NameService;
+import com.arjuna.common.util.propertyservice.PropertyManager;
import java.io.IOException;
-/*
- * To test:
- *
- * java -DLONG=#5 -DSTRING=^"foobar" com.hp.mwtests.ts.arjuna.naming.JNSTest
- */
+import org.junit.Test;
+import static org.junit.Assert.*;
public class JNSTest
{
-
-public static void main (String[] args)
+ @Test
+ public void test() throws IOException
{
- NameService nameService = new NameService(ArjunaNames.Implementation_NameService_JNS());
+ NameService nameService = new NameService(ArjunaNames.Implementation_NameService_JNS());
+ PropertyManager propertyManager = arjPropertyManager.getPropertyManager();
- try
- {
- String longAttr = new String("LONG");
- long lvalue = nameService.getLongAttribute(null, longAttr);
+ propertyManager.setProperty("TESTOBJ" + "." + "TESTATTR", "#1");
+ long lvalue = nameService.getLongAttribute("TESTOBJ", "TESTATTR");
+ assertEquals(1, lvalue);
- System.out.println("Long value: "+lvalue);
+ propertyManager.setProperty("TESTOBJ" + "." + "TESTATTR", "^StringVal");
+ String svalue = nameService.getStringAttribute("TESTOBJ", "TESTATTR");
- String stringAttr = new String("STRING");
- String svalue = nameService.getStringAttribute(null, stringAttr);
-
- System.out.println("String value: "+svalue);
- }
- catch (IOException e)
- {
- System.out.println(e);
- }
+ assertEquals("StringVal", svalue);
}
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/PNSTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/PNSTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/naming/PNSTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,72 +31,42 @@
* $Id: PNSTest.java 2342 2006-03-30 13:06:17Z $
*/
-import com.arjuna.ats.arjuna.ArjunaNames;
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.gandiva.*;
-import com.arjuna.ats.arjuna.gandiva.nameservice.NameService;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.io.IOException;
public class PNSTest
{
-
-public static void main (String[] args)
+ @Test
+ public void test() throws IOException
{
- try
- {
- String longAttr = new String("LONG");
- String stringAttr = new String("STRING");
- String objAttr = new String("OBJECTNAME");
- String uidAttr = new String("UID");
-
- long l = 12345;
- Uid u = new Uid();
- String s = new String("test");
+ String longAttr = new String("LONG");
+ String stringAttr = new String("STRING");
+ String objAttr = new String("OBJECTNAME");
+ String uidAttr = new String("UID");
- ObjectName o1 = new ObjectName("PNS:o1");
- ObjectName o2 = new ObjectName("PNS:o2");
-
- System.out.println("Adding <string, "+s+"> to o1");
- o1.setStringAttribute(stringAttr, s);
+ long l = 12345;
+ Uid u = new Uid();
+ String s = new String("test");
- System.out.println("\nAdding <long, "+l+"> to o2");
- o2.setLongAttribute(longAttr, l);
-
- System.out.println("Adding <uid, "+u+"> to o2");
- o2.setUidAttribute(uidAttr, u);
+ ObjectName o1 = new ObjectName("PNS:o1");
+ ObjectName o2 = new ObjectName("PNS:o2");
- System.out.println("\nAdding <object name, o2> to o1");
- o1.setObjectNameAttribute(objAttr, o2);
+ o1.setStringAttribute(stringAttr, s);
+ o2.setLongAttribute(longAttr, l);
+ o2.setUidAttribute(uidAttr, u);
+ o1.setObjectNameAttribute(objAttr, o2);
- System.out.println("\nNow extracting string from o1");
- System.out.println("Extracted: "+o1.getStringAttribute(stringAttr));
+ assertEquals(s, o1.getStringAttribute(stringAttr));
+ assertEquals(o2, o1.getObjectNameAttribute(objAttr));
- System.out.println("\nNow extracting object name from o1");
- ObjectName o3 = o1.getObjectNameAttribute(objAttr);
- System.out.println("Extracted: "+o3);
-
- System.out.println("\nNow extracting long from o2");
- System.out.println("Extracted: "+o3.getLongAttribute(longAttr));
-
- System.out.println("\nNow extracting uid from o2");
- Uid id = o3.getUidAttribute(uidAttr);
- System.out.println("Extracted: "+id);
-
- if (id.notEquals(u))
- System.out.println("Uid error.");
-
- ObjectName o4 = ObjectName.uniqueObjectName("PNS");
-
- System.out.println("\nUnique object name: "+o4);
- }
- catch (IOException e)
- {
- System.out.println(e);
- }
+ assertEquals(l, o2.getLongAttribute(longAttr));
+ assertEquals(u, o2.getUidAttribute(uidAttr));
}
-
}
-
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/AllObjUidsTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/AllObjUidsTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/AllObjUidsTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,133 +32,40 @@
package com.hp.mwtests.ts.arjuna.objectstore;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-
import com.arjuna.ats.arjuna.state.*;
-
import com.arjuna.ats.arjuna.common.Uid;
-
import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class AllObjUidsTest extends Test
-{
+import java.io.IOException;
- public void run (String[] args)
+public class AllObjUidsTest
+{
+ @Test
+ public void test() throws IOException, ObjectStoreException
{
- ObjectStore objStore = TxControl.getStore();
- boolean passed = false;
- InputObjectState ios = new InputObjectState();
- String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/ArjunaMSXAAtomicAction";
+ ObjectStore objStore = TxControl.getStore();
+ String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/DummyAtomicAction";
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-help"))
- {
- System.err.println("Usage: [-help] [-type <type name>]");
+ InputObjectState ios = new InputObjectState();
+ objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN);
+ Uid uid = new Uid();
+ uid.unpack(ios);
+ assertEquals(Uid.nullUid(), uid);
- System.exit(0);
- }
+ ios = new InputObjectState();
+ objStore.allObjUids(type, ios, ObjectStore.OS_COMMITTED);
+ uid = new Uid();
+ uid.unpack(ios);
+ assertEquals(Uid.nullUid(), uid);
- if (args[i].equals("-type"))
- {
- type = args[i+1];
-
- objStore = new ObjectStore();
- }
- }
-
- try
- {
- if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
- {
- Uid id = new Uid(Uid.nullUid());
-
- do
- {
- try
- {
- id.unpack(ios);
- }
- catch (Exception ex)
- {
- id = Uid.nullUid();
- }
-
- if (id.notEquals(Uid.nullUid()))
- System.err.println("Got UNKNOWN "+id);
-
- passed = true;
-
- } while (id.notEquals(Uid.nullUid()));
- }
-
- System.err.println("\n");
-
- if (objStore.allObjUids(type, ios, ObjectStore.OS_COMMITTED))
- {
- Uid id = new Uid(Uid.nullUid());
-
- do
- {
- try
- {
- id.unpack(ios);
- }
- catch (Exception ex)
- {
- id = Uid.nullUid();
- }
-
- if (id.notEquals(Uid.nullUid()))
- System.err.println("Got COMMITTED "+id);
-
- passed = true;
-
- } while (id.notEquals(Uid.nullUid()));
- }
-
- System.err.println("\n");
-
- if (objStore.allObjUids(type, ios, ObjectStore.OS_UNCOMMITTED))
- {
- Uid id = new Uid(Uid.nullUid());
-
- do
- {
- try
- {
- id.unpack(ios);
- }
- catch (Exception ex)
- {
- id = Uid.nullUid();
- }
-
- if (id.notEquals(Uid.nullUid()))
- System.err.println("Got UNCOMMITTED "+id);
-
- passed = true;
-
- } while (id.notEquals(Uid.nullUid()));
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
-
- if (passed)
- assertSuccess();
- else
- assertFailure();
+ ios = new InputObjectState();
+ objStore.allObjUids(type, ios, ObjectStore.OS_UNCOMMITTED);
+ uid = new Uid();
+ uid.unpack(ios);
+ assertEquals(Uid.nullUid(), uid);
}
-
- public static void main(String[] args)
- {
- AllObjUidsTest test = new AllObjUidsTest();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/CachedTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,63 +33,50 @@
import com.arjuna.ats.arjuna.ArjunaNames;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.common.*;
-import java.io.*;
-
import java.util.*;
-import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-
class ThreadWriter extends Thread
{
private static final String TYPE = "test";
- public ThreadWriter (ObjectStore theStore)
+ public ThreadWriter(ObjectStore theStore)
{
- store = theStore;
+ store = theStore;
}
- public void run ()
+ public void run()
{
- byte[] data = new byte[1024];
- OutputObjectState state = new OutputObjectState(new Uid(), "type");
- Uid u = new Uid();
+ byte[] data = new byte[1024];
+ OutputObjectState state = new OutputObjectState(new Uid(), "type");
+ Uid u = new Uid();
- try
- {
- state.packBytes(data);
+ try {
+ state.packBytes(data);
- if (store.write_committed(u, TYPE, state))
- {
- Thread.yield();
+ if (store.write_committed(u, TYPE, state)) {
+ Thread.yield();
- InputObjectState s = store.read_committed(u, TYPE);
+ InputObjectState s = store.read_committed(u, TYPE);
- Thread.yield();
+ Thread.yield();
- if (s != null)
- {
- if (store.remove_committed(u, TYPE))
- passed = true;
- else
- System.err.println("Could not remove state.");
- }
- else
- System.err.println("Could not read state.");
- }
- else
- System.err.println("Could not write state.");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
+ if (s != null) {
+ if (store.remove_committed(u, TYPE))
+ passed = true;
+ }
+ }
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ System.out.println(passed);
}
public boolean passed = false;
@@ -101,88 +88,37 @@
public class CachedTest
{
- public static void main (String[] args)
+ @Test
+ public void test() throws Exception
{
- boolean passed = true;
- String cacheSize = "2048";
- int threads = 100;
+ String cacheSize = "2048";
+ int threads = 100;
+ Thread[] t = new Thread[threads];
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-size"))
- cacheSize = args[i+1];
- if (args[i].equals("-threads"))
- {
- try
- {
- threads = Integer.parseInt(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- if (args[i].equals("-help"))
- {
- System.err.println("Usage: [-size <cache size>] [-threads <number>]");
+ System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
- System.exit(0);
- }
- }
+ ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
- Thread[] t = new Thread[threads];
+ long stime = Calendar.getInstance().getTime().getTime();
- System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
+ for (int i = 0; i < threads; i++) {
+ System.out.println("i: "+i);
+ t[i] = new ThreadWriter(store);
+ t[i].start();
+ }
- ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
+ for (int j = 0; j < threads; j++) {
+ System.out.println("j: "+j);
+ t[j].join();
+ assertTrue(((ThreadWriter) t[j]).passed);
+ }
- long stime = Calendar.getInstance().getTime().getTime();
+ long ftime = Calendar.getInstance().getTime().getTime();
+ long timeTaken = ftime - stime;
- for (int i = 0; (i < threads) && passed; i++)
- {
- try
- {
- t[i] = new ThreadWriter(store);
+ store.sync();
- t[i].start();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
-
- passed = false;
- }
- }
-
- for (int j = 0; j < threads; j++)
- {
- try
- {
- t[j].join();
-
- passed = passed && ((ThreadWriter) t[j]).passed;
- }
- catch (Exception ex)
- {
- }
- }
-
- long ftime = Calendar.getInstance().getTime().getTime();
- long timeTaken = ftime - stime;
-
- try
- {
- store.sync();
- }
- catch (Exception ex)
- {
- }
-
- System.out.println("time for "+threads+" users is "+timeTaken);
-
- if (passed)
- System.out.println("Passed.");
- else
- System.out.println("Failed.");
+ System.out.println("time for " + threads + " users is " + timeTaken);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/JDBCInventory.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/JDBCInventory.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/JDBCInventory.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -36,36 +36,20 @@
import com.arjuna.ats.arjuna.common.arjPropertyManager;
import com.arjuna.ats.arjuna.objectstore.ObjectStoreImple;
import com.arjuna.ats.arjuna.gandiva.inventory.Inventory;
-import org.jboss.dtf.testframework.unittest.Test;
-public class JDBCInventory extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class JDBCInventory
+{
+ @Test
+ public void test()
{
- arjPropertyManager.getPropertyManager().setProperty(Environment.STATIC_INVENTORY_IMPLE+"1", "com.arjuna.ats.internal.arjuna.objectstore.JDBCStoreSetup");
- arjPropertyManager.getPropertyManager().setProperty(Environment.JDBC_USER_DB_ACCESS, "com.hp.mwtests.ts.arjuna.objectstore.MyAccess");
+ arjPropertyManager.getPropertyManager().setProperty(Environment.STATIC_INVENTORY_IMPLE + "1", "com.arjuna.ats.internal.arjuna.objectstore.JDBCStoreSetup");
+ arjPropertyManager.getPropertyManager().setProperty(Environment.JDBC_USER_DB_ACCESS, "com.hp.mwtests.ts.arjuna.objectstore.MyAccess");
- ObjectStoreImple os = (ObjectStoreImple) Inventory.inventory().createVoid(ArjunaNames.Implementation_ObjectStore_JDBCStore());
+ ObjectStoreImple os = (ObjectStoreImple) Inventory.inventory().createVoid(ArjunaNames.Implementation_ObjectStore_JDBCStore());
- if (os != null)
- {
- logInformation("\nPassed.");
- assertSuccess();
- }
- else
- {
- Inventory.inventory().printList(System.out);
-
- logInformation("\nFailed.");
- assertFailure();
- }
+ assertNotNull(os);
}
-
-public static void main(String[] args)
- {
- JDBCInventory test = new JDBCInventory();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -39,29 +39,32 @@
import com.arjuna.ats.arjuna.recovery.RecoverAtomicAction;
import com.hp.mwtests.ts.arjuna.resources.BasicRecord;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LogStoreReactivationTest
{
+ @Test
+ public void test()
+ {
+ System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_SYNC_REMOVAL, "false");
+ System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
- public static void main (String[] args)
- {
- System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_SYNC_REMOVAL, "false");
- System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
-
- AtomicAction A = new AtomicAction();
- Uid txId = A.get_uid();
-
- System.err.println("IMPORTANT: ignore warnings about USER_DEF_FIRST0 as they are expected due to BasicRecord usage!");
-
- A.begin();
+ AtomicAction A = new AtomicAction();
+ Uid txId = A.get_uid();
- A.add(new BasicRecord());
+ System.err.println("IMPORTANT: ignore warnings about USER_DEF_FIRST0 as they are expected due to BasicRecord usage!");
- A.commit();
-
- RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
-
- rAA.replayPhase2();
- }
+ A.begin();
+
+ A.add(new BasicRecord());
+
+ A.commit();
+
+ RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
+
+ rAA.replayPhase2();
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreReactivationTest2.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -39,29 +39,32 @@
import com.arjuna.ats.arjuna.recovery.RecoverAtomicAction;
import com.hp.mwtests.ts.arjuna.resources.BasicRecord;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LogStoreReactivationTest2
{
+ @Test
+ public void test()
+ {
+ System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_SYNC_REMOVAL, "true");
+ System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
- public static void main (String[] args)
- {
- System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_SYNC_REMOVAL, "true");
- System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
-
- AtomicAction A = new AtomicAction();
- Uid txId = A.get_uid();
-
- System.err.println("IMPORTANT: if there are warnings about USER_DEF_FIRST0 then the test has failed!");
-
- A.begin();
+ AtomicAction A = new AtomicAction();
+ Uid txId = A.get_uid();
- A.add(new BasicRecord());
+ System.err.println("IMPORTANT: if there are warnings about USER_DEF_FIRST0 then the test has failed!");
- A.commit();
-
- RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
-
- rAA.replayPhase2();
- }
+ A.begin();
+
+ A.add(new BasicRecord());
+
+ A.commit();
+
+ RecoverAtomicAction rAA = new RecoverAtomicAction(txId, ActionStatus.COMMITTED);
+
+ rAA.replayPhase2();
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -38,134 +38,118 @@
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.coordinator.TxControl;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LogStoreRecoveryTest
{
- public static void main (String[] args)
- {
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
-
- ObjectStore objStore = TxControl.getStore();
- final int numberOfTransactions = 1000;
- final Uid[] ids = new Uid[numberOfTransactions];
- final int fakeData = 0xdeedbaaf;
- final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/LogStoreRecoveryTest";
-
- for (int i = 0; i < numberOfTransactions; i++)
- {
- OutputObjectState dummyState = new OutputObjectState();
-
- try
- {
- dummyState.packInt(fakeData);
- ids[i] = new Uid();
- objStore.write_committed(ids[i], type, dummyState);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- /*
- * Remove 50% of the entries, simulating a crash during
- * normal execution.
- *
- * Q: why not just write 50% in the first place?
- * A: because we will extend this test to allow the recovery
- * system to run in between writing and removing.
- */
-
- for (int i = 0; i < numberOfTransactions / 2; i++)
- {
- try
- {
- objStore.remove_committed(ids[i], type);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- try
- {
- /*
- * Give the purger thread a chance to run and delete
- * the entries we've "removed" (really only marked as
- * being removable.)
- */
-
- Thread.sleep(12000);
- }
- catch (final Exception ex)
- {
- }
-
- /*
- * Now get a list of entries to work on.
- */
-
- InputObjectState ios = new InputObjectState();
- boolean passed = true;
-
- try
- {
- if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
- {
- Uid id = new Uid(Uid.nullUid());
- int numberOfEntries = 0;
-
- do
- {
- try
- {
- id.unpack(ios);
- }
- catch (Exception ex)
- {
- id = Uid.nullUid();
- }
+ @Test
+ public void test()
+ {
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
- if (id.notEquals(Uid.nullUid()))
- {
- numberOfEntries++;
-
- boolean found = false;
-
- for (int i = 0; i < ids.length; i++)
- {
- if (id.equals(ids[i]))
- found = true;
- }
-
- if (passed && !found)
- {
- passed = false;
+ ObjectStore objStore = TxControl.getStore();
+ final int numberOfTransactions = 1000;
+ final Uid[] ids = new Uid[numberOfTransactions];
+ final int fakeData = 0xdeedbaaf;
+ final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/LogStoreRecoveryTest";
- System.err.println("Found unexpected transaction!");
- }
- }
- }
- while (id.notEquals(Uid.nullUid()));
-
- if ((numberOfEntries == numberOfTransactions / 2) && passed)
- {
- System.err.println("Would attempt recovery on "+numberOfEntries+" dead transactions.");
- }
- else
- {
- passed = false;
+ for (int i = 0; i < numberOfTransactions; i++) {
+ OutputObjectState dummyState = new OutputObjectState();
- System.err.println("Expected "+(numberOfTransactions / 2)+" and got "+numberOfEntries);
- }
- }
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
-
- System.err.println("Test "+((passed) ? "passed" : "failed"));
- }
+ try {
+ dummyState.packInt(fakeData);
+ ids[i] = new Uid();
+ objStore.write_committed(ids[i], type, dummyState);
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /*
+ * Remove 50% of the entries, simulating a crash during
+ * normal execution.
+ *
+ * Q: why not just write 50% in the first place?
+ * A: because we will extend this test to allow the recovery
+ * system to run in between writing and removing.
+ */
+
+ for (int i = 0; i < numberOfTransactions / 2; i++) {
+ try {
+ objStore.remove_committed(ids[i], type);
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ try {
+ /*
+ * Give the purger thread a chance to run and delete
+ * the entries we've "removed" (really only marked as
+ * being removable.)
+ */
+
+ Thread.sleep(12000);
+ }
+ catch (final Exception ex) {
+ }
+
+ /*
+ * Now get a list of entries to work on.
+ */
+
+ InputObjectState ios = new InputObjectState();
+ boolean passed = true;
+
+ try {
+ if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN)) {
+ Uid id = new Uid(Uid.nullUid());
+ int numberOfEntries = 0;
+
+ do {
+ try {
+ id.unpack(ios);
+ }
+ catch (Exception ex) {
+ id = Uid.nullUid();
+ }
+
+ if (id.notEquals(Uid.nullUid())) {
+ numberOfEntries++;
+
+ boolean found = false;
+
+ for (int i = 0; i < ids.length; i++) {
+ if (id.equals(ids[i]))
+ found = true;
+ }
+
+ if (passed && !found) {
+ passed = false;
+
+ System.err.println("Found unexpected transaction!");
+ }
+ }
+ }
+ while (id.notEquals(Uid.nullUid()));
+
+ if ((numberOfEntries == numberOfTransactions / 2) && passed) {
+ System.err.println("Would attempt recovery on " + numberOfEntries + " dead transactions.");
+ } else {
+ passed = false;
+
+ System.err.println("Expected " + (numberOfTransactions / 2) + " and got " + numberOfEntries);
+ }
+ }
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+
+ assertTrue(passed);
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest2.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -38,81 +38,76 @@
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
class TestWorker extends Thread
{
+ public TestWorker(int iters)
+ {
+ _iters = iters;
+ }
- public TestWorker (int iters)
- {
- _iters = iters;
- }
+ public void run()
+ {
+ for (int i = 0; i < _iters; i++) {
+ try {
+ AtomicAction A = new AtomicAction();
- public void run ()
- {
- for (int i = 0; i < _iters; i++)
- {
- try
- {
- AtomicAction A = new AtomicAction();
+ A.begin();
- A.begin();
+ A.add(new BasicRecord());
- A.add(new BasicRecord());
+ A.commit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
- A.commit();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- Thread.yield();
- }
- }
+ Thread.yield();
+ }
+ }
- private int _iters;
+ private int _iters;
}
public class LogStoreRecoveryTest2
{
+ @Test
+ public void test()
+ {
+ int threads = 10;
+ int work = 100;
- public static void main (String[] args)
- {
- int threads = 10;
- int work = 100;
-
- System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_SYNC_REMOVAL, "false");
- System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
+ System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_SYNC_REMOVAL, "false");
+ System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "1000000"); // essentially infinite
- TestWorker[] workers = new TestWorker[threads];
+ TestWorker[] workers = new TestWorker[threads];
- for (int i = 0; i < threads; i++)
- {
- workers[i] = new TestWorker(work);
+ for (int i = 0; i < threads; i++) {
+ workers[i] = new TestWorker(work);
- workers[i].start();
- }
-
- for (int j = 0; j < threads; j++)
- {
- try
- {
- workers[j].join();
- System.err.println("**terminated "+j);
- }
- catch (final Exception ex)
- {
- }
- }
+ workers[i].start();
+ }
- /*
- * Now have a log that hasn't been deleted. Run recovery and see
- * what happens!
- */
-
- RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
-
- manager.scan();
- }
+ for (int j = 0; j < threads; j++) {
+ try {
+ workers[j].join();
+ System.err.println("**terminated " + j);
+ }
+ catch (final Exception ex) {
+ }
+ }
+
+ /*
+ * Now have a log that hasn't been deleted. Run recovery and see
+ * what happens!
+ */
+
+ RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
+
+ manager.scan();
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -38,94 +38,85 @@
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.coordinator.TxControl;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LogStoreTest
{
- public static void main (String[] args)
- {
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
-
- ObjectStore objStore = TxControl.getStore();
- final int numberOfTransactions = 1000;
- final Uid[] ids = new Uid[numberOfTransactions];
- final int fakeData = 0xdeedbaaf;
- final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/Test";
-
- for (int i = 0; i < numberOfTransactions; i++)
- {
- OutputObjectState dummyState = new OutputObjectState();
-
- try
- {
- dummyState.packInt(fakeData);
- ids[i] = new Uid();
- objStore.write_committed(ids[i], type, dummyState);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- InputObjectState ios = new InputObjectState();
- boolean passed = false;
-
- try
- {
- if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
- {
- Uid id = new Uid(Uid.nullUid());
- int numberOfEntries = 0;
-
- do
- {
- try
- {
- id.unpack(ios);
- }
- catch (Exception ex)
- {
- id = Uid.nullUid();
- }
+ @Test
+ public void test()
+ {
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- if (id.notEquals(Uid.nullUid()))
- {
- passed = true;
-
- System.err.println("Located transaction log "+id+" in object store.");
-
- numberOfEntries++;
-
- boolean found = false;
-
- for (int i = 0; i < ids.length; i++)
- {
- if (id.equals(ids[i]))
- found = true;
- }
-
- if (passed && !found)
- {
- passed = false;
+ ObjectStore objStore = TxControl.getStore();
+ final int numberOfTransactions = 1000;
+ final Uid[] ids = new Uid[numberOfTransactions];
+ final int fakeData = 0xdeedbaaf;
+ final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/Test";
- System.err.println("Found unexpected transaction!");
- }
- }
- }
- while (id.notEquals(Uid.nullUid()));
-
- if ((numberOfEntries != ids.length) && passed)
- {
- passed = false;
-
- System.err.println("Expected "+ids.length+" and got "+numberOfEntries);
- }
- }
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
-
- System.err.println("Test "+((passed) ? "passed" : "failed"));
- }
+ for (int i = 0; i < numberOfTransactions; i++) {
+ OutputObjectState dummyState = new OutputObjectState();
+
+ try {
+ dummyState.packInt(fakeData);
+ ids[i] = new Uid();
+ objStore.write_committed(ids[i], type, dummyState);
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ InputObjectState ios = new InputObjectState();
+ boolean passed = false;
+
+ try {
+ if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN)) {
+ Uid id = new Uid(Uid.nullUid());
+ int numberOfEntries = 0;
+
+ do {
+ try {
+ id.unpack(ios);
+ }
+ catch (Exception ex) {
+ id = Uid.nullUid();
+ }
+
+ if (id.notEquals(Uid.nullUid())) {
+ passed = true;
+
+ System.err.println("Located transaction log " + id + " in object store.");
+
+ numberOfEntries++;
+
+ boolean found = false;
+
+ for (int i = 0; i < ids.length; i++) {
+ if (id.equals(ids[i]))
+ found = true;
+ }
+
+ if (passed && !found) {
+ passed = false;
+
+ System.err.println("Found unexpected transaction!");
+ }
+ }
+ }
+ while (id.notEquals(Uid.nullUid()));
+
+ if ((numberOfEntries != ids.length) && passed) {
+ passed = false;
+
+ System.err.println("Expected " + ids.length + " and got " + numberOfEntries);
+ }
+ }
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+
+ assertTrue(passed);
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreTest2.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -38,125 +38,109 @@
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.coordinator.TxControl;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LogStoreTest2
{
- public static void main (String[] args)
- {
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
-
- ObjectStore objStore = TxControl.getStore();
- final int numberOfTransactions = 1000;
- final Uid[] ids = new Uid[numberOfTransactions];
- final int fakeData = 0xdeedbaaf;
- final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/Test";
-
- for (int i = 0; i < numberOfTransactions; i++)
- {
- OutputObjectState dummyState = new OutputObjectState();
-
- try
- {
- dummyState.packInt(fakeData);
- ids[i] = new Uid();
- objStore.write_committed(ids[i], type, dummyState);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- try
- {
- objStore.remove_committed(ids[0], type);
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
-
- try
- {
- /*
- * Give the purger thread a chance to run and delete
- * the entry.
- */
-
- Thread.sleep(12000);
- }
- catch (final Exception ex)
- {
- }
-
- InputObjectState ios = new InputObjectState();
- boolean passed = false;
-
- try
- {
- if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN))
- {
- Uid id = new Uid(Uid.nullUid());
- int numberOfEntries = 0;
-
- do
- {
- try
- {
- id.unpack(ios);
- }
- catch (Exception ex)
- {
- id = Uid.nullUid();
- }
+ @Test
+ public void test()
+ {
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
- if (id.notEquals(Uid.nullUid()))
- {
- passed = true;
-
- numberOfEntries++;
-
- boolean found = false;
-
- for (int i = 0; i < ids.length; i++)
- {
- if (id.equals(ids[i]))
- found = true;
- }
-
- if (passed && !found)
- {
- passed = false;
+ ObjectStore objStore = TxControl.getStore();
+ final int numberOfTransactions = 1000;
+ final Uid[] ids = new Uid[numberOfTransactions];
+ final int fakeData = 0xdeedbaaf;
+ final String type = "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction/Test";
- System.err.println("Found unexpected transaction!");
- }
- }
- }
- while (id.notEquals(Uid.nullUid()));
-
- if ((numberOfEntries == ids.length -1) && passed)
- {
- if (objStore.currentState(ids[0], type) != ObjectStore.OS_UNKNOWN)
- passed = false;
- else
- {
- if (objStore.currentState(ids[1], type) != ObjectStore.OS_COMMITTED)
- passed = false;
- }
- }
- else
- {
- passed = false;
+ for (int i = 0; i < numberOfTransactions; i++) {
+ OutputObjectState dummyState = new OutputObjectState();
- System.err.println("Expected "+ids.length+" and got "+numberOfEntries);
- }
- }
- }
- catch (final Exception ex)
- {
- ex.printStackTrace();
- }
-
- System.err.println("Test "+((passed) ? "passed" : "failed"));
- }
+ try {
+ dummyState.packInt(fakeData);
+ ids[i] = new Uid();
+ objStore.write_committed(ids[i], type, dummyState);
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ try {
+ objStore.remove_committed(ids[0], type);
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+
+ try {
+ /*
+ * Give the purger thread a chance to run and delete
+ * the entry.
+ */
+
+ Thread.sleep(12000);
+ }
+ catch (final Exception ex) {
+ }
+
+ InputObjectState ios = new InputObjectState();
+ boolean passed = false;
+
+ try {
+ if (objStore.allObjUids(type, ios, ObjectStore.OS_UNKNOWN)) {
+ Uid id = new Uid(Uid.nullUid());
+ int numberOfEntries = 0;
+
+ do {
+ try {
+ id.unpack(ios);
+ }
+ catch (Exception ex) {
+ id = Uid.nullUid();
+ }
+
+ if (id.notEquals(Uid.nullUid())) {
+ passed = true;
+
+ numberOfEntries++;
+
+ boolean found = false;
+
+ for (int i = 0; i < ids.length; i++) {
+ if (id.equals(ids[i]))
+ found = true;
+ }
+
+ if (passed && !found) {
+ passed = false;
+
+ System.err.println("Found unexpected transaction!");
+ }
+ }
+ }
+ while (id.notEquals(Uid.nullUid()));
+
+ if ((numberOfEntries == ids.length - 1) && passed) {
+ if (objStore.currentState(ids[0], type) != ObjectStore.OS_UNKNOWN)
+ passed = false;
+ else {
+ if (objStore.currentState(ids[1], type) != ObjectStore.OS_COMMITTED)
+ passed = false;
+ }
+ } else {
+ passed = false;
+
+ System.err.println("Expected " + ids.length + " and got " + numberOfEntries);
+ }
+ }
+ }
+ catch (final Exception ex) {
+ ex.printStackTrace();
+ }
+
+ assertTrue(passed);
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -40,132 +40,88 @@
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
import com.arjuna.ats.arjuna.state.InputObjectState;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
class StressWorker extends Thread
{
+ public StressWorker(int iters, int thread)
+ {
+ _iters = iters;
+ _thread = thread;
+ }
- public StressWorker (int iters, int thread)
- {
- _iters = iters;
- _thread = thread;
- }
+ public void run()
+ {
+ for (int i = 0; i < _iters; i++) {
+ try {
+ AtomicAction A = new AtomicAction();
- public void run ()
- {
- for (int i = 0; i < _iters; i++)
- {
- try
- {
- AtomicAction A = new AtomicAction();
+ A.begin();
- A.begin();
+ A.add(new BasicRecord());
- A.add(new BasicRecord());
+ A.commit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
- A.commit();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
-
- Thread.yield();
- }
- }
+ Thread.yield();
+ }
+ }
- private int _iters;
- private int _thread;
+ private int _iters;
+ private int _thread;
}
public class LogStressTest
{
+ @Test
+ public void test()
+ {
+ int threads = 10;
+ int work = 100;
- public static void main (String[] args)
- {
- int threads = 10;
- int work = 100;
+ System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
- System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_PURGE_TIME, "10000");
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-threads") == 0)
- {
- try
- {
- Integer v = new Integer(args[i + 1]);
+ StressWorker[] workers = new StressWorker[threads];
- threads = v.intValue();
- }
- catch (Exception e)
- {
- System.err.println(e);
- }
- }
- if (args[i].compareTo("-work") == 0)
- {
- try
- {
- Integer v = new Integer(args[i + 1]);
+ for (int i = 0; i < threads; i++) {
+ workers[i] = new StressWorker(work, i);
- work = v.intValue();
- }
- catch (Exception e)
- {
- System.err.println(e);
- }
- }
- if (args[i].compareTo("-help") == 0)
- {
- System.out
- .println("Usage: LogStressTest [-help] [-threads <number>] [-work <number>]");
- System.exit(0);
- }
- }
+ workers[i].start();
+ }
- StressWorker[] workers = new StressWorker[threads];
+ for (int j = 0; j < threads; j++) {
+ try {
+ workers[j].join();
+ }
+ catch (final Exception ex) {
+ }
+ }
- for (int i = 0; i < threads; i++)
- {
- workers[i] = new StressWorker(work, i);
+ InputObjectState ios = new InputObjectState();
+ boolean passed = false;
- workers[i].start();
- }
-
- for (int j = 0; j < threads; j++)
- {
- try
- {
- workers[j].join();
- }
- catch (final Exception ex)
- {
- }
- }
+ try {
+ TxControl.getStore().allObjUids(new AtomicAction().type(), ios, ObjectStore.OS_UNKNOWN);
- InputObjectState ios = new InputObjectState();
- boolean passed = false;
-
- try
- {
- TxControl.getStore().allObjUids(new AtomicAction().type(), ios, ObjectStore.OS_UNKNOWN);
-
- Uid tempUid = new Uid(Uid.nullUid());
+ Uid tempUid = new Uid(Uid.nullUid());
- tempUid.unpack(ios);
-
- // there should be no entries left
-
- if (tempUid.equals(Uid.nullUid()))
- {
- passed = true;
- }
- }
- catch (final Exception ex)
- {
- }
-
- System.err.println("Test "+((passed) ? "passed" : "failed"));
- }
+ tempUid.unpack(ios);
+
+ // there should be no entries left
+
+ if (tempUid.equals(Uid.nullUid())) {
+ passed = true;
+ }
+ }
+ catch (final Exception ex) {
+ }
+
+ assertTrue(passed);
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStressTest2.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -36,6 +36,9 @@
import com.arjuna.ats.arjuna.common.*;
import com.hp.mwtests.ts.arjuna.resources.BasicRecord;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
/*
* Run with the log store for N hours and make sure there are
* no logs left at the end.
@@ -43,62 +46,36 @@
public class LogStressTest2
{
+ @Test
+ public void test()
+ {
+ System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
+ System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
+ System.setProperty(Environment.TRANSACTION_LOG_SIZE, "10000");
- public static void main (String[] args)
- {
- System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
- System.setProperty(Environment.OBJECTSTORE_TYPE, ArjunaNames.Implementation_ObjectStore_ActionLogStore().stringForm());
- System.setProperty(Environment.TRANSACTION_LOG_SIZE, "10000");
-
- int timeLimit = 4; // hours
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-time") == 0)
- {
- try
- {
- Integer v = new Integer(args[i + 1]);
+ int timeLimit = 4; // hours
- timeLimit = v.intValue();
- }
- catch (Exception e)
- {
- System.err.println(e);
- }
- }
- if (args[i].compareTo("-help") == 0)
- {
- System.out
- .println("Usage: LogStressTest2 [-help] [-time <hours>]");
- System.exit(0);
- }
- }
+ System.err.println("WARNING: this test will run for " + timeLimit + " hours.");
- System.err.println("WARNING: this test will run for "+timeLimit+" hours.");
-
- final long stime = System.currentTimeMillis();
- final long endTime = timeLimit * 60 * 60 * 1000;
- long ftime;
-
- do
- {
- try
- {
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- A.add(new BasicRecord());
-
- A.commit();
- }
- catch (final Exception ex)
- {
- }
-
- ftime = System.currentTimeMillis();
-
- } while ((ftime - stime) < endTime);
- }
+ final long stime = System.currentTimeMillis();
+ final long endTime = timeLimit * 60 * 60 * 1000;
+ long ftime;
+
+ do {
+ try {
+ AtomicAction A = new AtomicAction();
+
+ A.begin();
+
+ A.add(new BasicRecord());
+
+ A.commit();
+ }
+ catch (final Exception ex) {
+ }
+
+ ftime = System.currentTimeMillis();
+
+ } while ((ftime - stime) < endTime);
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/MyAccess.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/MyAccess.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/MyAccess.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -38,27 +38,27 @@
public class MyAccess implements com.arjuna.ats.arjuna.objectstore.jdbc.JDBCAccess
{
- public Connection getConnection () throws SQLException
+ public Connection getConnection() throws SQLException
{
- return null;
+ return null;
}
-
- public void putConnection (Connection conn)
+
+ public void putConnection(Connection conn)
{
}
- public String tableName ()
+ public String tableName()
{
- return null;
+ return null;
}
- public boolean dropTable ()
+ public boolean dropTable()
{
- return false;
+ return false;
}
- public void initialise (ObjectName objName)
+ public void initialise(ObjectName objName)
{
}
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/ObjectStoreTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -36,94 +36,63 @@
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
import com.arjuna.ats.arjuna.gandiva.ObjectName;
import com.arjuna.ats.arjuna.gandiva.ClassName;
-import org.jboss.dtf.testframework.unittest.Test;
-public class ObjectStoreTest extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+import java.io.IOException;
+
+public class ObjectStoreTest
+{
+ @Test
+ public void test() throws IOException
{
- ClassName imple = ArjunaNames.Implementation_ObjectStore_defaultStore();
- String localOSRoot = "foo";
- String objectStoreDir = "/bar";
- String shareStatus = "OS_SHARED";
+ ClassName imple = ArjunaNames.Implementation_ObjectStore_defaultStore();
+ String localOSRoot = "foo";
+ String objectStoreDir = "/bar";
+ String shareStatus = "OS_SHARED";
- ObjectName objName = new ObjectName("JNS:myname");
+ ObjectName objName = new ObjectName("JNS:myname");
- try
- {
- objName.setClassNameAttribute(Environment.OBJECTSTORE_TYPE, imple);
- objName.setStringAttribute(Environment.LOCALOSROOT, localOSRoot);
- objName.setStringAttribute(Environment.OBJECTSTORE_DIR, objectStoreDir);
- objName.setStringAttribute(Environment.OBJECTSTORE_SHARE, shareStatus);
- }
- catch (Exception e)
- {
- e.printStackTrace(System.err);
- assertFailure();
- }
+ objName.setClassNameAttribute(Environment.OBJECTSTORE_TYPE, imple);
+ objName.setStringAttribute(Environment.LOCALOSROOT, localOSRoot);
+ objName.setStringAttribute(Environment.OBJECTSTORE_DIR, objectStoreDir);
+ objName.setStringAttribute(Environment.OBJECTSTORE_SHARE, shareStatus);
- ObjectStore objStore = new ObjectStore(objName);
+ ObjectStore objStore = new ObjectStore(objName);
- System.out.println("\nchecking assumed valid store.");
+ assertTrue(validate(objStore));
- boolean passed = validate(objStore);
- if (passed)
- {
- // check with a known invalid implementation
-
- objStore = new ObjectStore();
-
- System.out.println("\nchecking known invalid store.");
-
- if (validate(objStore))
- passed = false;
- }
-
- if (passed)
- assertSuccess();
- else
- assertFailure();
+ // check with a known invalid implementation
+ objStore = new ObjectStore();
+ assertFalse(validate(objStore));
}
-private static final boolean validate (ObjectStore objStore)
+ private static final boolean validate(ObjectStore objStore)
{
- boolean passed = false;
+ boolean passed = false;
- if (objStore.className().equals(imple))
- {
- if (objStore.shareState() == ObjectStore.OS_SHARED)
- {
- if (objStore.storeDir().equals(objectStoreDir))
- {
- if (objStore.storeRoot().equals(localOSRoot))
- passed = true;
- else
- System.err.println("ObjectStore root wrong: "+objStore.storeRoot());
- }
- else
- System.err.println("ObjectStore dir wrong: "+objStore.storeDir());
- }
- else
- System.err.println("Share state wrong: "+objStore.shareState());
- }
- else
- System.err.println("Implementation wrong: "+objStore.className());
+ if (objStore.className().equals(imple)) {
+ if (objStore.shareState() == ObjectStore.OS_SHARED) {
+ if (objStore.storeDir().equals(objectStoreDir)) {
+ if (objStore.storeRoot().equals(localOSRoot))
+ passed = true;
+ else
+ System.err.println("ObjectStore root wrong: " + objStore.storeRoot());
+ } else
+ System.err.println("ObjectStore dir wrong: " + objStore.storeDir());
+ } else
+ System.err.println("Share state wrong: " + objStore.shareState());
+ } else
+ System.err.println("Implementation wrong: " + objStore.className());
- return passed;
+ return passed;
}
-public static void main(String[] args)
- {
- ObjectStoreTest test = new ObjectStoreTest();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
+ private static ClassName imple = ArjunaNames.Implementation_ObjectStore_defaultStore();
+ private static String localOSRoot = "foo";
+ private static String objectStoreDir = "/bar";
+ private static String shareStatus = "OS_SHARED";
-private static ClassName imple = ArjunaNames.Implementation_ObjectStore_defaultStore();
-private static String localOSRoot = "foo";
-private static String objectStoreDir = "/bar";
-private static String shareStatus = "OS_SHARED";
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/PersistenceTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -43,98 +43,67 @@
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class PersistenceTest extends Test
+public class PersistenceTest
{
-
- public void run(String[] args)
+ @Test
+ public void test()
{
- boolean passed = false;
- boolean threaded = false;
- long stime = Calendar.getInstance().getTime().getTime();
+ boolean passed = false;
+ boolean threaded = false;
+ long stime = Calendar.getInstance().getTime().getTime();
- for (int j = 0; j < args.length; j++)
- {
- if (args[j].equals("-cached"))
- threaded = true;
- }
+ for (int i = 0; i < 1000; i++) {
+ try {
+ ObjectStore store = null;
- for (int i = 0; i < 1000; i++)
- {
- try
- {
- ObjectStore store = null;
+ if (!threaded)
+ store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_ShadowingStore());
+ else
+ store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
- if (!threaded)
- store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_ShadowingStore());
- else
- store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
+ byte[] data = new byte[10240];
+ OutputObjectState state = new OutputObjectState();
+ Uid u = new Uid();
- byte[] data = new byte[10240];
- OutputObjectState state = new OutputObjectState();
- Uid u = new Uid();
+ state.packBytes(data);
- state.packBytes(data);
+ if (store.write_committed(u, "/StateManager/LockManager/foo", state)) {
+ passed = true;
+ } else
+ passed = false;
+ }
+ catch (ObjectStoreException e) {
+ System.out.println(e.getMessage());
- if (store.write_committed(u, "/StateManager/LockManager/foo", state))
- {
- passed = true;
- }
- else
- passed = false;
- }
- catch (ObjectStoreException e)
- {
- System.out.println(e.getMessage());
+ passed = false;
+ }
+ catch (IOException ex) {
+ ex.printStackTrace();
- passed = false;
- }
- catch (IOException ex)
- {
- ex.printStackTrace();
+ passed = false;
+ }
+ }
- passed = false;
- }
- }
+ try {
+ Thread.currentThread().sleep(1000);
+ }
+ catch (Exception ex) {
+ }
- try
- {
- Thread.currentThread().sleep(1000);
- }
- catch (Exception ex)
- {
- }
+ long ftime = Calendar.getInstance().getTime().getTime();
+ long timeTaken = ftime - stime;
- long ftime = Calendar.getInstance().getTime().getTime();
- long timeTaken = ftime - stime;
+ System.out.println("time for 1000 write transactions is " + timeTaken);
- System.out.println("time for 1000 write transactions is "+timeTaken);
-
- try
- {
- Thread.currentThread().sleep(1000);
- }
- catch (Exception ex)
- {
- }
-
- if (passed)
- {
- System.out.println("Test passed");
- assertSuccess();
+ try {
+ Thread.currentThread().sleep(1000);
}
- else
- {
- System.out.println("Test failed");
- assertFailure();
+ catch (Exception ex) {
}
- }
- public static void main(String[] args)
- {
- PersistenceTest test = new PersistenceTest();
- test.run(args);
+ assertTrue(passed);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/RemoveCachedTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,64 +32,46 @@
package com.hp.mwtests.ts.arjuna.objectstore;
import com.arjuna.ats.arjuna.ArjunaNames;
+import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.common.*;
-import java.io.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import java.util.*;
+import java.io.IOException;
-import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-
public class RemoveCachedTest
{
- public static void main (String[] args)
+ @Test
+ public void test() throws IOException, ObjectStoreException
{
- boolean passed = true;
- ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
- String type = "ArjunaMS/Destinations/a3d6227_dc656_3b77ce7e_2/Messages";
- InputObjectState buff = new InputObjectState();
+ boolean passed = true;
+ ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
+ String type = "ArjunaMS/Destinations/a3d6227_dc656_3b77ce7e_2/Messages";
+ InputObjectState buff = new InputObjectState();
- try
- {
- if (store.allObjUids(type, buff, ObjectStore.OS_COMMITTED))
- {
- Uid toRemove = new Uid(Uid.nullUid());
+ if (store.allObjUids(type, buff, ObjectStore.OS_COMMITTED)) {
+ Uid toRemove = new Uid(Uid.nullUid());
- do
- {
- toRemove.unpack(buff);
+ do {
+ toRemove.unpack(buff);
- if (toRemove.notEquals(Uid.nullUid()))
- {
- System.err.println("Removing "+toRemove+"\n");
+ if (toRemove.notEquals(Uid.nullUid())) {
+ System.err.println("Removing " + toRemove + "\n");
- if (store.remove_committed(toRemove, type))
- passed = true;
- else
- {
- System.err.println("Failed for "+toRemove);
+ if (store.remove_committed(toRemove, type))
+ passed = true;
+ else {
+ System.err.println("Failed for " + toRemove);
- passed = false;
- }
- }
- } while (toRemove.notEquals(Uid.nullUid()));
- }
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
+ passed = false;
+ }
+ }
+ } while (toRemove.notEquals(Uid.nullUid()));
+ }
- if (passed)
- System.out.println("Passed.");
- else
- System.out.println("Failed.");
+ assertTrue(passed);
}
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/WriteCachedTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,54 +33,45 @@
import com.arjuna.ats.arjuna.ArjunaNames;
import com.arjuna.ats.arjuna.objectstore.ObjectStore;
-import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.common.*;
-import java.io.*;
-
import java.util.*;
-import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-
class WriterThread extends Thread
{
private static final String TYPE = "test";
- public WriterThread (ObjectStore theStore)
+ public WriterThread(ObjectStore theStore)
{
- store = theStore;
+ store = theStore;
}
- public void run ()
+ public void run()
{
- byte[] data = new byte[1024];
- OutputObjectState state = new OutputObjectState(new Uid(), "type");
- Uid u = new Uid();
+ byte[] data = new byte[1024];
+ OutputObjectState state = new OutputObjectState(new Uid(), "type");
+ Uid u = new Uid();
- try
- {
- state.packBytes(data);
+ try {
+ state.packBytes(data);
- if (store.write_committed(u, TYPE, state))
- {
- InputObjectState s = store.read_committed(u, TYPE);
+ if (store.write_committed(u, TYPE, state)) {
+ InputObjectState s = store.read_committed(u, TYPE);
- if (s != null)
- passed = true;
- else
- System.err.println("Could not read state.");
- }
- else
- System.err.println("Could not write state.");
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
+ if (s != null)
+ passed = true;
+ else
+ System.err.println("Could not read state.");
+ } else
+ System.err.println("Could not write state.");
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
}
public boolean passed = false;
@@ -92,88 +83,55 @@
public class WriteCachedTest
{
- public static void main (String[] args)
+ @Test
+ public void test()
{
- boolean passed = true;
- String cacheSize = "20480";
- int threads = 10;
+ boolean passed = true;
+ String cacheSize = "20480";
+ int threads = 10;
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-size"))
- cacheSize = args[i+1];
- if (args[i].equals("-threads"))
- {
- try
- {
- threads = Integer.parseInt(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- if (args[i].equals("-help"))
- {
- System.err.println("Usage: [-size <cache size>] [-threads <number>]");
+ Thread[] t = new Thread[threads];
- System.exit(0);
- }
- }
+ System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
- Thread[] t = new Thread[threads];
+ ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
- System.setProperty("com.arjuna.ats.internal.arjuna.objectstore.cacheStore.size", cacheSize);
+ long stime = Calendar.getInstance().getTime().getTime();
- ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_CacheStore());
+ for (int i = 0; (i < threads) && passed; i++) {
+ try {
+ t[i] = new WriterThread(store);
+ t[i].start();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
- long stime = Calendar.getInstance().getTime().getTime();
+ passed = false;
+ }
+ }
- for (int i = 0; (i < threads) && passed; i++)
- {
- try
- {
- t[i] = new WriterThread(store);
+ for (int j = 0; j < threads; j++) {
+ try {
+ t[j].join();
- t[i].start();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
+ passed = passed && ((WriterThread) t[j]).passed;
+ }
+ catch (Exception ex) {
+ }
+ }
- passed = false;
- }
- }
+ long ftime = Calendar.getInstance().getTime().getTime();
+ long timeTaken = ftime - stime;
- for (int j = 0; j < threads; j++)
- {
- try
- {
- t[j].join();
+ System.out.println("time for " + threads + " users is " + timeTaken);
- passed = passed && ((WriterThread) t[j]).passed;
- }
- catch (Exception ex)
- {
- }
- }
+ try {
+ store.sync();
+ }
+ catch (Exception ex) {
+ }
- long ftime = Calendar.getInstance().getTime().getTime();
- long timeTaken = ftime - stime;
-
- System.out.println("time for "+threads+" users is "+timeTaken);
-
- try
- {
- store.sync();
- }
- catch (Exception ex)
- {
- }
-
- if (passed)
- System.out.println("Passed.");
- else
- System.out.println("Failed.");
+ assertTrue(passed);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance1.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance1.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance1.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,35 +32,33 @@
package com.hp.mwtests.ts.arjuna.performance;
import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.util.*;
-public class Performance1 extends Test
+public class Performance1
{
- public void run(String[] args)
+ @Test
+ public void test()
{
- int numberOfTransactions = 1000;
- long stime = Calendar.getInstance().getTime().getTime();
+ int numberOfTransactions = 1000;
+ long stime = Calendar.getInstance().getTime().getTime();
- for (int i = 0; i < numberOfTransactions; i++)
- {
- AtomicAction A = new AtomicAction();
+ for (int i = 0; i < numberOfTransactions; i++) {
+ AtomicAction A = new AtomicAction();
- A.begin();
- A.abort();
- }
+ A.begin();
+ A.abort();
+ }
- long ftime = Calendar.getInstance().getTime().getTime();
- long timeTaken = ftime - stime;
+ long ftime = Calendar.getInstance().getTime().getTime();
+ long timeTaken = ftime - stime;
- logInformation("time for "+numberOfTransactions+" write transactions is "+timeTaken);
- logInformation("number of transactions: "+numberOfTransactions);
- logInformation("throughput: "+(float) (numberOfTransactions/(timeTaken / 1000.0)));
-
- assertSuccess();
+ System.out.println("time for " + numberOfTransactions + " write transactions is " + timeTaken);
+ System.out.println("number of transactions: " + numberOfTransactions);
+ System.out.println("throughput: " + (float) (numberOfTransactions / (timeTaken / 1000.0)));
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance2.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance2.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -34,42 +34,39 @@
import com.hp.mwtests.ts.arjuna.resources.*;
import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.common.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
import java.util.*;
class Worker extends Thread
{
- public Worker (int iters)
+ public Worker(int iters)
{
- _iters = iters;
+ _iters = iters;
}
- public void run ()
+ public void run()
{
- for (int i = 0; i < _iters; i++)
- {
- try
- {
- AtomicAction A = new AtomicAction();
+ for (int i = 0; i < _iters; i++) {
+ try {
+ AtomicAction A = new AtomicAction();
- A.begin();
+ A.begin();
- A.add(new BasicRecord());
+ A.add(new BasicRecord());
- A.commit();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
+ A.commit();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- Performance2.doSignal();
+ Performance2.doSignal();
}
private int _iters;
@@ -79,94 +76,54 @@
public class Performance2
{
-
- public static void main (String[] args)
+ @Test
+ public void test()
{
- int threads = 10;
- int work = 100;
+ int threads = 10;
+ int work = 100;
- System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
+ System.setProperty(Environment.COMMIT_ONE_PHASE, "NO");
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-threads") == 0)
- {
- try
- {
- Integer v = new Integer(args[i+1]);
+ number = threads;
- threads = v.intValue();
- }
- catch (Exception e)
- {
- System.err.println(e);
- }
- }
- if (args[i].compareTo("-work") == 0)
- {
- try
- {
- Integer v = new Integer(args[i+1]);
+ int numberOfTransactions = threads * work;
+ long stime = Calendar.getInstance().getTime().getTime();
+ Worker[] workers = new Worker[threads];
- work = v.intValue();
- }
- catch (Exception e)
- {
- System.err.println(e);
- }
- }
- if (args[i].compareTo("-help") == 0)
- {
- System.out.println("Usage: Performance2 [-help] [-threads <number>] [-work <number>]");
- System.exit(0);
- }
- }
+ for (int i = 0; i < threads; i++) {
+ workers[i] = new Worker(work);
- number = threads;
+ workers[i].start();
+ }
- int numberOfTransactions = threads * work;
- long stime = Calendar.getInstance().getTime().getTime();
- Worker[] workers = new Worker[threads];
+ Performance2.doWait();
- for (int i = 0; i < threads; i++)
- {
- workers[i] = new Worker(work);
+ long ftime = Calendar.getInstance().getTime().getTime();
+ long timeTaken = ftime - stime;
- workers[i].start();
- }
-
- Performance2.doWait();
-
- long ftime = Calendar.getInstance().getTime().getTime();
- long timeTaken = ftime - stime;
-
- System.out.println("time for "+numberOfTransactions+" write transactions is "+timeTaken);
- System.out.println("number of transactions: "+numberOfTransactions);
- System.out.println("throughput: "+(float) (numberOfTransactions/(timeTaken / 1000.0)));
+ System.out.println("time for " + numberOfTransactions + " write transactions is " + timeTaken);
+ System.out.println("number of transactions: " + numberOfTransactions);
+ System.out.println("throughput: " + (float) (numberOfTransactions / (timeTaken / 1000.0)));
}
- public static void doWait ()
+ public static void doWait()
{
- try
- {
- synchronized (sync)
- {
- if (number > 0)
- sync.wait();
- }
- }
- catch (Exception e)
- {
- }
+ try {
+ synchronized (sync) {
+ if (number > 0)
+ sync.wait();
+ }
+ }
+ catch (Exception e) {
+ }
}
- public static void doSignal ()
+ public static void doSignal()
{
- synchronized (sync)
- {
- if (--number == 0)
- sync.notify();
- }
+ synchronized (sync) {
+ if (--number == 0)
+ sync.notify();
+ }
}
private static Object sync = new Object();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance3.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance3.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/performance/Performance3.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,37 +33,33 @@
import com.hp.mwtests.ts.arjuna.resources.*;
-import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import java.util.*;
-
public class Performance3
{
-
- public static void main (String[] args)
+ @Test
+ public void test()
{
- long stime = System.currentTimeMillis();
+ long stime = System.currentTimeMillis();
- for (int i = 0; i < 1000; i++)
- {
- TwoPhaseCoordinator tx = new TwoPhaseCoordinator();
+ for (int i = 0; i < 1000; i++) {
+ TwoPhaseCoordinator tx = new TwoPhaseCoordinator();
- tx.start();
+ tx.start();
- tx.addSynchronization(new SyncRecord());
+ tx.addSynchronization(new SyncRecord());
- tx.end(true);
- }
+ tx.end(true);
+ }
- long ftime = System.currentTimeMillis();
- double elapsedTime = (ftime - stime)/1000.0;
- double tps = 1000.0/elapsedTime;
+ long ftime = System.currentTimeMillis();
+ double elapsedTime = (ftime - stime) / 1000.0;
+ double tps = 1000.0 / elapsedTime;
- System.err.println("TPS: "+tps);
+ System.err.println("TPS: " + tps);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -20,9 +20,6 @@
*/
package com.hp.mwtests.ts.arjuna.reaper;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
import com.arjuna.ats.arjuna.coordinator.Reapable;
import com.arjuna.ats.arjuna.common.Uid;
@@ -31,111 +28,114 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
/**
* Exercises some aspects of the TransactionReaper functionality.
+ *
* @author jonathan.halliday at redhat.com, 2007-04-30
*/
-public class ReaperTestCase extends TestCase
+public class ReaperTestCase
{
- public static Test suite() {
- return new TestSuite(ReaperTestCase.class);
- }
+ @Test
+ public void testReaper() throws Exception
+ {
- public void testReaper() throws Exception {
-
- // test set+readback of interval
- TransactionReaper.create(100);
- TransactionReaper reaper = TransactionReaper.transactionReaper();
+ // test set+readback of interval
+ TransactionReaper.create(100);
+ TransactionReaper reaper = TransactionReaper.transactionReaper();
// set value is ignored in default DYNAMIC mode, it uses max long instead.
assertEquals(Long.MAX_VALUE, reaper.checkingPeriod());
- Reapable reapable = new MockReapable(new Uid());
- Reapable reapable2 = new MockReapable(new Uid());
- Reapable reapable3 = new MockReapable(new Uid());
+ Reapable reapable = new MockReapable(new Uid());
+ Reapable reapable2 = new MockReapable(new Uid());
+ Reapable reapable3 = new MockReapable(new Uid());
- ReaperElement reaperElement = new ReaperElement(reapable, 30);
- ReaperElement reaperElement2 = new ReaperElement(reapable2, 20);
- ReaperElement reaperElement3 = new ReaperElement(reapable3, 10);
+ ReaperElement reaperElement = new ReaperElement(reapable, 30);
+ ReaperElement reaperElement2 = new ReaperElement(reapable2, 20);
+ ReaperElement reaperElement3 = new ReaperElement(reapable3, 10);
- // test that ordering is by timeout, regardless of insertion order
- SortedSet sortedSet = new TreeSet();
- sortedSet.add(reaperElement);
- sortedSet.add(reaperElement3);
- sortedSet.add(reaperElement2);
+ // test that ordering is by timeout, regardless of insertion order
+ SortedSet sortedSet = new TreeSet();
+ sortedSet.add(reaperElement);
+ sortedSet.add(reaperElement3);
+ sortedSet.add(reaperElement2);
- assertEquals(sortedSet.first(), reaperElement3);
- assertEquals(sortedSet.last(), reaperElement);
+ assertEquals(sortedSet.first(), reaperElement3);
+ assertEquals(sortedSet.last(), reaperElement);
- // test insertion of timeout=0 is a nullop
- assertTrue(reaper.insert(reapable, 0));
- assertEquals(0, reaper.numberOfTransactions());
- assertEquals(0, reaper.numberOfTimeouts());
- assertFalse(reaper.remove(reapable));
+ // test insertion of timeout=0 is a nullop
+ assertTrue(reaper.insert(reapable, 0));
+ assertEquals(0, reaper.numberOfTransactions());
+ assertEquals(0, reaper.numberOfTimeouts());
+ assertFalse(reaper.remove(reapable));
- // test that duplicate insertion fails
- assertTrue(reaper.insert(reapable, 10));
- assertFalse(reaper.insert(reapable, 10));
- assertEquals(1, reaper.numberOfTransactions());
- assertEquals(1, reaper.numberOfTimeouts());
- assertTrue(reaper.remove(reapable));
- assertEquals(0, reaper.numberOfTransactions());
- assertEquals(0, reaper.numberOfTimeouts());
+ // test that duplicate insertion fails
+ assertTrue(reaper.insert(reapable, 10));
+ assertFalse(reaper.insert(reapable, 10));
+ assertEquals(1, reaper.numberOfTransactions());
+ assertEquals(1, reaper.numberOfTimeouts());
+ assertTrue(reaper.remove(reapable));
+ assertEquals(0, reaper.numberOfTransactions());
+ assertEquals(0, reaper.numberOfTimeouts());
- // test that timeout change fails
- assertTrue(reaper.insert(reapable, 10));
- assertFalse(reaper.insert(reapable, 20));
- assertEquals(1, reaper.numberOfTransactions());
- assertEquals(1, reaper.numberOfTimeouts());
- assertEquals(10, reaper.getTimeout(reapable));
- assertTrue(reaper.remove(reapable));
- assertEquals(0, reaper.numberOfTransactions());
- assertEquals(0, reaper.numberOfTimeouts());
+ // test that timeout change fails
+ assertTrue(reaper.insert(reapable, 10));
+ assertFalse(reaper.insert(reapable, 20));
+ assertEquals(1, reaper.numberOfTransactions());
+ assertEquals(1, reaper.numberOfTimeouts());
+ assertEquals(10, reaper.getTimeout(reapable));
+ assertTrue(reaper.remove(reapable));
+ assertEquals(0, reaper.numberOfTransactions());
+ assertEquals(0, reaper.numberOfTimeouts());
- // test reaping
- reaper.insert(reapable, 1); // seconds
- reaper.insert(reapable2, 5);
- assertEquals(2, reaper.numberOfTransactions());
- assertEquals(2, reaper.numberOfTimeouts());
- reaper.check();
- assertEquals(2, reaper.numberOfTransactions());
- Thread.sleep(2*1000);
- reaper.check();
- assertEquals(1, reaper.numberOfTransactions());
- assertEquals(1, reaper.numberOfTimeouts());
- Thread.sleep(4*1000);
- reaper.check();
- assertEquals(0, reaper.numberOfTransactions());
- assertEquals(0, reaper.numberOfTimeouts());
+ // test reaping
+ reaper.insert(reapable, 1); // seconds
+ reaper.insert(reapable2, 5);
+ assertEquals(2, reaper.numberOfTransactions());
+ assertEquals(2, reaper.numberOfTimeouts());
+ reaper.check();
+ assertEquals(2, reaper.numberOfTransactions());
+ Thread.sleep(2 * 1000);
+ reaper.check();
+ assertEquals(1, reaper.numberOfTransactions());
+ assertEquals(1, reaper.numberOfTimeouts());
+ Thread.sleep(4 * 1000);
+ reaper.check();
+ assertEquals(0, reaper.numberOfTransactions());
+ assertEquals(0, reaper.numberOfTimeouts());
- }
+ }
- public class MockReapable implements Reapable
- {
- public MockReapable(Uid uid) {
- this.uid = uid;
- }
+ public class MockReapable implements Reapable
+ {
+ public MockReapable(Uid uid)
+ {
+ this.uid = uid;
+ }
- public boolean running()
- {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
+ public boolean running()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
- public boolean preventCommit()
- {
- return false; //To change body of implemented methods use File | Settings | File Templates.
- }
+ public boolean preventCommit()
+ {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
- public int cancel()
- {
- return 0; //To change body of implemented methods use File | Settings | File Templates.
- }
+ public int cancel()
+ {
+ return 0; //To change body of implemented methods use File | Settings | File Templates.
+ }
- public Uid get_uid()
- {
- return uid;
- }
+ public Uid get_uid()
+ {
+ return uid;
+ }
- private Uid uid;
- }
+ private Uid uid;
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase2.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -20,17 +20,13 @@
*/
package com.hp.mwtests.ts.arjuna.reaper;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
import com.arjuna.ats.arjuna.coordinator.Reapable;
import com.arjuna.ats.arjuna.coordinator.ActionStatus;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.internal.arjuna.coordinator.ReaperElement;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.junit.Test;
+import static org.junit.Assert.*;
/**
* Exercise cancellation behaviour of TransactionReaper with resources
@@ -40,269 +36,272 @@
* @author Andrwe Dinn (adinn at redhat.com), 2007-07-09
*/
-public class ReaperTestCase2 extends TestCase
+public class ReaperTestCase2
{
- public static Test suite()
- {
- return new TestSuite(ReaperTestCase2.class);
- }
-
+ @Test
public void testReaper() throws Exception
{
- TransactionReaper.create(500);
- TransactionReaper reaper = TransactionReaper.transactionReaper();
+ TransactionReaper.create(500);
+ TransactionReaper reaper = TransactionReaper.transactionReaper();
- // give the reaper worker time to start too
+ // give the reaper worker time to start too
- Thread.sleep(1000);
+ Thread.sleep(1000);
- // create slow reapables some of which will not respond immediately
+ // create slow reapables some of which will not respond immediately
// to cancel requests and ensure that they get cancelled
// and that the reaper does not get wedged
- SlowReapable reapable1 = new SlowReapable(new Uid(), 2000, 0, true, true, false);
- SlowReapable reapable2 = new SlowReapable(new Uid(), 0, 0, true, true, false);
- SlowReapable reapable3 = new SlowReapable(new Uid(), 100, 2000, false, true, false);
- SlowReapable reapable4 = new SlowReapable(new Uid(), 1000, 1000, false, false, false);
+ SlowReapable reapable1 = new SlowReapable(new Uid(), 2000, 0, true, true, false);
+ SlowReapable reapable2 = new SlowReapable(new Uid(), 0, 0, true, true, false);
+ SlowReapable reapable3 = new SlowReapable(new Uid(), 100, 2000, false, true, false);
+ SlowReapable reapable4 = new SlowReapable(new Uid(), 1000, 1000, false, false, false);
- // insert reapables so they timeout at 1 second intervals then
- // check progress of cancellations and rollbacks
+ // insert reapables so they timeout at 1 second intervals then
+ // check progress of cancellations and rollbacks
- assertTrue(reaper.insert(reapable1, 1));
+ assertTrue(reaper.insert(reapable1, 1));
- assertTrue(reaper.insert(reapable2, 2));
+ assertTrue(reaper.insert(reapable2, 2));
- assertTrue(reaper.insert(reapable3, 3));
+ assertTrue(reaper.insert(reapable3, 3));
- assertTrue(reaper.insert(reapable4, 4));
+ assertTrue(reaper.insert(reapable4, 4));
- // make sure they were all registered
+ // make sure they were all registered
- assertEquals(4, reaper.numberOfTransactions());
- assertEquals(4, reaper.numberOfTimeouts());
+ assertEquals(4, reaper.numberOfTransactions());
+ assertEquals(4, reaper.numberOfTimeouts());
- // n.b. the reaper will not operate in dynamic mode by default
- // so we have to allow an extra checkPeriod millisecs for it
- // to detect timeouts (it may go back to sleep a few
- // milliseconds before a transaction times out). also by
- // default the reaper waits 500 msecs for a cancel to take
- // effect before interrupting and 500 msecs for an interrupt
- // to take effect before making a wedged worker a zombie. so
- // these need to be factored into this thread's delays when
- // tetsing the state of the reapables.
+ // n.b. the reaper will not operate in dynamic mode by default
+ // so we have to allow an extra checkPeriod millisecs for it
+ // to detect timeouts (it may go back to sleep a few
+ // milliseconds before a transaction times out). also by
+ // default the reaper waits 500 msecs for a cancel to take
+ // effect before interrupting and 500 msecs for an interrupt
+ // to take effect before making a wedged worker a zombie. so
+ // these need to be factored into this thread's delays when
+ // tetsing the state of the reapables.
- // wait at most 2 seconds for the first reapable to be cancelled
+ // wait at most 2 seconds for the first reapable to be cancelled
- int count = 0;
+ int count = 0;
- while (!reapable1.getCancelTried() && count < 20) {
- count++;
- Thread.sleep(100);
- }
+ while (!reapable1.getCancelTried() && count < 20) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 20);
+ assertTrue(count < 20);
- // ensure that the second one gets cancelled even if the
- // first one is wedged
+ // ensure that the second one gets cancelled even if the
+ // first one is wedged
- count = 0;
+ count = 0;
- while (reapable2.getRunning() && count < 15) {
- count++;
- Thread.sleep(100);
- }
+ while (reapable2.getRunning() && count < 15) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 15);
+ assertTrue(count < 15);
- // ensure also that the second one gave up at the cancel and
- // not the mark for rollback
+ // ensure also that the second one gave up at the cancel and
+ // not the mark for rollback
- assertTrue(reapable2.getCancelTried());
+ assertTrue(reapable2.getCancelTried());
- // This assert causes timing issues on some build machines
- // - skip for now pending a more robust fix e.g. code injection
- //assertTrue(!reapable2.getRollbackTried());
+ // This assert causes timing issues on some build machines
+ // - skip for now pending a more robust fix e.g. code injection
+ //assertTrue(!reapable2.getRollbackTried());
- // ensure that the first one responded to the interrupt and
- // marks itself for rollback only
+ // ensure that the first one responded to the interrupt and
+ // marks itself for rollback only
- count = 0;
+ count = 0;
- while (reapable1.getRunning() && count < 10) {
- count++;
- Thread.sleep(100);
- }
+ while (reapable1.getRunning() && count < 10) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 10);
- // the first one should not be running because it marks itself ActionStatus.ABORTED
- // - the reaper should not attempt to roll it back in this case
- assertTrue(!reapable1.getRollbackTried());
+ assertTrue(count < 10);
+ // the first one should not be running because it marks itself ActionStatus.ABORTED
+ // - the reaper should not attempt to roll it back in this case
+ assertTrue(!reapable1.getRollbackTried());
- // check that the third one refuses the cancel and gets marked
- // for rollback instead
+ // check that the third one refuses the cancel and gets marked
+ // for rollback instead
- count = 0;
+ count = 0;
- while (!reapable3.getCancelTried() && count < 25) {
- count++;
- Thread.sleep(100);
- }
+ while (!reapable3.getCancelTried() && count < 25) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 25);
+ assertTrue(count < 25);
- // ensure that it gets marked for rollback
+ // ensure that it gets marked for rollback
- count = 0;
+ count = 0;
- while (reapable3.getRunning() && count < 10) {
- count++;
- Thread.sleep(100);
- }
+ while (reapable3.getRunning() && count < 10) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 10);
+ assertTrue(count < 10);
- assertTrue(reapable3.getRollbackTried());
+ assertTrue(reapable3.getRollbackTried());
- // ensure the fourth one gets cancelled and marked for rolback
- // even though it does not play ball
+ // ensure the fourth one gets cancelled and marked for rolback
+ // even though it does not play ball
- count = 0;
+ count = 0;
- while (reapable4.getRunning() && count < 25) {
- count++;
- Thread.sleep(100);
- }
+ while (reapable4.getRunning() && count < 25) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 25);
+ assertTrue(count < 25);
- assertTrue(reapable4.getCancelTried());
- assertTrue(reapable4.getRollbackTried());
+ assertTrue(reapable4.getCancelTried());
+ assertTrue(reapable4.getRollbackTried());
- // we should have a zombie worker so check that the thread
- // which tried the cancel is still runnning then sleep a bit
- // to give it time to complete and check it has exited
+ // we should have a zombie worker so check that the thread
+ // which tried the cancel is still runnning then sleep a bit
+ // to give it time to complete and check it has exited
- Thread worker = reapable4.getCancelThread();
+ Thread worker = reapable4.getCancelThread();
- assertTrue(worker.isAlive());
+ assertTrue(worker.isAlive());
- count = 0;
+ count = 0;
- while (worker.isAlive() && count < 30) {
- count++;
- Thread.sleep(100);
- }
+ while (worker.isAlive() && count < 30) {
+ count++;
+ Thread.sleep(100);
+ }
- assertTrue(count < 30);
+ assertTrue(count < 30);
}
public class SlowReapable implements Reapable
{
- public SlowReapable(Uid uid, int callDelay, int interruptDelay, boolean doCancel, boolean doRollback, boolean doComplete)
- {
- this.uid = uid;
+ public SlowReapable(Uid uid, int callDelay, int interruptDelay, boolean doCancel, boolean doRollback, boolean doComplete)
+ {
+ this.uid = uid;
this.callDelay = callDelay;
this.interruptDelay = interruptDelay;
this.doCancel = doCancel;
this.doRollback = doRollback;
this.doComplete = doComplete;
- cancelTried = false;
- rollbackTried = false;
- running = true;
+ cancelTried = false;
+ rollbackTried = false;
+ running = true;
}
- public boolean running()
- {
- return getRunning();
- }
+ public boolean running()
+ {
+ return getRunning();
+ }
- public boolean preventCommit()
- {
- setRollbackTried();
- clearRunning();
- return doRollback;
- }
+ public boolean preventCommit()
+ {
+ setRollbackTried();
+ clearRunning();
+ return doRollback;
+ }
- public int cancel()
- {
- boolean interrupted = false;
+ public int cancel()
+ {
+ boolean interrupted = false;
- setCancelTried();
+ setCancelTried();
- // track the worker trying to do the cancel so we can
- // detect if it becomes a zombie
+ // track the worker trying to do the cancel so we can
+ // detect if it becomes a zombie
- setCancelThread(Thread.currentThread());
+ setCancelThread(Thread.currentThread());
- if (callDelay > 0) {
- try {
- Thread.sleep(callDelay);
- } catch (InterruptedException e) {
- interrupted = true;
- }
- }
- if (interrupted && interruptDelay > 0) {
- try {
- Thread.sleep(interruptDelay);
- } catch (InterruptedException e) {
- }
- }
+ if (callDelay > 0) {
+ try {
+ Thread.sleep(callDelay);
+ } catch (InterruptedException e) {
+ interrupted = true;
+ }
+ }
+ if (interrupted && interruptDelay > 0) {
+ try {
+ Thread.sleep(interruptDelay);
+ } catch (InterruptedException e) {
+ }
+ }
- if (doCancel) {
- clearRunning();
- return ActionStatus.ABORTED;
- } else {
- return ActionStatus.RUNNING;
- }
- }
+ if (doCancel) {
+ clearRunning();
+ return ActionStatus.ABORTED;
+ } else {
+ return ActionStatus.RUNNING;
+ }
+ }
- public Uid get_uid()
- {
- return uid;
- }
+ public Uid get_uid()
+ {
+ return uid;
+ }
- private Uid uid;
+ private Uid uid;
private int callDelay; // in milliseconds
private int interruptDelay; // in milliseconds
private boolean doCancel;
private boolean doRollback;
private boolean doComplete;
- private boolean cancelTried;
- private boolean rollbackTried;
- private boolean running;
- private Thread cancelThread;
+ private boolean cancelTried;
+ private boolean rollbackTried;
+ private boolean running;
+ private Thread cancelThread;
- public synchronized void setCancelTried()
- {
- cancelTried = true;
- }
- public synchronized boolean getCancelTried()
- {
- return cancelTried;
- }
- public synchronized void setCancelThread(Thread cancelThread)
- {
- this.cancelThread = cancelThread;
- }
- public synchronized Thread getCancelThread()
- {
- return cancelThread;
- }
- public synchronized void setRollbackTried()
- {
- rollbackTried = true;
- }
- public synchronized boolean getRollbackTried()
- {
- return rollbackTried;
- }
- public synchronized void clearRunning()
- {
- running = false;
- }
- public synchronized boolean getRunning()
- {
- return running;
- }
+ public synchronized void setCancelTried()
+ {
+ cancelTried = true;
+ }
+
+ public synchronized boolean getCancelTried()
+ {
+ return cancelTried;
+ }
+
+ public synchronized void setCancelThread(Thread cancelThread)
+ {
+ this.cancelThread = cancelThread;
+ }
+
+ public synchronized Thread getCancelThread()
+ {
+ return cancelThread;
+ }
+
+ public synchronized void setRollbackTried()
+ {
+ rollbackTried = true;
+ }
+
+ public synchronized boolean getRollbackTried()
+ {
+ return rollbackTried;
+ }
+
+ public synchronized void clearRunning()
+ {
+ running = false;
+ }
+
+ public synchronized boolean getRunning()
+ {
+ return running;
+ }
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase3.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase3.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/reaper/ReaperTestCase3.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -20,73 +20,64 @@
*/
package com.hp.mwtests.ts.arjuna.reaper;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import com.arjuna.ats.arjuna.coordinator.TransactionReaper;
import com.arjuna.ats.arjuna.coordinator.Reapable;
import com.arjuna.ats.arjuna.coordinator.ActionStatus;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.internal.arjuna.coordinator.ReaperElement;
-import java.util.SortedSet;
-import java.util.TreeSet;
+import org.junit.Test;
+import static org.junit.Assert.*;
-
-public class ReaperTestCase3 extends TestCase
+public class ReaperTestCase3
{
- public static Test suite()
+ @Test
+ public void testReaperWait() throws Exception
{
- return new TestSuite(ReaperTestCase3.class);
- }
+ TransactionReaper.create(500);
+ TransactionReaper reaper = TransactionReaper.transactionReaper();
- public void testReaperWait () throws Exception
- {
- TransactionReaper.create(500);
- TransactionReaper reaper = TransactionReaper.transactionReaper();
+ // give the reaper worker time to start too
- // give the reaper worker time to start too
+ Thread.sleep(1000);
- Thread.sleep(1000);
-
- // create slow reapables some of which will not respond immediately
+ // create slow reapables some of which will not respond immediately
// to cancel requests and ensure that they get cancelled
// and that the reaper does not get wedged
- SlowReapable reapable1 = new SlowReapable(new Uid(), 2000, 0, true, true);
- SlowReapable reapable2 = new SlowReapable(new Uid(), 0, 0, true, true);
- SlowReapable reapable3 = new SlowReapable(new Uid(), 100, 2000, false, true);
- SlowReapable reapable4 = new SlowReapable(new Uid(), 1000, 1000, false, false);
+ SlowReapable reapable1 = new SlowReapable(new Uid(), 2000, 0, true, true);
+ SlowReapable reapable2 = new SlowReapable(new Uid(), 0, 0, true, true);
+ SlowReapable reapable3 = new SlowReapable(new Uid(), 100, 2000, false, true);
+ SlowReapable reapable4 = new SlowReapable(new Uid(), 1000, 1000, false, false);
- // insert reapables so they timeout at 1 second intervals then
- // check progress of cancellations and rollbacks
+ // insert reapables so they timeout at 1 second intervals then
+ // check progress of cancellations and rollbacks
- assertTrue(reaper.insert(reapable1, 1));
+ assertTrue(reaper.insert(reapable1, 1));
- assertTrue(reaper.insert(reapable2, 2));
+ assertTrue(reaper.insert(reapable2, 2));
- assertTrue(reaper.insert(reapable3, 3));
+ assertTrue(reaper.insert(reapable3, 3));
- assertTrue(reaper.insert(reapable4, 4));
+ assertTrue(reaper.insert(reapable4, 4));
- // make sure they were all registered
+ // make sure they were all registered
- assertEquals(4, reaper.numberOfTransactions());
- assertEquals(4, reaper.numberOfTimeouts());
+ assertEquals(4, reaper.numberOfTransactions());
+ assertEquals(4, reaper.numberOfTimeouts());
- // force a termination but wait for the transactions to timeout
-
- TransactionReaper.terminate(true);
-
- assertEquals(0, reaper.numberOfTransactions());
-
- assertTrue(reapable1.getCancelTried());
- assertTrue(reapable2.getCancelTried());
- assertTrue(reapable3.getCancelTried());
- assertTrue(reapable4.getCancelTried());
+ // force a termination but wait for the transactions to timeout
+
+ TransactionReaper.terminate(true);
+
+ assertEquals(0, reaper.numberOfTransactions());
+
+ assertTrue(reapable1.getCancelTried());
+ assertTrue(reapable2.getCancelTried());
+ assertTrue(reapable3.getCancelTried());
+ assertTrue(reapable4.getCancelTried());
}
-
- public void testReaperForce () throws Exception
+
+ public void testReaperForce() throws Exception
{
TransactionReaper.create(5000);
TransactionReaper reaper = TransactionReaper.transactionReaper();
@@ -121,127 +112,134 @@
assertEquals(4, reaper.numberOfTimeouts());
// force a termination and don't wait for the normal timeout periods
-
+
TransactionReaper.terminate(false);
-
+
assertEquals(0, reaper.numberOfTransactions());
-
+
assertTrue(reapable1.getCancelTried());
assertTrue(reapable2.getCancelTried());
assertTrue(reapable3.getCancelTried());
assertTrue(reapable4.getCancelTried());
-
+
/*
- * Since we've (hopefully) just run two tests with new reapers in the same VM
- * we've also shown that it's possible to start/terminate/start again!
- */
+ * Since we've (hopefully) just run two tests with new reapers in the same VM
+ * we've also shown that it's possible to start/terminate/start again!
+ */
}
public class SlowReapable implements Reapable
{
- public SlowReapable(Uid uid, int callDelay, int interruptDelay, boolean doCancel, boolean doRollback)
- {
- this.uid = uid;
+ public SlowReapable(Uid uid, int callDelay, int interruptDelay, boolean doCancel, boolean doRollback)
+ {
+ this.uid = uid;
this.callDelay = callDelay;
this.interruptDelay = interruptDelay;
this.doCancel = doCancel;
this.doRollback = doRollback;
- cancelTried = false;
- rollbackTried = false;
- running = true;
+ cancelTried = false;
+ rollbackTried = false;
+ running = true;
}
- public boolean running()
- {
- return getRunning();
- }
+ public boolean running()
+ {
+ return getRunning();
+ }
- public boolean preventCommit()
- {
- setRollbackTried();
- clearRunning();
- return doRollback;
- }
+ public boolean preventCommit()
+ {
+ setRollbackTried();
+ clearRunning();
+ return doRollback;
+ }
- public int cancel()
- {
- boolean interrupted = false;
+ public int cancel()
+ {
+ boolean interrupted = false;
- setCancelTried();
+ setCancelTried();
- // track the worker trying to do the cancel so we can
- // detect if it becomes a zombie
+ // track the worker trying to do the cancel so we can
+ // detect if it becomes a zombie
- setCancelThread(Thread.currentThread());
+ setCancelThread(Thread.currentThread());
- if (callDelay > 0) {
- try {
- Thread.sleep(callDelay);
- } catch (InterruptedException e) {
- interrupted = true;
- }
- }
- if (interrupted && interruptDelay > 0) {
- try {
- Thread.sleep(interruptDelay);
- } catch (InterruptedException e) {
- }
- }
+ if (callDelay > 0) {
+ try {
+ Thread.sleep(callDelay);
+ } catch (InterruptedException e) {
+ interrupted = true;
+ }
+ }
+ if (interrupted && interruptDelay > 0) {
+ try {
+ Thread.sleep(interruptDelay);
+ } catch (InterruptedException e) {
+ }
+ }
- if (doCancel) {
- clearRunning();
- return ActionStatus.ABORTED;
- } else {
- return ActionStatus.RUNNING;
- }
- }
+ if (doCancel) {
+ clearRunning();
+ return ActionStatus.ABORTED;
+ } else {
+ return ActionStatus.RUNNING;
+ }
+ }
- public Uid get_uid()
- {
- return uid;
- }
+ public Uid get_uid()
+ {
+ return uid;
+ }
- private Uid uid;
+ private Uid uid;
private int callDelay; // in milliseconds
private int interruptDelay; // in milliseconds
private boolean doCancel;
private boolean doRollback;
- private boolean cancelTried;
- private boolean rollbackTried;
- private boolean running;
- private Thread cancelThread;
+ private boolean cancelTried;
+ private boolean rollbackTried;
+ private boolean running;
+ private Thread cancelThread;
- public synchronized void setCancelTried()
- {
- cancelTried = true;
- }
- public synchronized boolean getCancelTried()
- {
- return cancelTried;
- }
- public synchronized void setCancelThread(Thread cancelThread)
- {
- this.cancelThread = cancelThread;
- }
- public synchronized Thread getCancelThread()
- {
- return cancelThread;
- }
- public synchronized void setRollbackTried()
- {
- rollbackTried = true;
- }
- public synchronized boolean getRollbackTried()
- {
- return rollbackTried;
- }
- public synchronized void clearRunning()
- {
- running = false;
- }
- public synchronized boolean getRunning()
- {
- return running;
- }
+ public synchronized void setCancelTried()
+ {
+ cancelTried = true;
+ }
+
+ public synchronized boolean getCancelTried()
+ {
+ return cancelTried;
+ }
+
+ public synchronized void setCancelThread(Thread cancelThread)
+ {
+ this.cancelThread = cancelThread;
+ }
+
+ public synchronized Thread getCancelThread()
+ {
+ return cancelThread;
+ }
+
+ public synchronized void setRollbackTried()
+ {
+ rollbackTried = true;
+ }
+
+ public synchronized boolean getRollbackTried()
+ {
+ return rollbackTried;
+ }
+
+ public synchronized void clearRunning()
+ {
+ running = false;
+ }
+
+ public synchronized boolean getRunning()
+ {
+ return running;
+ }
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionStatusServiceTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionStatusServiceTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionStatusServiceTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,267 +31,71 @@
* $Id: ActionStatusServiceTest.java 2342 2006-03-30 13:06:17Z $
*/
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.coordinator.ActionStatus;
import com.arjuna.ats.arjuna.coordinator.AddOutcome;
-import com.arjuna.ats.arjuna.coordinator.BasicAction;
import com.arjuna.ats.arjuna.common.Uid;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus;
-import com.arjuna.ats.arjuna.recovery.Service;
import com.arjuna.ats.arjuna.recovery.ActionStatusService;
-import com.arjuna.ats.arjuna.utils.Utility;
-import com.arjuna.ats.internal.arjuna.recovery.Listener;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem;
-import com.arjuna.ats.internal.arjuna.Implementations;
-import org.jboss.dtf.testframework.unittest.Test;
-public class ActionStatusServiceTest extends Test
-{
- private static boolean test_setup()
- {
- boolean setupOk = false;
+import org.junit.Test;
+import static org.junit.Assert.*;
- try
- {
- _tests_passed = 0;
- _tests_failed = 0;
-
- _test_service = new ActionStatusService();
-
- _transaction_1 = new AtomicAction();
- _transaction_2 = new AtomicAction();
- _transaction_3 = new AtomicAction();
-
- _test_tran_type_1 = _transaction_1.type();
- _test_tran_type_2 = _transaction_2.type();
- _test_tran_type_3 = _transaction_3.type();
-
- _test_uid_1 = _transaction_1.getSavingUid();
- _test_uid_2 = _transaction_2.getSavingUid();
- _test_uid_3 = _transaction_3.getSavingUid();
-
- setupOk = true;
- }
- catch (Exception ex)
- {
- System.err.println("test_setup: Failed " + ex);
- }
-
- return setupOk;
+public class ActionStatusServiceTest
+{
+ @Test
+ public void test1() {
+ int crashType = CrashAbstractRecordImpl.CRASH_IN_COMMIT;
+ String[] expectedStatus = new String[] { "ActionStatus.ABORTED", "ActionStatus.RUNNING", "ActionStatus.COMMITTED" };
+ runTest(crashType, expectedStatus, false);
}
- public void run(String[] args)
- {
- if (test_setup())
- {
- try
- {
- test1();
- test2();
- test3();
-
- System.out.println(_unit_test + "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed);
-
- if ( _tests_failed > 0 )
- assertFailure();
- else
- assertSuccess();
- }
- catch (Exception ex)
- {
- System.err.println(_unit_test + "FATAL EXCEPTION: " +
- "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed);
- assertFailure();
- }
- }
+ @Test
+ public void test2() {
+ int crashType = CrashAbstractRecordImpl.CRASH_IN_PREPARE;
+ String[] expectedStatus = new String[] { "ActionStatus.ABORTED", "ActionStatus.RUNNING", "ActionStatus.ABORTED" };
+ runTest(crashType, expectedStatus, false);
}
- private static void test1()
- {
- try
- {
- String test_uid = _test_uid_1.toString();
- String test_type = _test_tran_type_1;
-
- int test_status1 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status2 = _test_service.getTransactionStatus("", test_uid);
-
- _transaction_1.begin();
-
- CrashAbstractRecordImpl cr1 =
- new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_COMMIT);
- CrashAbstractRecordImpl cr2 =
- new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_COMMIT);
-
- int addcr1 = _transaction_1.add(cr1);
- int addcr2 = _transaction_1.add(cr2);
-
- int test_status3 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status4 = _test_service.getTransactionStatus("", test_uid);
-
- _transaction_1.commit();
-
- int test_status5 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status6 = _test_service.getTransactionStatus("", test_uid);
-
- if ((addcr1 == AddOutcome.AR_ADDED) &&
- (addcr2 == AddOutcome.AR_ADDED) &&
- (ActionStatus.stringForm(test_status1).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status2).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status3).equals("ActionStatus.RUNNING")) &&
- (ActionStatus.stringForm(test_status4).equals("ActionStatus.RUNNING")) &&
- (ActionStatus.stringForm(test_status5).equals("ActionStatus.COMMITTED")) &&
- (ActionStatus.stringForm(test_status6).equals("ActionStatus.COMMITTED")))
- {
- System.out.println(_unit_test + "test1: passed");
- _tests_passed++;
- }
- else
- {
- System.out.println(_unit_test + "test1: failed");
- _tests_failed++;
- }
- }
- catch (Exception ex)
- {
- System.err.println(_unit_test + " test1 " + ex);
- _tests_failed++;
- }
+ @Test
+ public void test3() {
+ int crashType = CrashAbstractRecordImpl.NO_CRASH;
+ String[] expectedStatus = new String[] { "ActionStatus.ABORTED", "ActionStatus.RUNNING", "ActionStatus.ABORTED" };
+ runTest(crashType, expectedStatus, true);
}
- private static void test2()
+ public void runTest(int crashType, String[] expectedStatus, boolean doAbort)
{
- try
- {
- String test_uid = _test_uid_2.toString();
- String test_type = _test_tran_type_2;
+ ActionStatusService _test_service = new ActionStatusService();
+ AtomicAction _transaction_1 = new AtomicAction();
+ String _test_tran_type_1 = _transaction_1.type();
+ Uid _test_uid_1 = _transaction_1.getSavingUid();
- int test_status1 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status2 = _test_service.getTransactionStatus("", test_uid);
+ String test_uid = _test_uid_1.toString();
+ String test_type = _test_tran_type_1;
- _transaction_2.begin();
+ assertEquals(expectedStatus[0], ActionStatus.stringForm( _test_service.getTransactionStatus(test_type, test_uid) ));
+ assertEquals(expectedStatus[0], ActionStatus.stringForm( _test_service.getTransactionStatus("", test_uid) ));
- CrashAbstractRecordImpl cr1 =
- new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_PREPARE);
- CrashAbstractRecordImpl cr2 =
- new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_PREPARE);
+ _transaction_1.begin();
- int addcr1 = _transaction_2.add(cr1);
- int addcr2 = _transaction_2.add(cr2);
+ CrashAbstractRecordImpl cr1 =
+ new CrashAbstractRecordImpl(crashType);
+ CrashAbstractRecordImpl cr2 =
+ new CrashAbstractRecordImpl(crashType);
- int test_status3 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status4 = _test_service.getTransactionStatus("", test_uid);
+ assertEquals(AddOutcome.AR_ADDED, _transaction_1.add(cr1) );
+ assertEquals(AddOutcome.AR_ADDED, _transaction_1.add(cr2) );
- _transaction_2.commit();
+ assertEquals(expectedStatus[1], ActionStatus.stringForm( _test_service.getTransactionStatus(test_type, test_uid) ));
+ assertEquals(expectedStatus[1], ActionStatus.stringForm( _test_service.getTransactionStatus("", test_uid) ));
- int test_status5 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status6 = _test_service.getTransactionStatus("", test_uid);
-
- if ((addcr1 == AddOutcome.AR_ADDED) &&
- (addcr2 == AddOutcome.AR_ADDED) &&
- (ActionStatus.stringForm(test_status1).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status2).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status3).equals("ActionStatus.RUNNING")) &&
- (ActionStatus.stringForm(test_status4).equals("ActionStatus.RUNNING")) &&
- (ActionStatus.stringForm(test_status5).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status6).equals("ActionStatus.ABORTED")))
- {
- System.out.println(_unit_test + "test2: passed");
- _tests_passed++;
- }
- else
- {
- System.out.println(_unit_test + "test2: failed");
- _tests_failed++;
- }
+ if(doAbort) {
+ _transaction_1.abort();
+ } else {
+ _transaction_1.commit();
}
- catch (Exception ex)
- {
- System.err.println(_unit_test + " test2 " + ex);
- _tests_failed++;
- }
- }
- private static void test3()
- {
- try
- {
- String test_uid = _test_uid_3.toString();
- String test_type = _test_tran_type_3;
-
- int test_status1 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status2 = _test_service.getTransactionStatus("", test_uid);
-
- _transaction_3.begin();
-
- CrashAbstractRecordImpl cr1 =
- new CrashAbstractRecordImpl(CrashAbstractRecordImpl.NO_CRASH);
- CrashAbstractRecordImpl cr2 =
- new CrashAbstractRecordImpl(CrashAbstractRecordImpl.NO_CRASH);
-
- int addcr1 = _transaction_3.add(cr1);
- int addcr2 = _transaction_3.add(cr2);
-
- int test_status3 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status4 = _test_service.getTransactionStatus("", test_uid);
-
- _transaction_3.abort();
-
- int test_status5 = _test_service.getTransactionStatus(test_type, test_uid);
- int test_status6 = _test_service.getTransactionStatus("", test_uid);
-
- if ((addcr1 == AddOutcome.AR_ADDED) &&
- (addcr2 == AddOutcome.AR_ADDED) &&
- (ActionStatus.stringForm(test_status1).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status2).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status3).equals("ActionStatus.RUNNING")) &&
- (ActionStatus.stringForm(test_status4).equals("ActionStatus.RUNNING")) &&
- (ActionStatus.stringForm(test_status5).equals("ActionStatus.ABORTED")) &&
- (ActionStatus.stringForm(test_status6).equals("ActionStatus.ABORTED")))
- {
- System.out.println(_unit_test + "test3: passed");
- _tests_passed++;
- }
- else
- {
- System.out.println(_unit_test + "test3: failed");
- _tests_failed++;
- }
- }
- catch (Exception ex)
- {
- System.err.println(_unit_test + " test3 " + ex);
- _tests_failed++;
- }
+ assertEquals(expectedStatus[2], ActionStatus.stringForm( _test_service.getTransactionStatus(test_type, test_uid) ));
+ assertEquals(expectedStatus[2], ActionStatus.stringForm( _test_service.getTransactionStatus("", test_uid) ));
}
-
- private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.ActionStatusServiceTest: ";
-
- private static ActionStatusService _test_service;
-
- private static AtomicAction _transaction_1;
- private static AtomicAction _transaction_2;
- private static AtomicAction _transaction_3;
-
- private static Uid _test_uid_1;
- private static Uid _test_uid_2;
- private static Uid _test_uid_3;
-
- private static int _test_status_1;
- private static int _test_status_2;
- private static int _test_status_3;
-
- private static String _test_tran_type_1;
- private static String _test_tran_type_2;
- private static String _test_tran_type_3;
-
- private static int _tests_passed = 0;
- private static int _tests_failed = 0;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestClient.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestClient.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestClient.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,310 +31,229 @@
* $Id: ActionTestClient.java 2342 2006-03-30 13:06:17Z $
*/
-import java.io.* ;
-import java.net.* ;
-import java.util.* ;
+import java.io.*;
-import com.arjuna.ats.arjuna.AtomicAction ;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus ;
-import com.arjuna.ats.arjuna.coordinator.AddOutcome ;
-import com.arjuna.ats.arjuna.common.Uid ;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus ;
-import com.arjuna.ats.arjuna.recovery.Service ;
-import com.arjuna.ats.arjuna.utils.Utility ;
-import com.arjuna.ats.internal.arjuna.recovery.Listener ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem ;
-import org.jboss.dtf.testframework.unittest.Test;
-import com.hp.mwtests.ts.arjuna.objectstore.ObjectStoreTest;
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.recovery.Service;
+import com.arjuna.ats.internal.arjuna.recovery.Listener;
+import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
class ActionTestClientTestService implements Service
{
- private void test1()
- {
- try
- {
- String test_tran_type_1 = _in.readLine() ;
- String test_uid_1_str = _in.readLine() ;
+ private void test1()
+ {
+ System.out.println("test1");
- Uid test_uid_1 = new Uid( test_uid_1_str ) ;
+ try {
+ String test_tran_type_1 = _in.readLine();
+ String test_uid_1_str = _in.readLine();
- int test_status1 = _tsc.getTransactionStatus( test_tran_type_1, test_uid_1 ) ;
- int test_status2 = _tsc.getTransactionStatus( "", test_uid_1 ) ;
+ Uid test_uid_1 = new Uid(test_uid_1_str);
- _out.println( "OK" ) ;
- _out.flush() ;
+ int test_status1 = _tsc.getTransactionStatus(test_tran_type_1, test_uid_1);
+ int test_status2 = _tsc.getTransactionStatus("", test_uid_1);
- test_tran_type_1 = _in.readLine() ;
- test_uid_1_str = _in.readLine() ;
- test_uid_1 = new Uid( test_uid_1_str ) ;
+ _out.println("OK");
+ _out.flush();
- int test_status3 = _tsc.getTransactionStatus( test_tran_type_1, test_uid_1 ) ;
- int test_status4 = _tsc.getTransactionStatus( "", test_uid_1 ) ;
+ test_tran_type_1 = _in.readLine();
+ test_uid_1_str = _in.readLine();
+ test_uid_1 = new Uid(test_uid_1_str);
- _out.println ( "OK" ) ;
- _out.flush() ;
+ int test_status3 = _tsc.getTransactionStatus(test_tran_type_1, test_uid_1);
+ int test_status4 = _tsc.getTransactionStatus("", test_uid_1);
- test_tran_type_1 = _in.readLine() ;
- test_uid_1_str = _in.readLine() ;
- test_uid_1 = new Uid( test_uid_1_str ) ;
+ _out.println("OK");
+ _out.flush();
- int test_status5 = _tsc.getTransactionStatus( test_tran_type_1, test_uid_1 ) ;
- int test_status6 = _tsc.getTransactionStatus( "", test_uid_1 ) ;
+ test_tran_type_1 = _in.readLine();
+ test_uid_1_str = _in.readLine();
+ test_uid_1 = new Uid(test_uid_1_str);
- _out.println( "OK" ) ;
- _out.flush() ;
+ int test_status5 = _tsc.getTransactionStatus(test_tran_type_1, test_uid_1);
+ int test_status6 = _tsc.getTransactionStatus("", test_uid_1);
- if ( ( test_status1 == ActionStatus.ABORTED ) &&
- ( test_status2 == ActionStatus.ABORTED ) &&
- ( test_status3 == ActionStatus.RUNNING ) &&
- ( test_status4 == ActionStatus.RUNNING ) &&
- ( test_status5 == ActionStatus.COMMITTED ) &&
- ( test_status6 == ActionStatus.COMMITTED ) )
- {
- System.out.println( _unit_test + "test1: passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test1: failed" ) ;
- _tests_failed++ ;
- }
- }
- catch ( IOException ex )
- {
- System.err.println( _unit_test + "test1: failed " + ex ) ;
- }
- }
+ _out.println("OK");
+ _out.flush();
- private void test2()
- {
- try
- {
- String test_tran_type_2 = _in.readLine() ;
- String test_uid_2_str = _in.readLine() ;
- Uid test_uid_2 = new Uid( test_uid_2_str ) ;
+ if ((test_status1 == ActionStatus.ABORTED) &&
+ (test_status2 == ActionStatus.ABORTED) &&
+ (test_status3 == ActionStatus.RUNNING) &&
+ (test_status4 == ActionStatus.RUNNING) &&
+ (test_status5 == ActionStatus.COMMITTED) &&
+ (test_status6 == ActionStatus.COMMITTED)) {
+ System.out.println("test1: passed");
+ _tests_passed++;
+ } else {
+ System.out.println("test1: failed");
+ _tests_failed++;
+ }
+ }
+ catch (IOException ex) {
+ System.err.println("test1: failed " + ex);
+ }
+ }
- int test_status1 = _tsc.getTransactionStatus( test_tran_type_2, test_uid_2 ) ;
- int test_status2 = _tsc.getTransactionStatus( "", test_uid_2 ) ;
+ private void test2()
+ {
+ try {
+ String test_tran_type_2 = _in.readLine();
+ String test_uid_2_str = _in.readLine();
+ Uid test_uid_2 = new Uid(test_uid_2_str);
- _out.println ( "OK" ) ;
- _out.flush() ;
+ int test_status1 = _tsc.getTransactionStatus(test_tran_type_2, test_uid_2);
+ int test_status2 = _tsc.getTransactionStatus("", test_uid_2);
- test_tran_type_2 = _in.readLine() ;
- test_uid_2_str = _in.readLine() ;
- test_uid_2 = new Uid( test_uid_2_str ) ;
+ _out.println("OK");
+ _out.flush();
- int test_status3 = _tsc.getTransactionStatus( test_tran_type_2, test_uid_2 ) ;
- int test_status4 = _tsc.getTransactionStatus( "", test_uid_2 ) ;
+ test_tran_type_2 = _in.readLine();
+ test_uid_2_str = _in.readLine();
+ test_uid_2 = new Uid(test_uid_2_str);
- _out.println ( "OK" ) ;
- _out.flush() ;
+ int test_status3 = _tsc.getTransactionStatus(test_tran_type_2, test_uid_2);
+ int test_status4 = _tsc.getTransactionStatus("", test_uid_2);
- test_tran_type_2 = _in.readLine() ;
- test_uid_2_str = _in.readLine() ;
- test_uid_2 = new Uid( test_uid_2_str ) ;
+ _out.println("OK");
+ _out.flush();
- int test_status5 = _tsc.getTransactionStatus( test_tran_type_2, test_uid_2 ) ;
- int test_status6 = _tsc.getTransactionStatus( "", test_uid_2 ) ;
+ test_tran_type_2 = _in.readLine();
+ test_uid_2_str = _in.readLine();
+ test_uid_2 = new Uid(test_uid_2_str);
- _out.println( "OK" ) ;
- _out.flush() ;
+ int test_status5 = _tsc.getTransactionStatus(test_tran_type_2, test_uid_2);
+ int test_status6 = _tsc.getTransactionStatus("", test_uid_2);
- if ( ( test_status1 == ActionStatus.ABORTED ) &&
- ( test_status2 == ActionStatus.ABORTED ) &&
- ( test_status3 == ActionStatus.RUNNING ) &&
- ( test_status4 == ActionStatus.RUNNING ) &&
- ( test_status5 == ActionStatus.ABORTED ) &&
- ( test_status6 == ActionStatus.ABORTED ) )
- {
- System.out.println( _unit_test + "test2: passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test2: failed" ) ;
- _tests_failed++ ;
- }
- }
- catch ( IOException ex )
- {
- System.err.println( _unit_test + "test2: failed " + ex ) ;
- }
- }
+ _out.println("OK");
+ _out.flush();
- private void test3()
- {
- try
- {
- String test_tran_type_3 = _in.readLine() ;
- String test_uid_3_str = _in.readLine() ;
- Uid test_uid_3 = new Uid( test_uid_3_str ) ;
+ if ((test_status1 == ActionStatus.ABORTED) &&
+ (test_status2 == ActionStatus.ABORTED) &&
+ (test_status3 == ActionStatus.RUNNING) &&
+ (test_status4 == ActionStatus.RUNNING) &&
+ (test_status5 == ActionStatus.ABORTED) &&
+ (test_status6 == ActionStatus.ABORTED)) {
+ System.out.println("test2: passed");
+ _tests_passed++;
+ } else {
+ System.out.println("test2: failed");
+ _tests_failed++;
+ }
+ }
+ catch (IOException ex) {
+ System.err.println("test2: failed " + ex);
+ }
+ }
- int test_status1 = _tsc.getTransactionStatus( test_tran_type_3, test_uid_3 ) ;
- int test_status2 = _tsc.getTransactionStatus( "", test_uid_3 ) ;
+ private void test3()
+ {
+ try {
+ String test_tran_type_3 = _in.readLine();
+ String test_uid_3_str = _in.readLine();
+ Uid test_uid_3 = new Uid(test_uid_3_str);
- _out.println ( "OK" ) ;
- _out.flush() ;
+ int test_status1 = _tsc.getTransactionStatus(test_tran_type_3, test_uid_3);
+ int test_status2 = _tsc.getTransactionStatus("", test_uid_3);
- test_tran_type_3 = _in.readLine() ;
- test_uid_3_str = _in.readLine() ;
- test_uid_3 = new Uid( test_uid_3_str ) ;
+ _out.println("OK");
+ _out.flush();
- int test_status3 = _tsc.getTransactionStatus( test_tran_type_3, test_uid_3 ) ;
- int test_status4 = _tsc.getTransactionStatus( "", test_uid_3 ) ;
+ test_tran_type_3 = _in.readLine();
+ test_uid_3_str = _in.readLine();
+ test_uid_3 = new Uid(test_uid_3_str);
- _out.println ( "OK" ) ;
- _out.flush() ;
+ int test_status3 = _tsc.getTransactionStatus(test_tran_type_3, test_uid_3);
+ int test_status4 = _tsc.getTransactionStatus("", test_uid_3);
- test_tran_type_3 = _in.readLine() ;
- test_uid_3_str = _in.readLine() ;
- test_uid_3 = new Uid( test_uid_3_str ) ;
+ _out.println("OK");
+ _out.flush();
- int test_status5 = _tsc.getTransactionStatus( test_tran_type_3, test_uid_3 ) ;
- int test_status6 = _tsc.getTransactionStatus( "", test_uid_3 ) ;
+ test_tran_type_3 = _in.readLine();
+ test_uid_3_str = _in.readLine();
+ test_uid_3 = new Uid(test_uid_3_str);
- _out.println( "OK" ) ;
- _out.flush() ;
+ int test_status5 = _tsc.getTransactionStatus(test_tran_type_3, test_uid_3);
+ int test_status6 = _tsc.getTransactionStatus("", test_uid_3);
- if ( ( test_status1 == ActionStatus.ABORTED ) &&
- ( test_status2 == ActionStatus.ABORTED ) &&
- ( test_status3 == ActionStatus.RUNNING ) &&
- ( test_status4 == ActionStatus.RUNNING ) &&
- ( test_status5 == ActionStatus.ABORTED ) &&
- ( test_status6 == ActionStatus.ABORTED ) )
- {
- System.out.println( _unit_test + "test3: passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test3: failed" ) ;
- _tests_failed++ ;
- }
- }
- catch ( IOException ex )
- {
- System.err.println( _unit_test + "test3: failed " + ex ) ;
- }
- }
+ _out.println("OK");
+ _out.flush();
- public void doWork( InputStream is, OutputStream os )
- throws IOException
- {
- _in = new BufferedReader( new InputStreamReader(is) ) ;
- _out = new PrintWriter( new OutputStreamWriter(os) ) ;
+ if ((test_status1 == ActionStatus.ABORTED) &&
+ (test_status2 == ActionStatus.ABORTED) &&
+ (test_status3 == ActionStatus.RUNNING) &&
+ (test_status4 == ActionStatus.RUNNING) &&
+ (test_status5 == ActionStatus.ABORTED) &&
+ (test_status6 == ActionStatus.ABORTED)) {
+ System.out.println("test3: passed");
+ _tests_passed++;
+ } else {
+ System.out.println("test3: failed");
+ _tests_failed++;
+ }
+ }
+ catch (IOException ex) {
+ System.err.println("test3: failed " + ex);
+ }
+ }
- try
- {
- String pidUidStr = _in.readLine() ;
- Uid pidUid = new Uid( pidUidStr ) ;
- String pidStr = _in.readLine() ;
+ public void doWork(InputStream is, OutputStream os)
+ throws IOException
+ {
+ System.out.println("starting to work");
- if ( pidUid == Uid.nullUid() )
- {
- System.out.println( _unit_test + "Test Failed" ) ;
- }
- else
- {
- _tsc = new TransactionStatusConnector( pidStr, pidUid ) ;
+ _in = new BufferedReader(new InputStreamReader(is));
+ _out = new PrintWriter(new OutputStreamWriter(os));
- test1() ;
- test2() ;
- test3() ;
+ try {
+ String pidUidStr = _in.readLine();
+ Uid pidUid = new Uid(pidUidStr);
+ String pidStr = _in.readLine();
- System.out.println( _unit_test + "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed ) ;
- }
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + " FAILED " + ex ) ;
- }
- }
+ if (pidUid == Uid.nullUid()) {
+ System.out.println("Test Failed");
+ } else {
+ _tsc = new TransactionStatusConnector(pidStr, pidUid);
- private static final String _unit_test = ActionTestClient._unit_test ;
+ test1();
+ test2();
+ test3();
- private static TransactionStatusConnector _tsc ;
+ System.out.println("tests passed: " + _tests_passed +
+ " tests failed: " + _tests_failed);
+ }
+ }
+ catch (Exception ex) {
+ System.err.println(" FAILED " + ex);
+ }
+ }
- private static BufferedReader _in ;
- private static PrintWriter _out ;
+ private static TransactionStatusConnector _tsc;
- private static AtomicAction _transaction_1 ;
- private static AtomicAction _transaction_2 ;
- private static AtomicAction _transaction_3 ;
+ private static BufferedReader _in;
+ private static PrintWriter _out;
- private static Uid _test_uid_1 ;
- private static Uid _test_uid_2 ;
- private static Uid _test_uid_3 ;
-
- private static String _test_tran_type_1 ;
- private static String _test_tran_type_2 ;
- private static String _test_tran_type_3 ;
-
- public static int _tests_passed = 0 ;
- public static int _tests_failed = 0 ;
+ public static int _tests_passed = 0;
+ public static int _tests_failed = 0;
}
-public class ActionTestClient extends Test
+public class ActionTestClient
{
- private static boolean test_setup()
- {
- boolean setupOk = false ;
-
- try
- {
- _test_service = new ActionTestClientTestService() ;
- _listener = new Listener( test_port, _test_service ) ;
- _listener.setDaemon( true ) ;
- _listener.start() ;
-
- Thread.sleep( 8000 ) ; // allow time for test to run
-
- setupOk = true ;
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + "test_setup: Failed " + ex ) ;
- }
-
- return setupOk ;
- }
-
- public void run( String[] args )
+ @Test
+ public void test() throws Exception
{
- if ( !test_setup() )
- {
- logInformation("Test setup failed");
- assertFailure();
- }
+ ActionTestClientTestService test_service = new ActionTestClientTestService();
+ Listener listener = new Listener(4321, test_service);
+ listener.setDaemon(true);
+ listener.start();
- logInformation("Tests Passed: "+ActionTestClientTestService._tests_passed);
- logInformation("Tests Failed: "+ActionTestClientTestService._tests_failed);
+ Thread.sleep(8000); // allow time for test to run
- if ( ActionTestClientTestService._tests_failed == 0 )
- {
- assertSuccess();
- }
- else
- {
- assertFailure();
- }
+ assertEquals(3, ActionTestClientTestService._tests_passed);
+ assertEquals(0, ActionTestClientTestService._tests_failed);
}
-
-public static void main(String[] args)
- {
- ActionTestClient test = new ActionTestClient();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-
-
- public static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.ActionTestClient: " ;
-
- private static ActionTestClientTestService _test_service ;
-
- private static int test_port = 4321 ;
-
- private static Listener _listener ;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestServer.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestServer.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ActionTestServer.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,339 +31,295 @@
* $Id: ActionTestServer.java 2342 2006-03-30 13:06:17Z $
*/
-import java.io.* ;
-import java.net.* ;
-import java.util.* ;
+import java.io.*;
+import java.net.*;
-import com.arjuna.ats.arjuna.AtomicAction ;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus ;
-import com.arjuna.ats.arjuna.coordinator.AddOutcome ;
-import com.arjuna.ats.arjuna.coordinator.BasicAction ;
-import com.arjuna.ats.arjuna.coordinator.TxControl ;
-import com.arjuna.ats.arjuna.common.Uid ;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus ;
-import com.arjuna.ats.arjuna.recovery.Service ;
-import com.arjuna.ats.arjuna.recovery.ActionStatusService ;
-import com.arjuna.ats.arjuna.utils.Utility ;
-import com.arjuna.ats.internal.arjuna.recovery.Listener ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem ;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-import com.arjuna.ats.arjuna.objectstore.ObjectStore ;
+import com.arjuna.ats.arjuna.AtomicAction;
+import com.arjuna.ats.arjuna.coordinator.AddOutcome;
+import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.utils.Utility;
-public class ActionTestServer extends Test
+import com.arjuna.ats.arjuna.objectstore.ObjectStore;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ActionTestServer
{
- private static boolean test_setup()
- {
- boolean setupOk = false ;
+ private static boolean test_setup()
+ {
+ boolean setupOk = false;
- try
- {
- _tests_passed = 0 ;
- _tests_failed = 0 ;
+ try {
+ _tests_passed = 0;
+ _tests_failed = 0;
- // needed to force TxControl static initialization
- ObjectStore os = TxControl.getStore() ;
+ // needed to force TxControl static initialization
+ ObjectStore os = TxControl.getStore();
- _transaction_1 = new AtomicAction() ;
- _transaction_2 = new AtomicAction() ;
- _transaction_3 = new AtomicAction() ;
+ _transaction_1 = new AtomicAction();
+ _transaction_2 = new AtomicAction();
+ _transaction_3 = new AtomicAction();
- _test_tran_type_1 = _transaction_1.type() ;
- _test_tran_type_2 = _transaction_2.type() ;
- _test_tran_type_3 = _transaction_3.type() ;
+ _test_tran_type_1 = _transaction_1.type();
+ _test_tran_type_2 = _transaction_2.type();
+ _test_tran_type_3 = _transaction_3.type();
- _test_uid_1 = _transaction_1.getSavingUid() ;
- _test_uid_2 = _transaction_2.getSavingUid() ;
- _test_uid_3 = _transaction_3.getSavingUid() ;
+ _test_uid_1 = _transaction_1.getSavingUid();
+ _test_uid_2 = _transaction_2.getSavingUid();
+ _test_uid_3 = _transaction_3.getSavingUid();
- _test_host = InetAddress.getLocalHost().getHostAddress() ;
+ _test_host = InetAddress.getLocalHost().getHostAddress();
- final int one_second = 1000 ;
- final int connection_tries = 10 ;
- Socket sok = null ;
+ final int one_second = 1000;
+ final int connection_tries = 10;
+ Socket sok = null;
- for ( int i = 0 ; i < connection_tries ; i++ )
- {
- try
- {
- sok = new Socket( _test_host, _test_port ) ;
- Thread.sleep( one_second ) ;
- if ( sok != null )
- break ;
+ for (int i = 0; i < connection_tries; i++) {
+ try {
+ sok = new Socket(_test_host, _test_port);
+ Thread.sleep(one_second);
+ if (sok != null)
+ break;
+ }
+ catch (ConnectException ex) {
+ if (connection_tries == i + 1) {
+ throw ex;
+ }
+ }
}
- catch ( ConnectException ex )
- {
- if ( connection_tries == i + 1 )
- {
- throw ex ;
- }
- }
- }
- // for sending transaction data to client
- _from_client = new BufferedReader( new InputStreamReader
- ( sok.getInputStream() )) ;
+ // for sending transaction data to client
+ _from_client = new BufferedReader(new InputStreamReader
+ (sok.getInputStream()));
- _to_client = new PrintWriter( new OutputStreamWriter
- ( sok.getOutputStream() )) ;
+ _to_client = new PrintWriter(new OutputStreamWriter
+ (sok.getOutputStream()));
- // Send the process id to the client, so that it can setup
- // a TransactionStatusConnector to this process.
- _to_client.println( Utility.getProcessUid().toString() ) ;
- _to_client.println( Utility.intToHexString( Utility.getpid() )) ;
- _to_client.flush() ;
+ // Send the process id to the client, so that it can setup
+ // a TransactionStatusConnector to this process.
+ _to_client.println(Utility.getProcessUid().toString());
+ _to_client.println(Utility.intToHexString(Utility.getpid()));
+ _to_client.flush();
- setupOk = true ;
- }
- catch ( Exception ex )
- {
- System.err.println( "test_setup: Failed " + ex ) ;
- }
+ setupOk = true;
+ }
+ catch (Exception ex) {
+ System.err.println("test_setup: Failed " + ex);
+ }
- return setupOk ;
- }
+ return setupOk;
+ }
- public void run( String[] args )
- {
- if ( test_setup() )
- {
- try
- {
- test1() ;
- test2() ;
- test3() ;
+ @Test
+ public void test()
+ {
+ if (test_setup()) {
+ try {
+ test1();
+ test2();
+ test3();
- logInformation( _unit_test + "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed );
+ System.out.println(_unit_test + "tests passed: " + _tests_passed +
+ " tests failed: " + _tests_failed);
- if ( _tests_failed > 0 )
- {
- assertFailure();
+ if (_tests_failed > 0) {
+ fail();
}
- else
- {
- assertSuccess();
- }
+
}
- catch ( Exception ex )
- {
- System.err.println( _unit_test + "FATAL EXCEPTION: " +
- "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed ) ;
- assertFailure();
+ catch (Exception ex) {
+ fail(_unit_test + "FATAL EXCEPTION: " +
+ "tests passed: " + _tests_passed +
+ " tests failed: " + _tests_failed);
}
+ } else {
+
+ fail("Test setup failed");
}
- else
- {
- logInformation("Test setup failed");
- assertFailure();
- }
- }
+ }
- private static void test1()
- {
- try
- {
- String test_uid = _test_uid_1.toString() ;
- String test_type = _test_tran_type_1 ;
- String reply ;
+ private static void test1()
+ {
+ try {
+ String test_uid = _test_uid_1.toString();
+ String test_type = _test_tran_type_1;
+ String reply;
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
- reply = _from_client.readLine() ;
+ reply = _from_client.readLine();
- _transaction_1.begin() ;
+ _transaction_1.begin();
- CrashAbstractRecordImpl cr1 =
- new CrashAbstractRecordImpl( CrashAbstractRecordImpl.CRASH_IN_COMMIT ) ;
- CrashAbstractRecordImpl cr2 =
- new CrashAbstractRecordImpl( CrashAbstractRecordImpl.CRASH_IN_COMMIT ) ;
+ CrashAbstractRecordImpl cr1 =
+ new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_COMMIT);
+ CrashAbstractRecordImpl cr2 =
+ new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_COMMIT);
- int addcr1 = _transaction_1.add( cr1 ) ;
- int addcr2 = _transaction_1.add( cr2 ) ;
+ int addcr1 = _transaction_1.add(cr1);
+ int addcr2 = _transaction_1.add(cr2);
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
- reply = _from_client.readLine() ;
+ reply = _from_client.readLine();
- _transaction_1.commit() ;
+ _transaction_1.commit();
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
- reply = _from_client.readLine() ;
+ reply = _from_client.readLine();
- if ( ( addcr1 == AddOutcome.AR_ADDED ) &&
- ( addcr2 == AddOutcome.AR_ADDED ) )
- {
- System.out.println( _unit_test + "test1 passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test1 failed" ) ;
- _tests_failed++ ;
- }
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + " test1 " + ex ) ;
- _tests_failed++ ;
- }
- }
+ if ((addcr1 == AddOutcome.AR_ADDED) &&
+ (addcr2 == AddOutcome.AR_ADDED)) {
+ System.out.println(_unit_test + "test1 passed");
+ _tests_passed++;
+ } else {
+ System.out.println(_unit_test + "test1 failed");
+ _tests_failed++;
+ }
+ }
+ catch (Exception ex) {
+ System.err.println(_unit_test + " test1 " + ex);
+ _tests_failed++;
+ }
+ }
- private static void test2()
- {
- try
- {
- String test_uid = _test_uid_2.toString() ;
- String test_type = _test_tran_type_2 ;
- String reply ;
+ private static void test2()
+ {
+ try {
+ String test_uid = _test_uid_2.toString();
+ String test_type = _test_tran_type_2;
+ String reply;
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
- reply = _from_client.readLine() ;
+ reply = _from_client.readLine();
- _transaction_2.begin() ;
+ _transaction_2.begin();
- CrashAbstractRecordImpl cr1 =
- new CrashAbstractRecordImpl( CrashAbstractRecordImpl.CRASH_IN_PREPARE ) ;
- CrashAbstractRecordImpl cr2 =
- new CrashAbstractRecordImpl( CrashAbstractRecordImpl.CRASH_IN_PREPARE ) ;
+ CrashAbstractRecordImpl cr1 =
+ new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_PREPARE);
+ CrashAbstractRecordImpl cr2 =
+ new CrashAbstractRecordImpl(CrashAbstractRecordImpl.CRASH_IN_PREPARE);
- int addcr1 = _transaction_2.add( cr1 ) ;
- int addcr2 = _transaction_2.add( cr2 ) ;
+ int addcr1 = _transaction_2.add(cr1);
+ int addcr2 = _transaction_2.add(cr2);
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
- reply = _from_client.readLine() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
+ reply = _from_client.readLine();
- _transaction_2.commit() ;
+ _transaction_2.commit();
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
- reply = _from_client.readLine() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
+ reply = _from_client.readLine();
- if ( ( addcr1 == AddOutcome.AR_ADDED ) &&
- ( addcr2 == AddOutcome.AR_ADDED ) )
- {
- System.out.println( _unit_test + "test2 passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test2 failed" ) ;
- _tests_failed++ ;
- }
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + " test2 " + ex ) ;
- _tests_failed++ ;
- }
- }
+ if ((addcr1 == AddOutcome.AR_ADDED) &&
+ (addcr2 == AddOutcome.AR_ADDED)) {
+ System.out.println(_unit_test + "test2 passed");
+ _tests_passed++;
+ } else {
+ System.out.println(_unit_test + "test2 failed");
+ _tests_failed++;
+ }
+ }
+ catch (Exception ex) {
+ System.err.println(_unit_test + " test2 " + ex);
+ _tests_failed++;
+ }
+ }
- private static void test3()
- {
- try
- {
- String test_uid = _test_uid_3.toString() ;
- String test_type = _test_tran_type_3 ;
- String reply ;
+ private static void test3()
+ {
+ try {
+ String test_uid = _test_uid_3.toString();
+ String test_type = _test_tran_type_3;
+ String reply;
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
- reply = _from_client.readLine() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
+ reply = _from_client.readLine();
- _transaction_3.begin() ;
+ _transaction_3.begin();
- CrashAbstractRecordImpl cr1 =
- new CrashAbstractRecordImpl( CrashAbstractRecordImpl.NO_CRASH ) ;
- CrashAbstractRecordImpl cr2 =
- new CrashAbstractRecordImpl( CrashAbstractRecordImpl.NO_CRASH ) ;
+ CrashAbstractRecordImpl cr1 =
+ new CrashAbstractRecordImpl(CrashAbstractRecordImpl.NO_CRASH);
+ CrashAbstractRecordImpl cr2 =
+ new CrashAbstractRecordImpl(CrashAbstractRecordImpl.NO_CRASH);
- int addcr1 = _transaction_3.add( cr1 ) ;
- int addcr2 = _transaction_3.add( cr2 ) ;
+ int addcr1 = _transaction_3.add(cr1);
+ int addcr2 = _transaction_3.add(cr2);
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
- reply = _from_client.readLine() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
+ reply = _from_client.readLine();
- _transaction_3.commit() ;
+ _transaction_3.commit();
- // send transaction id to client
- _to_client.println( test_type ) ;
- _to_client.println( test_uid ) ;
- _to_client.flush() ;
- reply = _from_client.readLine() ;
+ // send transaction id to client
+ _to_client.println(test_type);
+ _to_client.println(test_uid);
+ _to_client.flush();
+ reply = _from_client.readLine();
- if ( ( addcr1 == AddOutcome.AR_ADDED ) &&
- ( addcr2 == AddOutcome.AR_ADDED ) )
- {
- System.out.println( _unit_test + "test3 passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test3 failed" ) ;
- _tests_failed++ ;
- }
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + " test3 " + ex ) ;
- _tests_failed++ ;
- }
- }
+ if ((addcr1 == AddOutcome.AR_ADDED) &&
+ (addcr2 == AddOutcome.AR_ADDED)) {
+ System.out.println(_unit_test + "test3 passed");
+ _tests_passed++;
+ } else {
+ System.out.println(_unit_test + "test3 failed");
+ _tests_failed++;
+ }
+ }
+ catch (Exception ex) {
+ System.err.println(_unit_test + " test3 " + ex);
+ _tests_failed++;
+ }
+ }
- public static void main(String[] args)
- {
- ActionTestServer test = new ActionTestServer();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
+ private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.ActionTestServer: ";
- private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.ActionTestServer: " ;
+ private static String _test_host;
+ private static final int _test_port = 4321;
- private static String _test_host ;
- private static final int _test_port = 4321 ;
+ private static BufferedReader _from_client;
+ private static PrintWriter _to_client;
- private static BufferedReader _from_client ;
- private static PrintWriter _to_client ;
+ private static AtomicAction _transaction_1;
+ private static AtomicAction _transaction_2;
+ private static AtomicAction _transaction_3;
- private static AtomicAction _transaction_1 ;
- private static AtomicAction _transaction_2 ;
- private static AtomicAction _transaction_3 ;
+ private static Uid _test_uid_1;
+ private static Uid _test_uid_2;
+ private static Uid _test_uid_3;
- private static Uid _test_uid_1 ;
- private static Uid _test_uid_2 ;
- private static Uid _test_uid_3 ;
+ private static String _test_tran_type_1;
+ private static String _test_tran_type_2;
+ private static String _test_tran_type_3;
- private static String _test_tran_type_1 ;
- private static String _test_tran_type_2 ;
- private static String _test_tran_type_3 ;
-
- private static int _tests_passed = 0 ;
- private static int _tests_failed = 0 ;
+ private static int _tests_passed = 0;
+ private static int _tests_failed = 0;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/BasicCrashRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/BasicCrashRecord.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/BasicCrashRecord.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,8 +31,6 @@
package com.hp.mwtests.ts.arjuna.recovery;
-import java.io.*;
-import com.arjuna.ats.arjuna.ObjectType;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.coordinator.RecordType;
import com.arjuna.ats.arjuna.coordinator.TwoPhaseOutcome;
@@ -41,74 +39,74 @@
import com.arjuna.ats.arjuna.state.OutputObjectState;
public class BasicCrashRecord extends AbstractRecord
-{
+{
- public BasicCrashRecord ()
+ public BasicCrashRecord()
{
}
- public int typeIs ()
+ public int typeIs()
{
- return RecordType.USER_DEF_FIRST0;
+ return RecordType.USER_DEF_FIRST0;
}
-
- public boolean doSave ()
+
+ public boolean doSave()
{
- return false;
+ return false;
}
- public String type ()
+ public String type()
{
- return "/StateManager/AbstractRecord/com.hp.mwtests.ts.arjuna.recovery.BasicCrashRecord";
+ return "/StateManager/AbstractRecord/com.hp.mwtests.ts.arjuna.recovery.BasicCrashRecord";
}
-
- public boolean save_state (OutputObjectState os, int i)
+
+ public boolean save_state(OutputObjectState os, int i)
{
- return false;
+ return false;
}
- public boolean restore_state (InputObjectState os, int i)
+ public boolean restore_state(InputObjectState os, int i)
{
- return false;
+ return false;
}
-
- public Object value ()
+
+ public Object value()
{
- return _id;
+ return _id;
}
- public void setValue (Object object)
+ public void setValue(Object object)
{
}
public int nestedAbort()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
public int nestedCommit()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
public int nestedPrepare()
{
- return TwoPhaseOutcome.PREPARE_OK;
+ return TwoPhaseOutcome.PREPARE_OK;
}
public int topLevelAbort()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
-
+
public int topLevelCommit()
{
- throw new com.arjuna.ats.arjuna.exceptions.FatalError();
+ throw new com.arjuna.ats.arjuna.exceptions.FatalError();
}
public int topLevelPrepare()
{
- return TwoPhaseOutcome.PREPARE_OK;
+ return TwoPhaseOutcome.PREPARE_OK;
}
public void alter(AbstractRecord abstractRecord)
@@ -121,24 +119,24 @@
public boolean shouldAdd(AbstractRecord abstractRecord)
{
- return false;
+ return false;
}
public boolean shouldAlter(AbstractRecord abstractRecord)
{
- return false;
+ return false;
}
public boolean shouldMerge(AbstractRecord abstractRecord)
{
- return false;
+ return false;
}
public boolean shouldReplace(AbstractRecord abstractRecord)
{
- return false;
+ return false;
}
private Uid _id = new Uid();
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CallbackRecoveryTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CallbackRecoveryTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CallbackRecoveryTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,20 +31,16 @@
package com.hp.mwtests.ts.arjuna.recovery;
-import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.recovery.*;
-import com.hp.mwtests.ts.arjuna.resources.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import org.jboss.dtf.testframework.unittest.Test;
-
class RecoveryScanImple implements RecoveryScan
{
- public void completed ()
+ public void completed()
{
- passed = true;
+ passed = true;
}
public boolean passed = false;
@@ -53,29 +49,24 @@
public class CallbackRecoveryTest
{
-
- public static void main (String[] args)
+ @Test
+ public void test()
{
- RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
- DummyRecoveryModule module = new DummyRecoveryModule();
- RecoveryScanImple rs = new RecoveryScanImple();
+ RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
+ DummyRecoveryModule module = new DummyRecoveryModule();
+ RecoveryScanImple rs = new RecoveryScanImple();
- manager.addModule(module);
+ manager.addModule(module);
- manager.scan(rs);
+ manager.scan(rs);
- try
- {
- Thread.currentThread().sleep(120000);
- }
- catch (Exception ex)
- {
- }
-
- if (module.finished() && rs.passed)
- System.err.println("Passed.");
- else
- System.err.println("Failed.");
+ try {
+ Thread.currentThread().sleep(120000);
+ }
+ catch (Exception ex) {
+ }
+
+ assertTrue(module.finished());
+ assertTrue(rs.passed);
}
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordImpl.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordImpl.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordImpl.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,174 +31,168 @@
* $Id: CrashAbstractRecordImpl.java 2342 2006-03-30 13:06:17Z $
*/
-import java.io.* ;
-import com.arjuna.ats.arjuna.ObjectType ;
-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.AbstractRecord ;
-import com.arjuna.ats.arjuna.state.InputObjectState ;
-import com.arjuna.ats.arjuna.state.OutputObjectState ;
+import java.io.*;
+import com.arjuna.ats.arjuna.ObjectType;
+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.AbstractRecord;
+import com.arjuna.ats.arjuna.state.InputObjectState;
+import com.arjuna.ats.arjuna.state.OutputObjectState;
+
public class CrashAbstractRecordImpl extends AbstractRecord
-{
- public CrashAbstractRecordImpl( int crashBehaviour )
- {
- super( new Uid( "-7FFFFFF"+ _count + ":0:0:0" ),
- "com.hp.mwtests.ts.arjuna.recovery.CrashAbstractRecordImpl",
- ObjectType.ANDPERSISTENT);
- _count++ ;
- _crash_behaviour = crashBehaviour ;
- }
-
- // for crash recovery
- private CrashAbstractRecordImpl()
- {
- }
-
- // for crash recovery
- public static AbstractRecord create()
- {
- return new CrashAbstractRecordImpl() ;
- }
+{
+ public CrashAbstractRecordImpl(int crashBehaviour)
+ {
+ super(new Uid("-7FFFFFF" + _count + ":0:0:0"),
+ "com.hp.mwtests.ts.arjuna.recovery.CrashAbstractRecordImpl",
+ ObjectType.ANDPERSISTENT);
+ _count++;
+ _crash_behaviour = crashBehaviour;
+ }
- public int typeIs()
- {
- return RecordType.USER_DEF_FIRST0;
- }
-
- public boolean doSave ()
- {
- return true ;
- }
+ // for crash recovery
+ private CrashAbstractRecordImpl()
+ {
+ }
- public String type ()
- {
- return "/StateManager/AbstractRecord/com.hp.mwtests.ts.arjuna.recovery.CrashAbstractRecordImpl" ;
- }
-
- public boolean save_state (OutputObjectState os, int i)
- {
- boolean result = super.save_state(os, i);
-
- if ( result )
- {
- try
- {
- os.packInt( _save_param ) ;
- }
- catch ( IOException ex )
- {
- result = false ;
- }
- }
+ // for crash recovery
+ public static AbstractRecord create()
+ {
+ return new CrashAbstractRecordImpl();
+ }
- return result ;
- }
-
- public boolean restore_state (InputObjectState os, int i)
- {
- boolean result = super.restore_state(os, i);
+ public int typeIs()
+ {
+ return RecordType.USER_DEF_FIRST0;
+ }
- try
- {
- _save_param = os.unpackInt() ;
- _save_param++ ;
- }
- catch ( IOException ex )
- {
- result = false ;
- }
-
- return result ;
- }
-
- public Object value()
- {
- return null;
- }
+ public boolean doSave()
+ {
+ return true;
+ }
- public void setValue(Object object)
- {
- }
+ public String type()
+ {
+ return "/StateManager/AbstractRecord/com.hp.mwtests.ts.arjuna.recovery.CrashAbstractRecordImpl";
+ }
- public int nestedAbort()
- {
- return TwoPhaseOutcome.FINISH_OK;
- }
+ public boolean save_state(OutputObjectState os, int i)
+ {
+ boolean result = super.save_state(os, i);
- public int nestedCommit()
- {
- return TwoPhaseOutcome.FINISH_OK;
- }
+ if (result) {
+ try {
+ os.packInt(_save_param);
+ }
+ catch (IOException ex) {
+ result = false;
+ }
+ }
- public int nestedPrepare()
- {
- return TwoPhaseOutcome.PREPARE_OK;
- }
+ return result;
+ }
- public int topLevelAbort()
- {
- return TwoPhaseOutcome.FINISH_OK;
- }
+ public boolean restore_state(InputObjectState os, int i)
+ {
+ boolean result = super.restore_state(os, i);
- public int topLevelCommit()
- {
- int two_phase_outcome = TwoPhaseOutcome.FINISH_OK ;
-
- if ( _crash_behaviour == CRASH_IN_COMMIT )
- {
- two_phase_outcome = TwoPhaseOutcome.FINISH_ERROR ;
- }
+ try {
+ _save_param = os.unpackInt();
+ _save_param++;
+ }
+ catch (IOException ex) {
+ result = false;
+ }
- return two_phase_outcome ;
- }
+ return result;
+ }
- public int topLevelPrepare()
- {
- int two_phase_outcome = TwoPhaseOutcome.PREPARE_OK ;
-
- if ( _crash_behaviour == CRASH_IN_PREPARE )
- {
- two_phase_outcome = TwoPhaseOutcome.PREPARE_NOTOK ;
- }
-
- return two_phase_outcome ;
- }
+ public Object value()
+ {
+ return null;
+ }
- public void alter(AbstractRecord abstractRecord)
- {
- }
+ public void setValue(Object object)
+ {
+ }
- public void merge(AbstractRecord abstractRecord)
- {
- }
+ public int nestedAbort()
+ {
+ return TwoPhaseOutcome.FINISH_OK;
+ }
- public boolean shouldAdd(AbstractRecord abstractRecord)
- {
- return false;
- }
+ public int nestedCommit()
+ {
+ return TwoPhaseOutcome.FINISH_OK;
+ }
- public boolean shouldAlter(AbstractRecord abstractRecord)
- {
- return false;
- }
+ public int nestedPrepare()
+ {
+ return TwoPhaseOutcome.PREPARE_OK;
+ }
- public boolean shouldMerge(AbstractRecord abstractRecord)
- {
- return false;
- }
+ public int topLevelAbort()
+ {
+ return TwoPhaseOutcome.FINISH_OK;
+ }
- public boolean shouldReplace(AbstractRecord abstractRecord)
- {
- return false;
- }
-
- public static final int NO_CRASH = 0;
- public static final int CRASH_IN_PREPARE = 1;
- public static final int CRASH_IN_COMMIT = 2;
- public static final int CRASH_IN_ABORT = 3;
- private static int _save_param = 0;
- private static int _count = 1 ;
- private static int _crash_behaviour = NO_CRASH ;
+ public int topLevelCommit()
+ {
+ int two_phase_outcome = TwoPhaseOutcome.FINISH_OK;
+
+ if (_crash_behaviour == CRASH_IN_COMMIT) {
+ two_phase_outcome = TwoPhaseOutcome.FINISH_ERROR;
+ }
+
+ return two_phase_outcome;
+ }
+
+ public int topLevelPrepare()
+ {
+ int two_phase_outcome = TwoPhaseOutcome.PREPARE_OK;
+
+ if (_crash_behaviour == CRASH_IN_PREPARE) {
+ two_phase_outcome = TwoPhaseOutcome.PREPARE_NOTOK;
+ }
+
+ return two_phase_outcome;
+ }
+
+ public void alter(AbstractRecord abstractRecord)
+ {
+ }
+
+ public void merge(AbstractRecord abstractRecord)
+ {
+ }
+
+ public boolean shouldAdd(AbstractRecord abstractRecord)
+ {
+ return false;
+ }
+
+ public boolean shouldAlter(AbstractRecord abstractRecord)
+ {
+ return false;
+ }
+
+ public boolean shouldMerge(AbstractRecord abstractRecord)
+ {
+ return false;
+ }
+
+ public boolean shouldReplace(AbstractRecord abstractRecord)
+ {
+ return false;
+ }
+
+ public static final int NO_CRASH = 0;
+ public static final int CRASH_IN_PREPARE = 1;
+ public static final int CRASH_IN_COMMIT = 2;
+ public static final int CRASH_IN_ABORT = 3;
+ private static int _save_param = 0;
+ private static int _count = 1;
+ private static int _crash_behaviour = NO_CRASH;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordSetup.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordSetup.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/CrashAbstractRecordSetup.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,19 +31,18 @@
* $Id: CrashAbstractRecordSetup.java 2342 2006-03-30 13:06:17Z $
*/
-import com.arjuna.ats.arjuna.gandiva.inventory.Inventory ;
+import com.arjuna.ats.arjuna.gandiva.inventory.Inventory;
public class CrashAbstractRecordSetup
{
- public CrashAbstractRecordSetup()
- {
- if ( !_added )
- {
- Inventory.inventory().addToList( new UserDefFirst0Setup() ) ;
- _added = true ;
- }
- }
-
- private static boolean _added = false ;
+ public CrashAbstractRecordSetup()
+ {
+ if (!_added) {
+ Inventory.inventory().addToList(new UserDefFirst0Setup());
+ _added = true;
+ }
+ }
+
+ private static boolean _added = false;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DestroyRecoverTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DestroyRecoverTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DestroyRecoverTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,101 +32,89 @@
package com.hp.mwtests.ts.arjuna.recovery;
import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.common.*;
import com.hp.mwtests.ts.arjuna.resources.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
public class DestroyRecoverTest
{
-
- public static void main (String[] args)
+ @Test
+ public void test()
{
- AtomicAction A = new AtomicAction();
- BasicObject bo = null;
- Uid txId = null;
- Uid objId = null;
- boolean passed = true;
+ AtomicAction A = new AtomicAction();
+ BasicObject bo = null;
+ Uid txId = null;
+ Uid objId = null;
+ boolean passed = true;
- com.arjuna.ats.arjuna.common.Configuration.setAlternativeOrdering(true);
+ com.arjuna.ats.arjuna.common.Configuration.setAlternativeOrdering(true);
- try
- {
- A.begin();
+ try {
+ A.begin();
- bo = new BasicObject();
- objId = bo.get_uid();
+ bo = new BasicObject();
+ objId = bo.get_uid();
- A.removeThread();
+ A.removeThread();
- A.commit();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
+ A.commit();
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
- passed = false;
- }
+ passed = false;
+ }
- if (passed)
- {
- try
- {
- A = new AtomicAction();
+ if (passed) {
+ try {
+ A = new AtomicAction();
- txId = A.get_uid();
+ txId = A.get_uid();
- A.begin();
+ A.begin();
- bo.activate();
+ bo.activate();
- bo.destroy();
+ bo.destroy();
- A.add(new BasicCrashRecord());
+ A.add(new BasicCrashRecord());
- A.removeThread();
+ A.removeThread();
- A.commit();
- }
- catch (com.arjuna.ats.arjuna.exceptions.FatalError ex)
- {
- // ignore
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
+ A.commit();
+ }
+ catch (com.arjuna.ats.arjuna.exceptions.FatalError ex) {
+ // ignore
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
- passed = false;
- }
- }
+ passed = false;
+ }
+ }
- if (passed)
- {
- try
- {
- passed = false;
+ if (passed) {
+ try {
+ passed = false;
- RecoveryTransaction tx = new RecoveryTransaction(txId);
+ RecoveryTransaction tx = new RecoveryTransaction(txId);
- tx.doCommit();
+ tx.doCommit();
- BasicObject recoveredObject = new BasicObject(objId);
+ BasicObject recoveredObject = new BasicObject(objId);
- if (recoveredObject.get() == -1)
- passed = true;
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
+ if (recoveredObject.get() == -1)
+ passed = true;
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
- if (passed)
- System.out.println("Passed.");
- else
- System.out.println("Failed.");
+ assertTrue(passed);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DummyRecoveryModule.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DummyRecoveryModule.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/DummyRecoveryModule.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,27 +33,27 @@
class DummyRecoveryModule implements com.arjuna.ats.arjuna.recovery.RecoveryModule
{
- public DummyRecoveryModule ()
+ public DummyRecoveryModule()
{
}
-
- public void periodicWorkFirstPass ()
+
+ public void periodicWorkFirstPass()
{
- System.err.println("DummyRecoveryModule.periodicWorkFirstPass");
+ System.err.println("DummyRecoveryModule.periodicWorkFirstPass");
}
-
- public void periodicWorkSecondPass ()
+
+ public void periodicWorkSecondPass()
{
- System.err.println("DummyRecoveryModule.periodicWorkSecondPass");
+ System.err.println("DummyRecoveryModule.periodicWorkSecondPass");
- _complete = true;
+ _complete = true;
}
-
- public final boolean finished ()
+
+ public final boolean finished()
{
- return _complete;
+ return _complete;
}
-
+
private boolean _complete = false;
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/EmbeddedRecoveryTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/EmbeddedRecoveryTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/EmbeddedRecoveryTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,40 +31,23 @@
package com.hp.mwtests.ts.arjuna.recovery;
-import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
-import com.hp.mwtests.ts.arjuna.resources.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import org.jboss.dtf.testframework.unittest.Test;
-
-public class EmbeddedRecoveryTest extends Test
+public class EmbeddedRecoveryTest
{
-
- public void run (String[] args)
+ @Test
+ public void test()
{
- RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
- DummyRecoveryModule module = new DummyRecoveryModule();
+ RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
+ DummyRecoveryModule module = new DummyRecoveryModule();
- manager.addModule(module);
+ manager.addModule(module);
- manager.scan();
+ manager.scan();
- if (module.finished())
- assertSuccess();
- else
- assertFailure();
+ assertTrue(module.finished());
}
-
- public static void main (String[] args)
- {
- EmbeddedRecoveryTest test = new EmbeddedRecoveryTest();
-
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
-
- test.run(args);
- }
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ListenerTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ListenerTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/ListenerTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,168 +33,131 @@
import java.io.*;
import java.net.*;
-import java.util.*;
import com.arjuna.ats.arjuna.recovery.Service;
import com.arjuna.ats.internal.arjuna.recovery.Listener;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
class ListenerTestService implements Service
{
- public void doWork( InputStream is, OutputStream os )
- throws IOException
- {
- BufferedReader in = new BufferedReader( new InputStreamReader(is) );
- PrintWriter out = new PrintWriter( new OutputStreamWriter(os) );
+ public void doWork(InputStream is, OutputStream os)
+ throws IOException
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(is));
+ PrintWriter out = new PrintWriter(new OutputStreamWriter(os));
- try
- {
- String test_string = in.readLine();
- out.println( test_string );
- out.flush();
- }
- catch ( SocketException ex )
- {
- ; // socket closed
- }
- catch ( IOException ex )
- {
- System.err.println( "testService: failed" );
- }
- }
+ try {
+ String test_string = in.readLine();
+ out.println(test_string);
+ out.flush();
+ }
+ catch (SocketException ex) {
+ ; // socket closed
+ }
+ catch (IOException ex) {
+ System.err.println("testService: failed");
+ }
+ }
}
-public class ListenerTest extends Test
+public class ListenerTest
{
- public void run( String[] args )
- {
- if ( test_setup() )
- {
- try
- {
- test1();
+ @Test
+ public void test()
+ {
+ assertTrue(test_setup());
- logInformation( _unit_test + "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed );;
+ test1();
- if ( _tests_failed > 0 )
- {
- assertFailure();
- }
- else
- {
- assertSuccess();
- }
- }
- catch ( Exception ex )
- {
- logInformation( _unit_test + "FATAL EXCEPTION: " +
- "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed );
- assertSuccess();
- }
- }
+ assertEquals(0, _tests_failed);
+ assertEquals(1, _tests_passed);
}
- /**
- * Pre-test setup.
- */
- private static boolean test_setup()
- {
- boolean setupOk = false;
+ /**
+ * Pre-test setup.
+ */
+ private static boolean test_setup()
+ {
+ boolean setupOk = false;
- try
- {
- _tests_passed = 0;
- _tests_failed = 0;
+ try {
+ _tests_passed = 0;
+ _tests_failed = 0;
- _test_service = new ListenerTestService();
+ _test_service = new ListenerTestService();
- _test_host = InetAddress.getLocalHost().getHostAddress();
- _test_service_socket = new ServerSocket( _test_port );
+ _test_host = InetAddress.getLocalHost().getHostAddress();
+ _test_service_socket = new ServerSocket(_test_port);
- _test_socket = new Socket( _test_host, _test_port );
- _from_test_service = new BufferedReader( new InputStreamReader
- ( _test_socket.getInputStream() ));
- _to_test_service = new PrintWriter( new OutputStreamWriter
- ( _test_socket.getOutputStream() ));
+ _test_socket = new Socket(_test_host, _test_port);
+ _from_test_service = new BufferedReader(new InputStreamReader
+ (_test_socket.getInputStream()));
+ _to_test_service = new PrintWriter(new OutputStreamWriter
+ (_test_socket.getOutputStream()));
- setupOk = true;
- }
- catch ( Exception ex )
- {
- System.err.println( "test_setup: Failed " + ex );
- }
+ setupOk = true;
+ }
+ catch (Exception ex) {
+ System.err.println("test_setup: Failed " + ex);
+ }
- return setupOk;
- }
+ return setupOk;
+ }
- /**
- * Check that listener can be created and a simlple service ran.
- */
- private static void test1()
- {
- try
- {
- Listener testListener = new Listener( _test_service_socket,
- _test_service );
- try
- {
- testListener.start();
+ /**
+ * Check that listener can be created and a simlple service ran.
+ */
+ private static void test1()
+ {
+ try {
+ Listener testListener = new Listener(_test_service_socket,
+ _test_service);
+ try {
+ testListener.start();
- Thread.sleep( 1000 ); // allow testListener to startup.
+ Thread.sleep(1000); // allow testListener to startup.
- String testString = "testString";
- _to_test_service.println( testString );
- _to_test_service.flush();
- String returnString = _from_test_service.readLine();
+ String testString = "testString";
+ _to_test_service.println(testString);
+ _to_test_service.flush();
+ String returnString = _from_test_service.readLine();
- if ( testString.equals( returnString ) )
- {
- System.out.println( _unit_test + "test1: passed" );
- _tests_passed++;
+ if (testString.equals(returnString)) {
+ System.out.println(_unit_test + "test1: passed");
+ _tests_passed++;
+ } else {
+ System.out.println(_unit_test + "test1: failed");
+ _tests_failed++;
+ }
}
- else
- {
- System.out.println( _unit_test + "test1: failed" );
- _tests_failed++;
+ catch (Exception ex) {
+ System.err.println(_unit_test + " test1 " + ex);
+ _tests_failed++;
}
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + " test1 " + ex );
- _tests_failed++;
- }
- testListener.stopListener();
- }
- catch ( IOException ex )
- {
- System.err.println( _unit_test + " test1 " + ex );
- _tests_failed++;
- }
- }
-
-public static void main(String[] args)
- {
- ListenerTest test = new ListenerTest();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
+ testListener.stopListener();
+ }
+ catch (IOException ex) {
+ System.err.println(_unit_test + " test1 " + ex);
+ _tests_failed++;
+ }
}
- private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.ListenerTest: ";
+ private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.ListenerTest: ";
- private static String _test_host;
- private static final int _test_port = 4321;
+ private static String _test_host;
+ private static final int _test_port = 4321;
- private static ListenerTestService _test_service;
+ private static ListenerTestService _test_service;
- private static Socket _test_socket;
- private static ServerSocket _test_service_socket;
+ private static Socket _test_socket;
+ private static ServerSocket _test_service_socket;
- private static BufferedReader _from_test_service;
- private static PrintWriter _to_test_service;
+ private static BufferedReader _from_test_service;
+ private static PrintWriter _to_test_service;
- private static int _tests_passed = 0;
- private static int _tests_failed = 0;
+ private static int _tests_passed = 0;
+ private static int _tests_failed = 0;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/LogMoveTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/LogMoveTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/LogMoveTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -40,63 +40,60 @@
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
import com.arjuna.ats.arjuna.state.OutputObjectState;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class LogMoveTest
{
- public static void main (String[] args)
+ @Test
+ public void test()
{
ObjectStore os = TxControl.getStore();
OutputObjectState fluff = new OutputObjectState();
Uid kungfuTx = new Uid();
- boolean outcome = false;
+ boolean passed = false;
final String tn = new AtomicAction().type();
- try
- {
+ try {
kungfuTx.pack(fluff);
System.err.println("Creating dummy log");
-
+
os.write_committed(kungfuTx, tn, fluff);
- if (os.currentState(kungfuTx, tn) == ObjectStore.OS_COMMITTED)
- {
- System.err.println("Wrote dummy transaction "+kungfuTx);
+ if (os.currentState(kungfuTx, tn) == ObjectStore.OS_COMMITTED) {
+ System.err.println("Wrote dummy transaction " + kungfuTx);
System.setProperty(RecoveryEnvironment.EXPIRY_SCAN_INTERVAL, "1");
System.setProperty(Environment.PERIODIC_RECOVERY_PERIOD, "8000000");
-
+
RecoveryManager manager = RecoveryManager
.manager(RecoveryManager.DIRECT_MANAGEMENT);
manager.scan();
-
- try
- {
- Thread.sleep(3600000);
+
+ try {
+ Thread.sleep(3600000);
}
- catch (final Exception ex)
- {
+ catch (final Exception ex) {
}
-
+
manager.scan();
-
+
if (os.currentState(kungfuTx, tn) == ObjectStore.OS_COMMITTED)
System.err.println("Transaction log not moved!");
- else
- {
+ else {
System.err.println("Transaction log moved!");
-
- outcome = true;
+
+ passed = true;
}
- }
- else
+ } else
System.err.println("State is not committed!");
}
- catch (final Exception ex)
- {
+ catch (final Exception ex) {
ex.printStackTrace();
}
- System.err.println("Test outcome: " + (outcome ? "passed" : "failed"));
+ assertTrue(passed);
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryLifecycleTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryLifecycleTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryLifecycleTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,56 +31,37 @@
package com.hp.mwtests.ts.arjuna.recovery;
-import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
-import com.hp.mwtests.ts.arjuna.resources.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
-import org.jboss.dtf.testframework.unittest.Test;
-
-public class RecoveryLifecycleTest extends Test
+public class RecoveryLifecycleTest
{
-
- public void run (String[] args)
+ @Test
+ public void test()
{
- RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
- DummyRecoveryModule module = new DummyRecoveryModule();
+ RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
+ DummyRecoveryModule module = new DummyRecoveryModule();
- manager.addModule(module);
+ manager.addModule(module);
- manager.scan();
+ manager.scan();
- if (!module.finished())
- assertFailure();
+ assertTrue(module.finished());
- manager.terminate();
-
- manager.initialize();
-
- module = new DummyRecoveryModule();
-
- if (module.finished())
- assertFailure();
-
- manager.addModule(module);
+ manager.terminate();
- manager.scan();
+ manager.initialize();
- if (module.finished())
- assertSuccess();
- else
- assertFailure();
- }
+ module = new DummyRecoveryModule();
- public static void main (String[] args)
- {
- RecoveryLifecycleTest test = new RecoveryLifecycleTest();
+ assertFalse(module.finished());
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
+ manager.addModule(module);
- test.run(args);
- }
+ manager.scan();
+ assertTrue(module.finished());
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryManagerStartStopTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryManagerStartStopTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryManagerStartStopTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -1,11 +1,7 @@
package com.hp.mwtests.ts.arjuna.recovery;
-import junit.framework.TestCase;
-import junit.framework.Test;
-import junit.framework.TestSuite;
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
import com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery;
-import com.arjuna.ats.internal.arjuna.recovery.Listener;
import java.net.Socket;
import java.net.InetAddress;
@@ -14,16 +10,15 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
/**
* test to ensure that the recovery manager cleans up all its threads when terminated
*/
-public class RecoveryManagerStartStopTest extends TestCase
+public class RecoveryManagerStartStopTest
{
- public static Test suite()
- {
- return new TestSuite(RecoveryManagerStartStopTest.class);
- }
-
+ @Test
public void testStartStop() throws Exception
{
// check how many threads there are running
@@ -33,7 +28,7 @@
dumpThreadGroup(thg, "Before recovery manager create");
- RecoveryManager.delayRecoveryManagerThread() ;
+ RecoveryManager.delayRecoveryManagerThread();
RecoveryManager manager = RecoveryManager.manager(RecoveryManager.INDIRECT_MANAGEMENT);
dumpThreadGroup(thg, "Before recovery manager initialize");
@@ -47,7 +42,7 @@
dumpThreadGroup(thg, "Before recovery manager start periodic recovery thread");
manager.startRecoveryManagerThread();
-
+
dumpThreadGroup(thg, "Before recovery manager client create");
// we need to open several connections to the recovery manager listener service and then
@@ -63,7 +58,7 @@
manager.terminate();
// ensure the client threads get killed
-
+
ensureRecoveryClientsTerminated();
// ensure there are no extra threads running
@@ -77,7 +72,8 @@
assertEquals(activeCount, newActiveCount);
}
- private void ensureRecoveryClientsTerminated() {
+ private void ensureRecoveryClientsTerminated()
+ {
// check that any threads added to talk to the reocvery listener get their sockets closed
for (RecoveryManagerStartStopTestThread client : clients) {
@@ -90,7 +86,8 @@
}
}
- private void addRecoveryClient() {
+ private void addRecoveryClient()
+ {
// open a connection to the recovery listener service in a new thread and ensure that the
// thread is terminated by habing its socket closed.
@@ -107,7 +104,7 @@
System.out.println(header);
System.out.println("Thread count == " + activeCount);
- for (int i = 0; i < reported ; i++) {
+ for (int i = 0; i < reported; i++) {
System.out.println("Thread[" + i + "] == " + threads[i].getName());
}
@@ -130,7 +127,8 @@
return failed;
}
- public void run() {
+ public void run()
+ {
BufferedReader fromServer = null;
Socket connectorSocket = null;
// get a socket connected to the listener
@@ -155,7 +153,7 @@
System.out.println("connected!!!");
System.out.flush();
- fromServer = new BufferedReader(new InputStreamReader(connectorSocket.getInputStream())) ;
+ fromServer = new BufferedReader(new InputStreamReader(connectorSocket.getInputStream()));
} catch (Exception e) {
System.out.println("Failed to set up listener input stream!!!");
e.printStackTrace();
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryTransaction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryTransaction.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryTransaction.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,33 +31,32 @@
package com.hp.mwtests.ts.arjuna.recovery;
-import java.io.*;
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.coordinator.*;
public class RecoveryTransaction extends BasicAction
-{
+{
- public RecoveryTransaction (Uid txId)
+ public RecoveryTransaction(Uid txId)
{
- super(txId);
-
- activate();
+ super(txId);
+
+ activate();
}
- public void doAbort ()
+ public void doAbort()
{
- super.phase2Abort(true);
+ super.phase2Abort(true);
}
-
- public void doCommit ()
+
+ public void doCommit()
{
- super.phase2Commit(true);
+ super.phase2Commit(true);
}
- public String type ()
+ public String type()
{
- return "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
+ return "/StateManager/BasicAction/TwoPhaseCoordinator/AtomicAction";
}
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusConnectorTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusConnectorTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusConnectorTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,243 +31,222 @@
* $Id: TransactionStatusConnectorTest.java 2342 2006-03-30 13:06:17Z $
*/
-import java.io.* ;
-import java.net.* ;
-import java.util.* ;
+import java.io.*;
+import java.net.*;
+import java.util.*;
-import com.arjuna.ats.arjuna.common.Uid ;
-import com.arjuna.ats.arjuna.coordinator.ActionStatus ;
-import com.arjuna.ats.arjuna.recovery.Service ;
-import com.arjuna.ats.internal.arjuna.recovery.Listener ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem ;
-import com.arjuna.ats.arjuna.utils.Utility ;
+import com.arjuna.ats.arjuna.common.Uid;
+import com.arjuna.ats.arjuna.coordinator.ActionStatus;
+import com.arjuna.ats.arjuna.recovery.Service;
+import com.arjuna.ats.internal.arjuna.recovery.Listener;
+import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusConnector;
+import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem;
+import com.arjuna.ats.arjuna.utils.Utility;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
class TransactionStatusConnectorTestService implements Service
{
- public void doWork( InputStream is, OutputStream os )
- throws IOException
- {
- BufferedReader in = new BufferedReader( new InputStreamReader(is) ) ;
- PrintWriter out = new PrintWriter( new OutputStreamWriter(os) ) ;
+ public void doWork(InputStream is, OutputStream os)
+ throws IOException
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(is));
+ PrintWriter out = new PrintWriter(new OutputStreamWriter(os));
- try
- {
- out.println ( Utility.intToHexString( Utility.getpid() )) ;
- out.flush() ;
+ try {
+ out.println(Utility.intToHexString(Utility.getpid()));
+ out.flush();
- String rmStatus = in.readLine() ;
- if ( rmStatus.equals( "OK" ) )
- {
- for ( int i = 0 ; i < 4 ; i++ )
- {
- _rx_tran_type = in.readLine() ;
- _rx_uid_str = in.readLine() ;
+ String rmStatus = in.readLine();
+ if (rmStatus.equals("OK")) {
+ for (int i = 0; i < 4; i++) {
+ _rx_tran_type = in.readLine();
+ _rx_uid_str = in.readLine();
- out.println( _test_status ) ;
- out.flush() ;
+ out.println(_test_status);
+ out.flush();
+ }
}
- }
- }
- catch ( SocketException ex )
- {
- ; // Socket closed
- }
- catch ( Exception ex )
- {
- System.err.println( "TestService failed " + ex ) ;
- }
- }
-
- public String _rx_tran_type ;
- public String _rx_uid_str ;
- public String _test_status ;
- public boolean _stop_test = false ;
+ }
+ catch (SocketException ex) {
+ ; // Socket closed
+ }
+ catch (Exception ex) {
+ System.err.println("TestService failed " + ex);
+ }
+ }
+
+ public String _rx_tran_type;
+ public String _rx_uid_str;
+ public String _test_status;
+ public boolean _stop_test = false;
}
public class TransactionStatusConnectorTest
{
- public static void main( String[] args )
- {
- if ( test_setup() )
- {
- try
- {
- test1() ;
-
- System.out.println( _unit_test + "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed ) ;
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + "FATAL EXCEPTION: " +
- "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed ) ;
- }
- }
- }
+ @Test
+ public void test()
+ {
+ assertTrue(test_setup());
+ test1();
+ assertEquals(0, _tests_failed);
+ assertEquals(1, _tests_passed);
+ }
- /**
- * Pre-test setup.
- */
- private static boolean test_setup()
- {
- boolean setupOk = false ;
-
- try
- {
- _tests_passed = 0 ;
- _tests_failed = 0 ;
+ /**
+ * Pre-test setup.
+ */
+ private static boolean test_setup()
+ {
+ boolean setupOk = false;
- if ( TransactionStatusManagerItem.createAndSave( _test_port ) )
- {
- _pidUid = Utility.getProcessUid() ;
- String strUid = _pidUid.toString() ;
- StringTokenizer st = new StringTokenizer( strUid, ":" ) ;
- st.nextToken() ;
- _pidStr = st.nextToken() ;
+ try {
+ _tests_passed = 0;
+ _tests_failed = 0;
- _test_service_socket = new ServerSocket( _test_port ) ;
- _test_service = new TransactionStatusConnectorTestService() ;
+ if (TransactionStatusManagerItem.createAndSave(_test_port)) {
+ _pidUid = Utility.getProcessUid();
+ String strUid = _pidUid.toString();
+ StringTokenizer st = new StringTokenizer(strUid, ":");
+ st.nextToken();
+ _pidStr = st.nextToken();
- _test_status_1 = ActionStatus.COMMITTED ;
- _test_status_2 = ActionStatus.PREPARED ;
- _test_status_3 = ActionStatus.ABORTED ;
- _test_status_4 = ActionStatus.INVALID ;
+ _test_service_socket = new ServerSocket(_test_port);
+ _test_service = new TransactionStatusConnectorTestService();
- _test_uid_1 = new Uid() ;
- _test_uid_2 = new Uid() ;
- _test_uid_3 = new Uid() ;
- _test_uid_4 = new Uid() ;
-
- _test_tran_type_1 = "_test_tran_type_1" ;
- _test_tran_type_2 = "_test_tran_type_2" ;
- _test_tran_type_3 = "_test_tran_type_3" ;
- _test_tran_type_4 = "_test_tran_type_4" ;
+ _test_status_1 = ActionStatus.COMMITTED;
+ _test_status_2 = ActionStatus.PREPARED;
+ _test_status_3 = ActionStatus.ABORTED;
+ _test_status_4 = ActionStatus.INVALID;
- _listener = new Listener( _test_service_socket, _test_service ) ;
- _listener.start() ;
+ _test_uid_1 = new Uid();
+ _test_uid_2 = new Uid();
+ _test_uid_3 = new Uid();
+ _test_uid_4 = new Uid();
- setupOk = true ;
- }
- }
- catch ( Exception ex )
- {
- System.err.println( "test_setup: Failed " + ex ) ;
- }
-
- return setupOk ;
- }
-
- /**
- * Test which checks that a transaction status connector can be
- * created and transaction statuses can be retrieved using a simple
- * test service.
- */
- private static void test1()
- {
- try
- {
- TransactionStatusConnector testTransactionStatusConnector =
- new TransactionStatusConnector( _pidStr, _pidUid ) ;
+ _test_tran_type_1 = "_test_tran_type_1";
+ _test_tran_type_2 = "_test_tran_type_2";
+ _test_tran_type_3 = "_test_tran_type_3";
+ _test_tran_type_4 = "_test_tran_type_4";
- _test_service._test_status = Integer.toString( _test_status_1 ) ;
- int test_status1 = testTransactionStatusConnector.getTransactionStatus
- ( _test_tran_type_1, _test_uid_1 ) ;
- _rx_tran_type_1 = _test_service._rx_tran_type ;
- _rx_uid_str_1 = _test_service._rx_uid_str ;
-
- _test_service._test_status = Integer.toString( _test_status_2 ) ;
- int test_status2 = testTransactionStatusConnector.getTransactionStatus
- ( _test_tran_type_2, _test_uid_2 ) ;
- _rx_tran_type_2 = _test_service._rx_tran_type ;
- _rx_uid_str_2 = _test_service._rx_uid_str ;
-
- _test_service._test_status = Integer.toString( _test_status_3 ) ;
- int test_status3 = testTransactionStatusConnector.getTransactionStatus
- ( _test_tran_type_3, _test_uid_3 ) ;
- _rx_tran_type_3 = _test_service._rx_tran_type ;
- _rx_uid_str_3 = _test_service._rx_uid_str ;
-
- _test_service._test_status = Integer.toString( _test_status_4 ) ;
- int test_status4 = testTransactionStatusConnector.getTransactionStatus
- ( _test_tran_type_4, _test_uid_4 ) ;
- _rx_tran_type_4 = _test_service._rx_tran_type ;
- _rx_uid_str_4 = _test_service._rx_uid_str ;
-
- if ( ( test_status1 == _test_status_1 ) &&
- ( test_status2 == _test_status_2 ) &&
- ( test_status3 == _test_status_3 ) &&
- ( test_status4 == _test_status_4 ) &&
- ( _rx_tran_type_1.equals( _test_tran_type_1 ) ) &&
- ( _rx_tran_type_2.equals( _test_tran_type_2 ) ) &&
- ( _rx_tran_type_3.equals( _test_tran_type_3 ) ) &&
- ( _rx_tran_type_4.equals( _test_tran_type_4 ) ) &&
- ( _rx_uid_str_1.equals( _test_uid_1.toString() ) ) &&
- ( _rx_uid_str_2.equals( _test_uid_2.toString() ) ) &&
- ( _rx_uid_str_3.equals( _test_uid_3.toString() ) ) &&
- ( _rx_uid_str_4.equals( _test_uid_4.toString() ) ) )
- {
- System.out.println( _unit_test + "test1: passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test1: failed" ) ;
- _tests_failed++ ;
- }
- _listener.stopListener() ;
- }
- catch ( Exception ex )
- {
- System.err.println( _unit_test + " test1 " + ex ) ;
- _tests_failed++ ;
- }
- }
-
- private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.TransactionStatusConnectorTest: " ;
- private static final int _test_port = 4321 ;
+ _listener = new Listener(_test_service_socket, _test_service);
+ _listener.start();
- private static TransactionStatusConnectorTestService _test_service ;
+ setupOk = true;
+ }
+ }
+ catch (Exception ex) {
+ System.err.println("test_setup: Failed " + ex);
+ }
- private static Socket _test_socket ;
- private static String _test_host ;
- private static ServerSocket _test_service_socket ;
-
- private static Listener _listener ;
-
- private static Uid _pidUid ;
- private static String _pidStr ;
-
- private static BufferedReader _from_test_service ;
- private static PrintWriter _to_test_service ;
-
- private static int _test_status ;
- private static int _test_status_1 ;
- private static int _test_status_2 ;
- private static int _test_status_3 ;
- private static int _test_status_4 ;
-
- private static Uid _test_uid_1 ;
- private static Uid _test_uid_2 ;
- private static Uid _test_uid_3 ;
- private static Uid _test_uid_4 ;
-
- private static String _test_tran_type_1 ;
- private static String _test_tran_type_2 ;
- private static String _test_tran_type_3 ;
- private static String _test_tran_type_4 ;
-
- private static String _rx_tran_type_1 ;
- private static String _rx_tran_type_2 ;
- private static String _rx_tran_type_3 ;
- private static String _rx_tran_type_4 ;
-
- private static String _rx_uid_str_1 ;
- private static String _rx_uid_str_2 ;
- private static String _rx_uid_str_3 ;
- private static String _rx_uid_str_4 ;
-
- private static int _tests_passed = 0 ;
- private static int _tests_failed = 0 ;
+ return setupOk;
+ }
+
+ /**
+ * Test which checks that a transaction status connector can be
+ * created and transaction statuses can be retrieved using a simple
+ * test service.
+ */
+ private static void test1()
+ {
+ try {
+ TransactionStatusConnector testTransactionStatusConnector =
+ new TransactionStatusConnector(_pidStr, _pidUid);
+
+ _test_service._test_status = Integer.toString(_test_status_1);
+ int test_status1 = testTransactionStatusConnector.getTransactionStatus
+ (_test_tran_type_1, _test_uid_1);
+ _rx_tran_type_1 = _test_service._rx_tran_type;
+ _rx_uid_str_1 = _test_service._rx_uid_str;
+
+ _test_service._test_status = Integer.toString(_test_status_2);
+ int test_status2 = testTransactionStatusConnector.getTransactionStatus
+ (_test_tran_type_2, _test_uid_2);
+ _rx_tran_type_2 = _test_service._rx_tran_type;
+ _rx_uid_str_2 = _test_service._rx_uid_str;
+
+ _test_service._test_status = Integer.toString(_test_status_3);
+ int test_status3 = testTransactionStatusConnector.getTransactionStatus
+ (_test_tran_type_3, _test_uid_3);
+ _rx_tran_type_3 = _test_service._rx_tran_type;
+ _rx_uid_str_3 = _test_service._rx_uid_str;
+
+ _test_service._test_status = Integer.toString(_test_status_4);
+ int test_status4 = testTransactionStatusConnector.getTransactionStatus
+ (_test_tran_type_4, _test_uid_4);
+ _rx_tran_type_4 = _test_service._rx_tran_type;
+ _rx_uid_str_4 = _test_service._rx_uid_str;
+
+ if ((test_status1 == _test_status_1) &&
+ (test_status2 == _test_status_2) &&
+ (test_status3 == _test_status_3) &&
+ (test_status4 == _test_status_4) &&
+ (_rx_tran_type_1.equals(_test_tran_type_1)) &&
+ (_rx_tran_type_2.equals(_test_tran_type_2)) &&
+ (_rx_tran_type_3.equals(_test_tran_type_3)) &&
+ (_rx_tran_type_4.equals(_test_tran_type_4)) &&
+ (_rx_uid_str_1.equals(_test_uid_1.toString())) &&
+ (_rx_uid_str_2.equals(_test_uid_2.toString())) &&
+ (_rx_uid_str_3.equals(_test_uid_3.toString())) &&
+ (_rx_uid_str_4.equals(_test_uid_4.toString()))) {
+ System.out.println(_unit_test + "test1: passed");
+ _tests_passed++;
+ } else {
+ System.out.println(_unit_test + "test1: failed");
+ _tests_failed++;
+ }
+ _listener.stopListener();
+ }
+ catch (Exception ex) {
+ System.err.println(_unit_test + " test1 " + ex);
+ _tests_failed++;
+ }
+ }
+
+ private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.TransactionStatusConnectorTest: ";
+ private static final int _test_port = 4321;
+
+ private static TransactionStatusConnectorTestService _test_service;
+
+ private static Socket _test_socket;
+ private static String _test_host;
+ private static ServerSocket _test_service_socket;
+
+ private static Listener _listener;
+
+ private static Uid _pidUid;
+ private static String _pidStr;
+
+ private static BufferedReader _from_test_service;
+ private static PrintWriter _to_test_service;
+
+ private static int _test_status;
+ private static int _test_status_1;
+ private static int _test_status_2;
+ private static int _test_status_3;
+ private static int _test_status_4;
+
+ private static Uid _test_uid_1;
+ private static Uid _test_uid_2;
+ private static Uid _test_uid_3;
+ private static Uid _test_uid_4;
+
+ private static String _test_tran_type_1;
+ private static String _test_tran_type_2;
+ private static String _test_tran_type_3;
+ private static String _test_tran_type_4;
+
+ private static String _rx_tran_type_1;
+ private static String _rx_tran_type_2;
+ private static String _rx_tran_type_3;
+ private static String _rx_tran_type_4;
+
+ private static String _rx_uid_str_1;
+ private static String _rx_uid_str_2;
+ private static String _rx_uid_str_3;
+ private static String _rx_uid_str_4;
+
+ private static int _tests_passed = 0;
+ private static int _tests_failed = 0;
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusManagerItemTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusManagerItemTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/TransactionStatusManagerItemTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,112 +31,38 @@
* $Id: TransactionStatusManagerItemTest.java 2342 2006-03-30 13:06:17Z $
*/
-import java.net.* ;
+import java.net.*;
-import com.arjuna.ats.arjuna.utils.Utility ;
-import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem ;
+import com.arjuna.ats.arjuna.utils.Utility;
+import com.arjuna.ats.internal.arjuna.recovery.TransactionStatusManagerItem;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class TransactionStatusManagerItemTest
{
- public static void main( String[] args )
- {
- if ( test_setup() )
- {
- try
- {
- test1() ;
- test2() ;
-
- System.out.println( _unit_test + "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed ) ;
- }
- catch ( Exception ex )
- {
- System.err.println( "FATAL EXCEPTION: " +
- "tests passed: " + _tests_passed +
- " tests failed: " + _tests_failed ) ;
-
- }
- }
- }
-
- /**
- * Pre-test setup.
- */
- private static boolean test_setup()
- {
- boolean setupOk = false ;
-
- try
- {
- _tests_passed = 0 ;
- _tests_failed = 0 ;
- _test_host = InetAddress.getLocalHost().getHostAddress() ;
- setupOk = true ;
- }
- catch ( UnknownHostException ex )
- {
- System.err.println( "test_setup: UnknownHost " + ex ) ;
- }
-
- return setupOk ;
- }
-
- /**
- * Check that a transaction status manager item can be created
- * correctly.
- */
- private static void test1()
- {
- if ( TransactionStatusManagerItem.createAndSave( _test_port ) )
- {
- _tsmi = TransactionStatusManagerItem.get() ;
+ @Test
+ public void test() throws Exception
+ {
+ int _test_port = 4321;
+ String _test_host = InetAddress.getLocalHost().getHostAddress();
- if ( ( _tsmi.port() == _test_port ) &&
- ( _tsmi.host().equals( _test_host ) ) )
- {
- System.out.println( _unit_test + "test1: passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test1: failed" ) ;
- _tests_failed++ ;
- }
- }
- else
- {
- System.out.println( _unit_test + "test1: failed" ) ;
- _tests_failed++ ;
- }
- }
+ // Check that a transaction status manager item can be created correctly.
- /**
- * Check that a transaction status manager item can be re-created
- * correctly.
- */
- private static void test2()
- {
- _tsmi = null ;
- _tsmi = TransactionStatusManagerItem.recreate( Utility.getProcessUid() ) ;
+ assertTrue( TransactionStatusManagerItem.createAndSave(_test_port) );
- if ( ( _tsmi.port() == _test_port ) &&
- ( _tsmi.host().equals( _test_host ) ) )
- {
- System.out.println( _unit_test + "test2: passed" ) ;
- _tests_passed++ ;
- }
- else
- {
- System.out.println( _unit_test + "test2: failed" ) ;
- _tests_failed++ ;
- }
- }
-
- private static final int _test_port = 4321 ;
- private static String _test_host = "" ;
- private static final String _unit_test = "com.hp.mwtests.ts.arjuna.recovery.TransactionStatusManagerItemTest: " ;
- private static TransactionStatusManagerItem _tsmi = null ;
- private static int _tests_passed = 0 ;
- private static int _tests_failed = 0 ;
+ TransactionStatusManagerItem _tsmi = TransactionStatusManagerItem.get();
+
+ assertEquals(_test_port, _tsmi.port());
+ assertEquals(_test_host, _tsmi.host());
+
+ // Check that a transaction status manager item can be re-created correctly.
+
+ _tsmi = null;
+ _tsmi = TransactionStatusManagerItem.recreate(Utility.getProcessUid());
+
+ assertEquals(_test_port, _tsmi.port());
+ assertEquals(_test_host, _tsmi.host());
+
+ }
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/UserDefFirst0Setup.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/UserDefFirst0Setup.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/UserDefFirst0Setup.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,49 +31,48 @@
* $Id: UserDefFirst0Setup.java 2342 2006-03-30 13:06:17Z $
*/
-import com.arjuna.ats.arjuna.coordinator.RecordType ;
-import com.arjuna.ats.arjuna.gandiva.ClassName ;
-import com.arjuna.ats.arjuna.gandiva.ObjectName ;
-import com.arjuna.ats.arjuna.gandiva.inventory.InventoryElement ;
+import com.arjuna.ats.arjuna.gandiva.ClassName;
+import com.arjuna.ats.arjuna.gandiva.ObjectName;
+import com.arjuna.ats.arjuna.gandiva.inventory.InventoryElement;
public class UserDefFirst0Setup implements InventoryElement
{
- public UserDefFirst0Setup ()
- {
- }
+ public UserDefFirst0Setup()
+ {
+ }
- public synchronized Object createVoid ()
- {
- return CrashAbstractRecordImpl.create();
- }
+ public synchronized Object createVoid()
+ {
+ return CrashAbstractRecordImpl.create();
+ }
- public synchronized Object createClassName (ClassName className)
- {
- return null;
- }
+ public synchronized Object createClassName(ClassName className)
+ {
+ return null;
+ }
- public synchronized Object createObjectName (ObjectName objectName)
- {
- return null;
- }
+ public synchronized Object createObjectName(ObjectName objectName)
+ {
+ return null;
+ }
- public synchronized Object createResources (Object[] resources)
- {
- return null;
- }
+ public synchronized Object createResources(Object[] resources)
+ {
+ return null;
+ }
- public synchronized Object createClassNameResources (ClassName className, Object[] resources)
- {
- return null;
- }
+ public synchronized Object createClassNameResources(ClassName className, Object[] resources)
+ {
+ return null;
+ }
- public synchronized Object createObjectNameResources (ObjectName objectName, Object[] resources)
- {
- return null;
- }
+ public synchronized Object createObjectNameResources(ObjectName objectName, Object[] resources)
+ {
+ return null;
+ }
- public ClassName className ()
- {
- return new ClassName("RecordType.USER_DEF_FIRST0");
- }
+ public ClassName className()
+ {
+ return new ClassName("RecordType.USER_DEF_FIRST0");
+ }
}
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 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicObject.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -38,106 +38,100 @@
public class BasicObject extends StateManager
{
- public BasicObject ()
+ public BasicObject()
{
- super(ObjectType.ANDPERSISTENT);
+ super(ObjectType.ANDPERSISTENT);
- state = 0;
+ state = 0;
- System.out.println("Created basic object.");
+ System.out.println("Created basic object.");
- activate();
- modified();
- deactivate();
+ activate();
+ modified();
+ deactivate();
}
- public BasicObject (Uid u)
+ public BasicObject(Uid u)
{
- super(u, ObjectType.ANDPERSISTENT);
+ super(u, ObjectType.ANDPERSISTENT);
- state = -1;
-
- activate();
+ state = -1;
+
+ activate();
}
-
- public void incr (int value)
+
+ public void incr(int value)
{
- modified();
-
- state += value;
+ modified();
+
+ state += value;
}
-
- public void set (int value)
+
+ public void set(int value)
{
- modified();
-
- state = value;
+ modified();
+
+ state = value;
}
- public int get ()
+ public int get()
{
- if (activate())
- return state;
- else
- return -1;
+ if (activate())
+ return state;
+ else
+ return -1;
}
- public String type ()
+ public String type()
{
- return "StateManager/BasicObject";
+ return "StateManager/BasicObject";
}
-
- public boolean deactivate ()
+
+ public boolean deactivate()
{
return super.deactivate();
}
-
- public boolean activate ()
+
+ public boolean activate()
{
return super.activate();
}
-
- public boolean save_state (OutputObjectState os, int type)
+
+ public boolean save_state(OutputObjectState os, int type)
{
- try
- {
- os.packInt(state);
- os.packBytes(moreState);
- }
- catch (Exception ex)
- {
- return false;
- }
+ try {
+ os.packInt(state);
+ os.packBytes(moreState);
+ }
+ catch (Exception ex) {
+ return false;
+ }
- return true;
+ return true;
}
-
- public boolean restore_state (InputObjectState os, int 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 true;
+ 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 true;
}
-
+
private int state;
private byte[] moreState = {'a', 'b', 'c', 'd'};
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicRecord.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicRecord.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -35,107 +35,108 @@
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.gandiva.ClassName;
+
import java.io.PrintWriter;
public class BasicRecord extends AbstractRecord
{
- public BasicRecord ()
+ public BasicRecord()
{
- super(new Uid());
+ super(new Uid());
}
- public int typeIs ()
+ public int typeIs()
{
- return RecordType.USER_DEF_FIRST0;
+ return RecordType.USER_DEF_FIRST0;
}
- public ClassName className ()
+ public ClassName className()
{
- return new ClassName("BasicRecord");
+ return new ClassName("BasicRecord");
}
-
- public int nestedAbort ()
+
+ public int nestedAbort()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
-
- public int nestedCommit ()
+
+ public int nestedCommit()
{
- return TwoPhaseOutcome.FINISH_ERROR;
+ return TwoPhaseOutcome.FINISH_ERROR;
}
-
- public int nestedPrepare ()
+
+ public int nestedPrepare()
{
- return TwoPhaseOutcome.PREPARE_NOTOK;
+ return TwoPhaseOutcome.PREPARE_NOTOK;
}
-
- public int topLevelAbort ()
+
+ public int topLevelAbort()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
-
- public int topLevelCommit ()
+
+ public int topLevelCommit()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
-
- public int topLevelPrepare ()
+
+ public int topLevelPrepare()
{
- return TwoPhaseOutcome.PREPARE_OK;
+ return TwoPhaseOutcome.PREPARE_OK;
}
-
- public void print (PrintWriter strm)
+
+ public void print(PrintWriter strm)
{
- strm.println("Shutdown for:");
- super.print(strm);
+ strm.println("Shutdown for:");
+ super.print(strm);
}
- public boolean doSave ()
+ public boolean doSave()
{
- return true;
+ return true;
}
-
- public boolean save_state (OutputObjectState os, int ot)
+
+ public boolean save_state(OutputObjectState os, int ot)
{
- return true;
+ return true;
}
- public boolean restore_state (InputObjectState os, int ot)
+ public boolean restore_state(InputObjectState os, int ot)
{
- return true;
+ return true;
}
-
- public String type ()
+
+ public String type()
{
- return "/StateManager/AbstractRecord/BasicRecord";
+ return "/StateManager/AbstractRecord/BasicRecord";
}
-
- public boolean shouldAdd (AbstractRecord a)
+
+ public boolean shouldAdd(AbstractRecord a)
{
- return false;
+ return false;
}
-
- public boolean shouldMerge (AbstractRecord a)
+
+ public boolean shouldMerge(AbstractRecord a)
{
- return false;
+ return false;
}
-
- public boolean shouldReplace (AbstractRecord a)
+
+ public boolean shouldReplace(AbstractRecord a)
{
- return false;
+ return false;
}
-
- public boolean shouldAlter (AbstractRecord a)
+
+ public boolean shouldAlter(AbstractRecord a)
{
- return false;
+ return false;
}
- public void merge (AbstractRecord a)
+ public void merge(AbstractRecord a)
{
}
-
- public void alter (AbstractRecord a)
+
+ public void alter(AbstractRecord a)
{
}
@@ -143,14 +144,14 @@
* @return <code>Object</code> to be used to order.
*/
- public Object value ()
+ public Object value()
{
- return null;
+ return null;
}
-
- public void setValue (Object o)
+
+ public void setValue(Object o)
{
}
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicThreadedObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicThreadedObject.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/BasicThreadedObject.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,81 +33,67 @@
import com.arjuna.ats.arjuna.AtomicAction;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.common.*;
+
import java.lang.Thread;
-import java.lang.Math;
-import java.util.Random;
-import com.hp.mwtests.ts.arjuna.exceptions.TestException;
-
-import java.lang.InterruptedException;
-
public class BasicThreadedObject extends Thread
{
-
-public BasicThreadedObject (boolean start)
+
+ public BasicThreadedObject(boolean start)
{
- startAction = start;
- uid = new Uid();
+ startAction = start;
+ uid = new Uid();
}
-public void run ()
+ public void run()
{
- if (startAction)
- {
- BasicThreadedObject.A = new AtomicAction();
+ if (startAction) {
+ BasicThreadedObject.A = new AtomicAction();
- System.out.println("BasicThreadedObject "+uid+" created action "+BasicThreadedObject.A.get_uid());
+ System.out.println("BasicThreadedObject " + uid + " created action " + BasicThreadedObject.A.get_uid());
- BasicThreadedObject.A.begin();
+ BasicThreadedObject.A.begin();
- Thread.yield();
- }
- else
- {
- System.out.println("BasicThreadedObject "+uid+" adding to action "+BasicThreadedObject.A.get_uid());
-
- BasicThreadedObject.A.addThread();
+ Thread.yield();
+ } else {
+ System.out.println("BasicThreadedObject " + uid + " adding to action " + BasicThreadedObject.A.get_uid());
- Thread.yield();
- }
+ BasicThreadedObject.A.addThread();
- BasicAction act = BasicAction.Current();
+ Thread.yield();
+ }
- if (act != null)
- System.out.println("BasicThreadedObject "+uid+" current action "+act.get_uid());
- else
- System.out.println("BasicThreadedObject "+uid+" current action null");
+ BasicAction act = BasicAction.Current();
- try
- {
- BasicThreadedObject.O.incr(4);
+ if (act != null)
+ System.out.println("BasicThreadedObject " + uid + " current action " + act.get_uid());
+ else
+ System.out.println("BasicThreadedObject " + uid + " current action null");
- Thread.yield();
- }
- catch (Exception e)
- {
- }
-
- if (startAction)
- {
- System.out.println("\nBasicThreadedObject "+uid+" committing action "+act.get_uid());
- BasicThreadedObject.A.commit();
- System.out.println("BasicThreadedObject "+uid+" action "+act.get_uid()+" committed\n");
- }
- else
- {
- System.out.println("\nBasicThreadedObject "+uid+" aborting action "+act.get_uid());
- BasicThreadedObject.A.abort();
- System.out.println("BasicThreadedObject "+uid+" action "+act.get_uid()+" aborted\n");
- }
+ try {
+ BasicThreadedObject.O.incr(4);
+
+ Thread.yield();
+ }
+ catch (Exception e) {
+ }
+
+ if (startAction) {
+ System.out.println("\nBasicThreadedObject " + uid + " committing action " + act.get_uid());
+ BasicThreadedObject.A.commit();
+ System.out.println("BasicThreadedObject " + uid + " action " + act.get_uid() + " committed\n");
+ } else {
+ System.out.println("\nBasicThreadedObject " + uid + " aborting action " + act.get_uid());
+ BasicThreadedObject.A.abort();
+ System.out.println("BasicThreadedObject " + uid + " action " + act.get_uid() + " aborted\n");
+ }
}
-private Uid uid;
-private boolean startAction;
+ private Uid uid;
+ private boolean startAction;
-public static AtomicAction A = null;
-public static SimpleObject O = new SimpleObject();
-
+ public static AtomicAction A = null;
+ public static SimpleObject O = new SimpleObject();
+
};
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhase.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/OnePhase.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -31,9 +31,7 @@
package com.hp.mwtests.ts.arjuna.resources;
-import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.state.*;
import java.io.IOException;
@@ -44,42 +42,42 @@
public static final int PREPARED = 0;
public static final int COMMITTED = 1;
public static final int ROLLEDBACK = 2;
-
+
/**
* Return values from TwoPhaseOutcome to indicate success or failure.
*/
- public int commit ()
+ public int commit()
{
- _status = COMMITTED;
-
- return TwoPhaseOutcome.FINISH_OK;
+ _status = COMMITTED;
+
+ return TwoPhaseOutcome.FINISH_OK;
}
-
+
/**
* Return values from TwoPhaseOutcome to indicate success or failure.
*/
-
- public int rollback ()
+
+ public int rollback()
{
- _status = ROLLEDBACK;
-
- return TwoPhaseOutcome.FINISH_OK;
+ _status = ROLLEDBACK;
+
+ return TwoPhaseOutcome.FINISH_OK;
}
- public void pack (OutputObjectState os) throws IOException
+ public void pack(OutputObjectState os) throws IOException
{
}
-
- public void unpack (InputObjectState os) throws IOException
+
+ public void unpack(InputObjectState os) throws IOException
{
}
- public final int status ()
+ public final int status()
{
- return _status;
+ return _status;
}
-
+
private int _status = PREPARED;
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ShutdownRecord.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ShutdownRecord.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/ShutdownRecord.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -35,118 +35,114 @@
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.state.*;
import com.arjuna.ats.arjuna.gandiva.ClassName;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
+
import java.io.PrintWriter;
-import java.io.IOException;
-
-import com.arjuna.common.util.logging.*;
-
public class ShutdownRecord extends AbstractRecord
{
public static final int FAIL_IN_PREPARE = 0;
public static final int FAIL_IN_COMMIT = 1;
-
- public ShutdownRecord (int failurePoint)
+
+ public ShutdownRecord(int failurePoint)
{
- super(new Uid());
-
- _failurePoint = failurePoint;
+ super(new Uid());
+
+ _failurePoint = failurePoint;
}
- public int typeIs ()
+ public int typeIs()
{
- return RecordType.USER_DEF_FIRST0;
+ return RecordType.USER_DEF_FIRST0;
}
- public ClassName className ()
+ public ClassName className()
{
- return new ClassName("ShutdownRecord");
+ return new ClassName("ShutdownRecord");
}
-
- public int nestedAbort ()
+
+ public int nestedAbort()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
-
- public int nestedCommit ()
+
+ public int nestedCommit()
{
- return TwoPhaseOutcome.FINISH_ERROR;
+ return TwoPhaseOutcome.FINISH_ERROR;
}
-
- public int nestedPrepare ()
+
+ public int nestedPrepare()
{
- return TwoPhaseOutcome.PREPARE_NOTOK;
+ return TwoPhaseOutcome.PREPARE_NOTOK;
}
-
- public int topLevelAbort ()
+
+ public int topLevelAbort()
{
- return TwoPhaseOutcome.FINISH_OK;
+ return TwoPhaseOutcome.FINISH_OK;
}
-
- public int topLevelCommit ()
+
+ public int topLevelCommit()
{
- if (_failurePoint == FAIL_IN_COMMIT)
- return TwoPhaseOutcome.FINISH_ERROR;
- else
- return TwoPhaseOutcome.FINISH_OK;
+ if (_failurePoint == FAIL_IN_COMMIT)
+ return TwoPhaseOutcome.FINISH_ERROR;
+ else
+ return TwoPhaseOutcome.FINISH_OK;
}
-
- public int topLevelPrepare ()
+
+ public int topLevelPrepare()
{
- if (_failurePoint == FAIL_IN_PREPARE)
- return TwoPhaseOutcome.PREPARE_NOTOK;
- else
- return TwoPhaseOutcome.PREPARE_OK;
+ if (_failurePoint == FAIL_IN_PREPARE)
+ return TwoPhaseOutcome.PREPARE_NOTOK;
+ else
+ return TwoPhaseOutcome.PREPARE_OK;
}
-
- public void print (PrintWriter strm)
+
+ public void print(PrintWriter strm)
{
- strm.println("Shutdown for:");
- super.print(strm);
+ strm.println("Shutdown for:");
+ super.print(strm);
}
-
- public boolean save_state (OutputObjectState os, int ot)
+
+ public boolean save_state(OutputObjectState os, int ot)
{
- return false;
+ return false;
}
- public boolean restore_state (InputObjectState os, int ot)
+ public boolean restore_state(InputObjectState os, int ot)
{
- return false;
+ return false;
}
-
- public String type ()
+
+ public String type()
{
- return "/StateManager/AbstractRecord/ShutdownRecord";
+ return "/StateManager/AbstractRecord/ShutdownRecord";
}
-
- public boolean shouldAdd (AbstractRecord a)
+
+ public boolean shouldAdd(AbstractRecord a)
{
- return false;
+ return false;
}
-
- public boolean shouldMerge (AbstractRecord a)
+
+ public boolean shouldMerge(AbstractRecord a)
{
- return false;
+ return false;
}
-
- public boolean shouldReplace (AbstractRecord a)
+
+ public boolean shouldReplace(AbstractRecord a)
{
- return false;
+ return false;
}
-
- public boolean shouldAlter (AbstractRecord a)
+
+ public boolean shouldAlter(AbstractRecord a)
{
- return false;
+ return false;
}
- public void merge (AbstractRecord a)
+ public void merge(AbstractRecord a)
{
}
-
- public void alter (AbstractRecord a)
+
+ public void alter(AbstractRecord a)
{
}
@@ -154,16 +150,16 @@
* @return <code>Object</code> to be used to order.
*/
- public Object value ()
+ public Object value()
{
- return null;
+ return null;
}
-
- public void setValue (Object o)
+
+ public void setValue(Object o)
{
}
private int _failurePoint = -1;
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SimpleObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SimpleObject.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SimpleObject.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -34,29 +34,29 @@
public class SimpleObject
{
-public SimpleObject ()
+ public SimpleObject()
{
- state = 0;
+ state = 0;
- System.out.println("Created simple object.");
+ System.out.println("Created simple object.");
}
-
-public void incr (int value)
+
+ public void incr(int value)
{
- state += value;
+ state += value;
}
-
-public void set (int value)
+
+ public void set(int value)
{
- state = value;
+ state = value;
}
-public int get ()
+ public int get()
{
- return state;
+ return state;
}
-private int state;
-
+ private int state;
+
};
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 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/SyncRecord.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -33,39 +33,30 @@
import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.ClassName;
-import com.arjuna.ats.arjuna.objectstore.ObjectStoreType;
-import java.io.PrintWriter;
-import java.io.IOException;
-
-import com.arjuna.common.util.logging.*;
-
public class SyncRecord implements SynchronizationRecord
{
-
- public boolean beforeCompletion ()
+ public boolean beforeCompletion()
{
- return true;
+ return true;
}
- public boolean afterCompletion (int status)
+ public boolean afterCompletion(int status)
{
- return true;
+ return true;
}
- public Uid get_uid ()
+ public Uid get_uid()
{
- return _theUid;
+ return _theUid;
}
private Uid _theUid = new Uid();
-
- public int compareTo(Object o) {
- SynchronizationRecord sr = (SynchronizationRecord)o;
- if(_theUid.equals(sr.get_uid())) {
+ public int compareTo(Object o)
+ {
+ SynchronizationRecord sr = (SynchronizationRecord) o;
+ if (_theUid.equals(sr.get_uid())) {
return 0;
} else {
return _theUid.lessThan(sr.get_uid()) ? -1 : 1;
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/security/SecurityTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/security/SecurityTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/security/SecurityTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -1,74 +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.
- */
-package com.hp.mwtests.ts.arjuna.security;
-
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: SecurityTest.java 2342 2006-03-30 13:06:17Z $
- */
-
-public class SecurityTest
-{
-
-public static void main (String[] args)
- {
- SecurityManager securityManager = System.getSecurityManager();
-
- if (securityManager == null)
- {
- /*
- * Means we were loaded locally, so no security manager.
- */
-
- System.out.println("Could not get SecurityManager.");
- System.exit(0);
- }
-
- try
- {
- securityManager.checkRead("/etc/passwd");
-
- System.out.println("Can read.");
- }
- catch (SecurityException e)
- {
- System.out.println("Cannot read.");
- }
-
- try
- {
- securityManager.checkWrite("/tmp/foo");
-
- System.out.println("Can write.");
- }
- catch (SecurityException e)
- {
- System.out.println("Cannot write.");
- }
- }
-
-}
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 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/statemanager/BasicTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,52 +32,24 @@
package com.hp.mwtests.ts.arjuna.statemanager;
import com.arjuna.ats.arjuna.AtomicAction;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.common.*;
import com.hp.mwtests.ts.arjuna.resources.*;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class BasicTest extends Test
+public class BasicTest
{
-
-public void run(String[] args)
+ @Test
+ public void test() throws Exception
{
- try
- {
- test();
+ AtomicAction A = new AtomicAction();
+ BasicObject bo = new BasicObject();
- assertSuccess();
- }
- catch (Exception e)
- {
- logInformation("Unexpected exception thrown - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ A.begin();
- System.gc();
+ bo.set(2);
- System.runFinalization();
+ A.commit();
}
-
-private void test () throws Exception
- {
- AtomicAction A = new AtomicAction();
- BasicObject bo = new BasicObject();
-
- A.begin();
-
- bo.set(2);
-
- A.commit();
- }
-
-public static void main(String[] args)
- {
- BasicTest test = new BasicTest();
- test.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
- test.run(args);
- }
-};
+}
Deleted: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/testframework/Wrapper.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/testframework/Wrapper.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/testframework/Wrapper.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -1,85 +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) 2008
- * @author JBoss Inc.
- */
-
-package com.hp.mwtests.ts.arjuna.testframework;
-
-import org.jboss.dtf.testframework.unittest.Test;
-
-import java.lang.reflect.Method;
-
-public class Wrapper
-{
- public static void main (String[] args)
- {
- String className = null;
-
- if ((args.length > 0) && args[0].equals("-class"))
- className = args[1];
-
- if (className == null)
- {
- System.err.println("No class specified. Usage: -class <test class> [args]");
-
- return;
- }
-
- String[] params = new String[args.length-2];
-
- System.arraycopy(args, 2, params, 0, args.length-2);
-
- Class c = null;
-
- try
- {
- c = Thread.currentThread().getContextClassLoader().loadClass(className);
-
- Test theTest = (Test) c.newInstance();
-
- theTest.initialise(null, null, params, new org.jboss.dtf.testframework.unittest.LocalHarness());
- theTest.run(params);
- }
- catch (ClassCastException ex)
- {
- try
- {
- Method mainMethod = c.getMethod("main", String[].class);
-
- if (mainMethod == null)
- {
- System.err.println("No main found for non-Test class.");
-
- return;
- }
-
- mainMethod.invoke(null, (Object) params);
- }
- catch (Exception x)
- {
- x.printStackTrace();
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/threadaction/ThreadActionTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/threadaction/ThreadActionTest.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/threadaction/ThreadActionTest.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,37 +32,38 @@
*/
import com.hp.mwtests.ts.arjuna.resources.BasicThreadedObject;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.coordinator.*;
+
import java.lang.Thread;
import java.lang.InterruptedException;
-
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class ThreadActionTest
{
-
-public static void main (String[] args)
+ @Test
+ public void test()
{
- BasicThreadedObject object1 = new BasicThreadedObject(true);
- BasicThreadedObject object2 = new BasicThreadedObject(false);
+ BasicThreadedObject object1 = new BasicThreadedObject(true);
+ BasicThreadedObject object2 = new BasicThreadedObject(false);
- System.out.println("Main thread has action "+BasicAction.Current());
+ System.out.println("Main thread has action " + BasicAction.Current());
- object1.start();
- object2.start();
+ object1.start();
+ object2.start();
- Thread.yield();
-
- try
- {
- object1.join();
- object2.join();
- }
- catch (InterruptedException e)
- {
- }
+ Thread.yield();
- System.out.println("Main thread has action "+BasicAction.Current());
+ try {
+ object1.join();
+ object2.join();
+ }
+ catch (InterruptedException e) {
+ }
+
+ System.out.println("Main thread has action " + BasicAction.Current());
}
-
-};
+
+}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUniqueness.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUniqueness.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUniqueness.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -32,17 +32,17 @@
*/
import com.arjuna.ats.arjuna.common.*;
+import org.junit.Test;
public class UidUniqueness
{
-
-public static void main (String[] args)
+ @Test
+ public void test()
{
- for (int i = 0; i < 100; i++)
- {
- Uid u = new Uid();
- System.out.println(u + " " + u.hashCode());
- }
+ for (int i = 0; i < 100; i++) {
+ Uid u = new Uid();
+ System.out.println(u + " " + u.hashCode());
+ }
}
-
+
}
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/xa/xidcheck.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/xa/xidcheck.java 2009-07-02 16:13:51 UTC (rev 27447)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/xa/xidcheck.java 2009-07-02 16:34:55 UTC (rev 27448)
@@ -35,26 +35,21 @@
import com.arjuna.ats.arjuna.xa.*;
import com.arjuna.ats.internal.arjuna.utils.*;
-class xidcheck
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class xidcheck
{
-
- public static void main (String[] args)
+ @Test
+ public void test()
{
- Uid test = new Uid();
- XID xidimple = XATxConverter.getXid(test, true);
+ Uid test = new Uid();
+ XID xidimple = XATxConverter.getXid(test, true);
- System.err.println(xidimple);
+ System.err.println(xidimple);
- Uid convertedUid = XATxConverter.getUid(xidimple);
-
- if (test.notEquals(convertedUid))
- {
- System.err.println(test+" "+convertedUid);
+ Uid convertedUid = XATxConverter.getUid(xidimple);
- System.err.println("Failed.");
- }
- else
- System.err.println("Passed.");
+ assertEquals(test, convertedUid);
}
-
}
More information about the jboss-svn-commits
mailing list