[jboss-svn-commits] JBL Code SVN: r27613 - in labs/jbosstm/trunk/ArjunaCore: arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore and 14 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jul 6 07:55:48 EDT 2009
Author: jhalliday
Date: 2009-07-06 07:55:48 -0400 (Mon, 06 Jul 2009)
New Revision: 27613
Added:
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/TestBase.java
Removed:
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/concurrencycontrol/ConcurrencyTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest3.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest4.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest5.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest6.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
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/recovery/RecoveryManagerStartStopTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/build.xml
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest1.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest2.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest3.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/AtomicTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/BasicActionTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/RecoverableTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObject.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObjectLog.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/BasicThreadedObject.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/HammerThreadedObject.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/RecoverableObject.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/destroy/DestroyTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/hammer/Hammer.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/nestedtoplevelaction/NestedTopLevelAction.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/objectmodeltest/ObjectModelTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest1.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest2.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/recovery/RecoveryTest.java
labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/threadaction/ThreadActionTest.java
Log:
Updates to unit tests, mostly txoj module. JBTM-576
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/build.xml 2009-07-06 11:55:48 UTC (rev 27613)
@@ -48,39 +48,23 @@
<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"/>
- <!-- this one leaves a record in the object store which breaks LogStressTest -->
- <exclude name="**/LastResource.java"/>
+
+ <!-- LogStressTest2 takes too long - needs moving to /qa -->
+ <exclude name="**/LogStressTest2.java"/>
+ <!-- ReaperTestCase2 and 3 have timing issues - adinn to fix - JBTM-567 -->
+ <exclude name="**/ReaperTestCase2.java"/>
+ <exclude name="**/ReaperTestCase3.java"/>
</fileset>
</tests>
</run.tests.macro>
- <run.tests.macro>
- <tests><fileset dir="tests/classes" includes="**/ReaperTestCase.java"/></tests>
- </run.tests.macro>
- <!--<run.tests.macro>
- <tests><fileset dir="tests/classes" includes="**/ReaperTestCase2.java"/></tests>
- </run.tests.macro>-->
- <run.tests.macro>
- <tests><fileset dir="tests/classes" includes="**/TxControlUnitTest.java"/></tests>
- </run.tests.macro>
- <run.tests.macro>
- <tests><fileset dir="tests/classes" includes="**/PersistenceUnitTest.java"/></tests>
- </run.tests.macro>
- <!-- this is failing when running on Hudson because of timing issues
- <run.tests.macro>
- <tests><fileset dir="tests/classes" includes="**/RecoveryManagerStartStopTest.java"/></tests>
- </run.tests.macro>
- -->
</target>
</project>
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-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/objectstore/LogStoreRecoveryTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -37,11 +37,12 @@
import com.arjuna.ats.arjuna.common.Environment;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.ats.arjuna.coordinator.TxControl;
+import com.hp.mwtests.ts.arjuna.resources.TestBase;
import org.junit.Test;
import static org.junit.Assert.*;
-public class LogStoreRecoveryTest
+public class LogStoreRecoveryTest extends TestBase
{
@Test
public void test()
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-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/recovery/RecoveryManagerStartStopTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -23,6 +23,7 @@
import com.arjuna.ats.arjuna.recovery.RecoveryManager;
import com.arjuna.ats.internal.arjuna.recovery.PeriodicRecovery;
+import com.arjuna.ats.arjuna.common.Environment;
import java.net.Socket;
import java.net.InetAddress;
@@ -42,6 +43,8 @@
@Test
public void testStartStop() throws Exception
{
+ System.setProperty(Environment.RECOVERY_MANAGER_PORT, "4712");
+
// check how many threads there are running
ThreadGroup thg = Thread.currentThread().getThreadGroup();
@@ -155,16 +158,12 @@
// get a socket connected to the listener
// don't write anything just sit on a read until the socket is closed
try {
- ServerSocket socket = PeriodicRecovery.getServerSocket();
- InetAddress address;
String host;
int port;
- address = socket.getInetAddress();
-
host = InetAddress.getLocalHost().getHostName();
- port = PeriodicRecovery.getServerSocket().getLocalPort();
+ port = Integer.parseInt(System.getProperty(Environment.RECOVERY_MANAGER_PORT));
System.out.println("client atempting to connect to host " + host + " port " + port);
System.out.flush();
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/TestBase.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/TestBase.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/resources/TestBase.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, 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) 2009,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.resources;
+
+import com.arjuna.ats.arjuna.common.arjPropertyManager;
+import com.arjuna.ats.arjuna.common.Environment;
+
+import java.io.File;
+
+import org.junit.Before;
+import org.junit.After;
+
+/**
+ * handy utility functions for unit tests.
+ */
+public class TestBase
+{
+ @Before
+ public void setUp()
+ {
+ emptyObjectStore();
+ }
+
+ @After
+ public void tearDown()
+ {
+ emptyObjectStore();
+ }
+
+ private void emptyObjectStore()
+ {
+ String objectStoreDirName = arjPropertyManager.getPropertyManager().getProperty(Environment.OBJECTSTORE_DIR, com.arjuna.ats.arjuna.common.Configuration.objectStoreRoot());
+
+ System.out.println("Emptying " + objectStoreDirName);
+
+ File objectStoreDir = new File(objectStoreDirName);
+
+ removeContents(objectStoreDir);
+ }
+
+ public void removeContents(File directory)
+ {
+ if ((directory != null) &&
+ directory.isDirectory() &&
+ (!directory.getName().equals("")) &&
+ (!directory.getName().equals("/")) &&
+ (!directory.getName().equals("\\")) &&
+ (!directory.getName().equals(".")) &&
+ (!directory.getName().equals("..")))
+ {
+ File[] contents = directory.listFiles();
+
+ for (int index = 0; index < contents.length; index++)
+ {
+ if (contents[index].isDirectory())
+ {
+ removeContents(contents[index]);
+
+ contents[index].delete();
+ }
+ else
+ {
+ contents[index].delete();
+ }
+ }
+ }
+ }
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/build.xml
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/build.xml 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/build.xml 2009-07-06 11:55:48 UTC (rev 27613)
@@ -22,7 +22,7 @@
<property name="modulename" value="txoj"/>
- <property name="global.ext.test.libs" value="junit.jar,TestingFramework.jar"/>
+ <property name="global.ext.test.libs" value="junit-4.6.jar"/>
<import file="../../sharedbuild.xml"/>
@@ -39,4 +39,20 @@
</propertyfile>
</target>
+ <target name="run.tests">
+
+ <run.tests.macro>
+ <tests>
+ <fileset dir="tests/classes" includes="**/*.java">
+ <exclude name="**/common/**"/>
+
+
+
+ <exclude name="**/DestroyTest.java"/>
+ </fileset>
+ </tests>
+ </run.tests.macro>
+
+ </target>
+
</project>
\ No newline at end of file
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest1.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest1.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest1.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -33,25 +33,23 @@
import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
-import com.arjuna.ats.arjuna.common.*;
import java.util.Random;
import java.lang.Math;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-public class AtomicObjectTest1 extends Test
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class AtomicObjectTest1
{
public static final int START_VALUE_1 = 10;
public static final int START_VALUE_2 = 101;
public static final int EXPECTED_RESULT = START_VALUE_1 + START_VALUE_2;
-
-public void run(String[] args)
+ @Test
+ public void test() throws TestException
{
rand = new Random();
@@ -61,29 +59,9 @@
System.out.println(atomicObject1.get_uid());
System.out.println(atomicObject2.get_uid());
- try
- {
- atomicObject1.set(START_VALUE_1);
- }
- catch (TestException e)
- {
- System.out.println("m set1 : failed");
- logInformation("ERROR - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ atomicObject1.set(START_VALUE_1);
- try
- {
- atomicObject2.set(START_VALUE_2);
- }
- catch (TestException e)
- {
- System.out.println("m set2 : failed");
- logInformation("ERROR - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ atomicObject2.set(START_VALUE_2);
get12('m', 0);
get21('m', 0);
@@ -94,21 +72,8 @@
get12('m', 0);
get21('m', 0);
- try
- {
- if ( ( getValue1() + getValue2() ) != EXPECTED_RESULT )
- {
- assertFailure();
- }
- }
- catch (TestException e)
- {
- assertFailure();
- logInformation("Unexpected Failure: "+e);
- e.printStackTrace(System.err);
- }
+ assertEquals(EXPECTED_RESULT, (getValue1()+getValue2()));
- assertSuccess();
}
private static void indent (char thr, int level)
@@ -426,13 +391,6 @@
}
}
-public static void main(String[] args)
- {
- AtomicObjectTest1 test = new AtomicObjectTest1();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
-
private static AtomicObject atomicObject1 = null;
private static AtomicObject atomicObject2 = null;
private static Random rand = null;
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest2.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest2.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -33,17 +33,15 @@
import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
-import com.arjuna.ats.arjuna.common.*;
import java.util.Random;
import java.lang.Math;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.lang.InterruptedException;
class ThreadObject1 extends Thread
@@ -64,15 +62,16 @@
private char chr;
-};
+}
-public class AtomicObjectTest2 extends Test
+public class AtomicObjectTest2
{
public static final int START_VALUE_1 = 10;
public static final int START_VALUE_2 = 101;
public static final int EXPECTED_RESULT = START_VALUE_1 + START_VALUE_2;
-public void run(String[] args)
+ @Test
+ public void test() throws TestException
{
rand = new Random();
atomicObject1 = new AtomicObject();
@@ -81,29 +80,9 @@
System.out.println(atomicObject1.get_uid());
System.out.println(atomicObject2.get_uid());
- try
- {
atomicObject1.set(START_VALUE_1);
- }
- catch (TestException e)
- {
- System.out.println("m set1 : failed");
- logInformation("ERROR - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
- try
- {
atomicObject2.set(START_VALUE_2);
- }
- catch (TestException e)
- {
- System.out.println("m set2 : failed");
- logInformation("ERROR - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
ThreadObject1 thr1 = new ThreadObject1('1');
ThreadObject1 thr2 = new ThreadObject1('2');
@@ -123,21 +102,8 @@
get12('m', 0);
get21('m', 0);
- try
- {
- if ( ( getValue1() + getValue2() ) != EXPECTED_RESULT )
- {
- assertFailure();
- }
- }
- catch (TestException e)
- {
- assertFailure();
- logInformation("Unexpected Failure: "+e);
- e.printStackTrace(System.err);
- }
+assertEquals(EXPECTED_RESULT, (getValue1()+getValue2()));
- assertSuccess();
}
public static void randomOperation (char thr, int level)
@@ -482,13 +448,6 @@
System.out.println(" get21 : "+res1+" : "+res2+" : "+res+" : "+value1+" : "+value2);
}
-public static void main(String[] args)
- {
- AtomicObjectTest2 test = new AtomicObjectTest2();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
-
private static AtomicObject atomicObject1 = null;
private static AtomicObject atomicObject2 = null;
private static Random rand = null;
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest3.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest3.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/atomicobject/AtomicObjectTest3.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -33,22 +33,19 @@
import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
-import com.arjuna.ats.arjuna.common.*;
import java.util.Random;
import java.lang.Math;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.lang.InterruptedException;
class AbortObject extends Thread
{
-
public AbortObject ()
{
}
@@ -77,7 +74,7 @@
private static int nextThreadId = 3;
-};
+}
class CommitObject extends Thread
@@ -111,7 +108,7 @@
private static int nextThreadId = 3;
-};
+}
class ThreadObject2 extends Thread
@@ -133,17 +130,17 @@
private int _value;
-};
+}
-public class AtomicObjectTest3 extends Test
+public class AtomicObjectTest3
{
public static final int START_VALUE_1 = 10;
public static final int START_VALUE_2 = 101;
public static final int EXPECTED_RESULT = START_VALUE_1 + START_VALUE_2;
-
-public void run(String[] args)
+ @Test
+ public void test() throws TestException
{
rand = new Random();
atomicObject1 = new AtomicObject();
@@ -188,21 +185,7 @@
get12(0, 0);
get21(0, 0);
- try
- {
- if ( ( getValue1() + getValue2() ) != EXPECTED_RESULT )
- {
- assertFailure();
- }
- }
- catch (TestException e)
- {
- assertFailure();
- logInformation("Unexpected Failure: "+e);
- e.printStackTrace(System.err);
- }
-
- assertSuccess();
+ assertEquals(EXPECTED_RESULT, (getValue1()+getValue2()));
}
public static void randomOperation (int thr, int level)
@@ -641,15 +624,8 @@
System.out.println(" get21 : "+res1+" : "+res2+" : "+res+" : "+value1+" : "+value2);
}
-public static void main(String[] args)
- {
- AtomicObjectTest3 test = new AtomicObjectTest3();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
-
private static AtomicObject atomicObject1 = null;
private static AtomicObject atomicObject2 = null;
private static Random rand = null;
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/AtomicTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/AtomicTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/AtomicTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,91 +32,58 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
import com.arjuna.ats.arjuna.common.*;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-public class AtomicTest extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class AtomicTest
+{
+ @Test
+ public void run()
{
AtomicObject foo = new AtomicObject();
Uid u = foo.get_uid();
- int v;
AtomicAction A = new AtomicAction();
- try
- {
+ try {
A.begin();
- logInformation("current object value is "+foo.get());
-
foo.set(2);
- logInformation("object value is now "+foo.get());
-
A.commit();
int finalVal = foo.get();
- logInformation("final object value is now "+finalVal);
+ assertEquals(2, finalVal);
- if (finalVal == 2)
- logInformation("This is correct.");
- else
- {
- logInformation("This is incorrect.");
- assertFailure();
- }
- logInformation("\nStarting new action.");
-
foo = new AtomicObject(u);
A = new AtomicAction();
A.begin();
- logInformation("current object value is "+foo.get());
-
foo.set(4);
A.commit();
finalVal = foo.get();
- logInformation("final object value is "+finalVal);
+ assertEquals(4, finalVal);
- if (finalVal == 4)
- logInformation("This is correct.");
- else
- {
- logInformation("This is incorrect.");
- assertFailure();
- }
}
catch (TestException e)
{
- logInformation("AtomicObject exception raised.");
- e.printStackTrace(System.err);
- assertFailure();
-
A.abort();
+
+ fail("AtomicObject exception raised.");
}
- assertSuccess();
}
-public static void main(String[] args)
- {
- AtomicTest test = new AtomicTest();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/BasicActionTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/BasicActionTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/BasicActionTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,41 +32,22 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
import com.arjuna.ats.arjuna.common.*;
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
+import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-public class BasicActionTest extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class BasicActionTest
+{
+ @Test
+ public void run() throws TestException
{
AtomicObject foo = null;
Uid u = null;
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-uid") == 0)
- {
- u = new Uid(args[i+1]);
-
- if (!u.valid())
- {
- System.out.println("Invalid uid.");
- System.exit(1);
- }
- }
- if (args[i].compareTo("-help") == 0)
- {
- System.out.println("Usage: [-uid <uid>] [-help]");
- assertFailure();
- }
- }
-
if (u == null)
foo = new AtomicObject();
else
@@ -74,56 +55,26 @@
AtomicAction A = new AtomicAction();
+ int value = foo.get();
try
{
A.begin();
- try
- {
- logInformation("current object value is "+foo.get());
- }
- catch (Exception e)
- {
- }
-
- try
- {
- logInformation("setting value");
-
foo.set(foo.get()+2);
- }
- catch (Exception e)
- {
- }
- try
- {
- logInformation("object value is now "+foo.get());
- }
- catch (Exception e)
- {
- }
-
A.commit();
- try
- {
- logInformation("final object value is now "+foo.get());
- }
- catch (Exception e)
- {
- }
+ assertEquals(value+2, foo.get());
+
}
catch (Exception e)
{
- logInformation("AtomicObject exception raised.");
A.abort();
+ fail("AtomicObject exception raised.");
}
- logInformation("\nWill now try some erroneous conditions.\n");
+ System.out.println("\nWill now try some erroneous conditions.\n");
- try
- {
AtomicAction B = new AtomicAction();
u = new Uid();
@@ -133,13 +84,13 @@
try
{
- logInformation("attempting to get value from non-existent object: "+foo.get());
+ System.out.println("attempting to get value from non-existent object: "+foo.get());
}
catch (Exception e)
{
}
- logInformation("trying to set value to 5");
+ System.out.println("trying to set value to 5");
try
{
@@ -151,7 +102,7 @@
try
{
- logInformation("attempting to get value again: "+foo.get());
+ System.out.println("attempting to get value again: "+foo.get());
}
catch (Exception e)
{
@@ -159,20 +110,5 @@
B.commit();
}
- catch (Exception e)
- {
- logInformation("Unexpected Exception - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
- assertSuccess();
- }
-
-public static void main(String[] args)
- {
- BasicActionTest test = new BasicActionTest();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/PersistenceTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -33,84 +33,28 @@
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 com.arjuna.ats.txoj.common.*;
-import java.io.*;
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.arjuna.ats.arjuna.exceptions.ObjectStoreException;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-public class PersistenceTest extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
- {
- boolean passed = false;
- try
- {
+public class PersistenceTest
+{
+ @Test
+ public void test() throws ObjectStoreException
+ {
ObjectStore store = new ObjectStore(ArjunaNames.Implementation_ObjectStore_ShadowingStore());
OutputObjectState state = new OutputObjectState();
Uid u = new Uid();
- logInformation("Uid is "+u);
+ assertTrue( store.write_committed(u, "/StateManager/LockManager/foo", state) );
- if (store.write_committed(u, "/StateManager/LockManager/foo", state))
- {
- logInformation("written ok");
-
- passed = true;
- }
- else
- logInformation("write error");
-
- if (passed)
- {
- passed = false;
-
- /*
- * Now try to read.
- */
-
InputObjectState inputState = store.read_committed(u, "/StateManager/LockManager/foo");
- if (inputState != null)
- {
- logInformation("read ok");
-
- passed = true;
- }
- else
- logInformation("read error");
- }
- }
- catch (ObjectStoreException e)
- {
- logInformation(e.getMessage());
-
- passed = false;
- }
-
- if (passed)
- {
- logInformation("Test passed");
- assertSuccess();
- }
- else
- {
- logInformation("Test failed");
- assertFailure();
- }
+ assertNotNull( inputState );
}
-
-public static void main(String[] args)
- {
- PersistenceTest test = new PersistenceTest();
- test.initialise(null, null, args, new LocalHarness());
- test.runTest();
- }
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/RecoverableTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/RecoverableTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/basic/RecoverableTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,77 +32,42 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.RecoverableObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-public class RecoverableTest extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class RecoverableTest
+{
+ @Test
+ public void test()
{
- boolean passed = false;
- RecoverableObject foo = new RecoverableObject();
- int value = 0;
+ RecoverableObject foo = new RecoverableObject();
- AtomicAction A = new AtomicAction();
+ AtomicAction A = new AtomicAction();
- A.begin();
+ A.begin();
- logInformation("value is "+foo.get());
+ foo.set(2);
- foo.set(2);
+ assertEquals(2, foo.get());
- logInformation("value is "+foo.get());
+ A.abort();
- A.abort();
+ assertEquals(0, foo.get());
- value = foo.get();
+ AtomicAction B = new AtomicAction();
- logInformation("value is now "+value);
+ B.begin();
- if (value == 0)
- {
- AtomicAction B = new AtomicAction();
+ foo.set(4);
- B.begin();
+ assertEquals(4, foo.get());
- logInformation("value is "+foo.get());
+ B.commit();
- foo.set(4);
-
- logInformation("value is "+foo.get());
-
- B.commit();
-
- value = foo.get();
-
- logInformation("value is now "+value);
-
- if (value == 4)
- passed = true;
- }
-
- if (passed)
- {
- logInformation("Test passed");
- assertSuccess();
- }
- else
- {
- logInformation("Test failed");
- assertFailure();
- }
+ assertEquals(4, foo.get());
}
-
-public static void main(String[] args)
- {
- RecoverableTest test = new RecoverableTest();
- test.initialise(null, null, args, new LocalHarness());
- test.runTest();
- }
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObject.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObject.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -37,8 +37,6 @@
import com.arjuna.ats.arjuna.gandiva.*;
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.txoj.*;
-import com.arjuna.ats.txoj.common.*;
-import java.io.*;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import java.io.IOException;
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObjectLog.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObjectLog.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/AtomicObjectLog.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -37,12 +37,9 @@
import com.arjuna.ats.arjuna.gandiva.*;
import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.txoj.*;
-import com.arjuna.ats.txoj.common.*;
import com.arjuna.ats.internal.arjuna.coordinator.*;
-import java.io.*;
-
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import java.io.IOException;
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/BasicThreadedObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/BasicThreadedObject.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/BasicThreadedObject.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -33,18 +33,11 @@
import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.txoj.*;
-import com.arjuna.ats.txoj.common.*;
import java.lang.Thread;
-import java.lang.Math;
-import java.util.Random;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-import java.lang.InterruptedException;
public class BasicThreadedObject extends Thread
{
@@ -113,4 +106,4 @@
public static AtomicAction A = null;
public static AtomicObject O = new AtomicObject();
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/HammerThreadedObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/HammerThreadedObject.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/HammerThreadedObject.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,14 +32,8 @@
package com.hp.mwtests.ts.txoj.common.resources;
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
import com.arjuna.ats.arjuna.common.*;
-import com.arjuna.ats.txoj.*;
-import com.arjuna.ats.txoj.common.*;
import java.lang.Thread;
-import java.lang.Math;
import java.util.Random;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
@@ -108,4 +102,4 @@
public static int iter = 100;
public static Random rand = new Random();
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/RecoverableObject.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/RecoverableObject.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/common/resources/RecoverableObject.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -34,10 +34,7 @@
import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.txoj.*;
-import com.arjuna.ats.txoj.common.*;
import java.io.IOException;
@@ -168,5 +165,5 @@
private int state;
-};
+}
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/concurrencycontrol/ConcurrencyTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/concurrencycontrol/ConcurrencyTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/concurrencycontrol/ConcurrencyTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -1,129 +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.txoj.concurrencycontrol;
-
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: ConcurrencyTest.java 2342 2006-03-30 13:06:17Z $
- */
-
-import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.txoj.common.*;
-import com.arjuna.ats.arjuna.common.*;
-
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-
-public class ConcurrencyTest extends Test
-{
-
-public void run(String[] args)
- {
- AtomicObject foo = null;
- Uid u = null;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-uid") == 0)
- {
- u = new Uid(args[i+1]);
-
- if (!u.valid())
- {
- logInformation("Invalid uid.");
- assertFailure();
- }
- }
- if (args[i].compareTo("-help") == 0)
- {
- System.out.println("Usage: [-uid <uid>] [-help]");
- assertFailure();
- }
- }
-
- if (u == null)
- foo = new AtomicObject();
- else
- foo = new AtomicObject(u);
-
- logInformation("Starting top-level action.");
-
- AtomicAction A = new AtomicAction();
-
- try
- {
- A.begin();
-
- logInformation("Current atomic object state: " + foo.get());
-
- foo.set(7);
-
- if (u == null)
- {
- logInformation("Now waiting for 20 seconds.");
-
- try
- {
- Thread.sleep(20000);
- }
- catch (InterruptedException e)
- {
- }
- }
-
- logInformation("\nCommitting top-level action.");
-
- if (A.commit() != ActionStatus.COMMITTED)
- {
- logInformation("Error when committing action.");
- assertFailure();
- }
- else
- {
- logInformation("Action committed.");
- }
- }
- catch (TestException e)
- {
- logInformation("Could not set state. Aborting action.");
- assertFailure();
- A.abort();
- }
-
- assertSuccess();
- }
-
-public static void main(String[] args)
- {
- ConcurrencyTest test = new ConcurrencyTest();
- test.initialise( null, null, args, new LocalHarness() );
- test.runTest();
- }
-};
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/destroy/DestroyTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/destroy/DestroyTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/destroy/DestroyTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,95 +32,33 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-import com.arjuna.ats.arjuna.coordinator.*;
import com.arjuna.ats.arjuna.common.*;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
-public class DestroyTest extends Test
-{
+import org.junit.Test;
+import static org.junit.Assert.*;
-public void run(String[] args)
+public class DestroyTest
+{
+ @Test
+ public void test() throws TestException
{
- AtomicObject atomicObject = new AtomicObject();
- Uid u = atomicObject.get_uid();
- AtomicAction a = new AtomicAction();
+ AtomicObject atomicObject = new AtomicObject();
+ Uid u = atomicObject.get_uid();
+ AtomicAction a = new AtomicAction();
- a.begin();
+ a.begin();
- try
- {
- atomicObject.set(10);
- }
- catch (TestException e)
- {
- logInformation("set : failed");
- logInformation("Unexpected exception - "+e);
- e.printStackTrace(System.err);
- assertFailure();
- }
+ atomicObject.set(10);
- logInformation("set : ok");
+ assertTrue(atomicObject.destroy());
- if (!atomicObject.destroy())
- {
- logInformation("destroy : failed");
+ a.commit();
- a.abort();
+ atomicObject = new AtomicObject(u);
- assertFailure();
- }
-
- a.commit();
-
- atomicObject = new AtomicObject(u);
-
- boolean passed = false;
-
- try
- {
- int val = atomicObject.get();
-
- if (val != -1)
- {
- logInformation("got : "+val);
-
- logInformation("destroy did not work!");
- }
- else
- {
- System.out.println("object destroyed!");
-
- passed = true;
- }
- }
- catch (TestException e)
- {
- System.out.println("object destroyed!");
-
- passed = true;
- }
-
- if (passed)
- System.out.println("Test passed");
- else
- {
- System.out.println("Test failed");
-
- assertFailure();
- }
-
- assertSuccess();
+ assertEquals(-1, atomicObject.get());
}
-
-public static void main(String[] args)
- {
- DestroyTest test = new DestroyTest();
- test.initialise(null, null, args, new LocalHarness());
- test.runTest();
- }
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/hammer/Hammer.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/hammer/Hammer.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/hammer/Hammer.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -31,48 +31,33 @@
* $Id: Hammer.java 2342 2006-03-30 13:06:17Z $
*/
-import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-import java.lang.Thread;
-import java.util.Random;
-
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
import com.hp.mwtests.ts.txoj.common.resources.HammerThreadedObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.unittest.LocalHarness;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
import java.lang.InterruptedException;
-public class Hammer extends Test
+public class Hammer
{
-
-public void run(String[] args)
+ @Test
+ public void test()
{
- HammerThreadedObject.object = new AtomicObject();
- HammerThreadedObject object1 = new HammerThreadedObject(2);
- HammerThreadedObject object2 = new HammerThreadedObject(-2);
+ HammerThreadedObject.object = new AtomicObject();
+ HammerThreadedObject object1 = new HammerThreadedObject(2);
+ HammerThreadedObject object2 = new HammerThreadedObject(-2);
- object1.start();
- object2.start();
+ object1.start();
+ object2.start();
- try
- {
- object1.join();
- object2.join();
- }
- catch (InterruptedException e)
- {
- }
-
- /* If we didn't deadlock, we'll get to here. */
- assertSuccess();
+ try
+ {
+ object1.join();
+ object2.join();
+ }
+ catch (InterruptedException e)
+ {
+ }
}
-
-public static void main(String[] args)
- {
- Hammer test = new Hammer();
- test.initialise(null, null, args, new LocalHarness());
- test.runTest();
- }
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/nestedtoplevelaction/NestedTopLevelAction.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/nestedtoplevelaction/NestedTopLevelAction.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/nestedtoplevelaction/NestedTopLevelAction.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,99 +32,74 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class NestedTopLevelAction
{
-
-public static void main (String[] args)
+ @Test
+ public void test()
{
- AtomicAction A = new AtomicAction();
- TopLevelAction B = new TopLevelAction();
- AtomicAction C = new AtomicAction();
- AtomicObject foo1 = new AtomicObject();
- AtomicObject foo2 = new AtomicObject();
- boolean passed = false;
+ AtomicAction A = new AtomicAction();
+ TopLevelAction B = new TopLevelAction();
+ AtomicAction C = new AtomicAction();
+ AtomicObject foo1 = new AtomicObject();
+ AtomicObject foo2 = new AtomicObject();
- try
- {
- System.out.println("\nStarting top-level action.\n");
-
- A.begin();
+ try
+ {
+ A.begin();
- System.out.println(A);
+ foo1.set(5);
- foo1.set(5);
+ System.out.println("Current atomic object 1 state: " + foo1.get());
- System.out.println("Current atomic object 1 state: " + foo1.get());
+ System.out.println("\nStarting nested top-level action.");
- System.out.println("\nStarting nested top-level action.");
+ B.begin();
- B.begin();
+ System.out.println(B);
- System.out.println(B);
+ foo2.set(7);
- foo2.set(7);
+ System.out.println("Current atomic object 2 state: " + foo2.get());
- System.out.println("Current atomic object 2 state: " + foo2.get());
+ System.out.println("\nCommitting nested top-level action.");
- System.out.println("\nCommitting nested top-level action.");
-
- B.commit();
+ B.commit();
- System.out.println("\nAborting top-level action.");
+ System.out.println("\nAborting top-level action.");
- A.abort();
+ A.abort();
- C.begin();
+ C.begin();
- int val1 = foo1.get();
- int val2 = foo2.get();
-
- System.out.println("\nFinal atomic object 1 state: " + val1);
-
- if (val1 == 0)
- {
- System.out.println("This is correct.");
+ int val1 = foo1.get();
+ int val2 = foo2.get();
- passed = true;
- }
- else
- System.out.println("This is incorrect.");
-
- System.out.println("\nFinal atomic object 2 state: " + val2);
+ System.out.println("\nFinal atomic object 1 state: " + val1);
- if (val2 == 7)
- {
- System.out.println("This is correct.");
+ assertEquals(0, val1);
- passed = passed && true;
- }
- else
- {
- System.out.println("This is incorrect.");
+ System.out.println("\nFinal atomic object 2 state: " + val2);
- passed = passed && true;
- }
-
- C.commit();
- }
- catch (TestException e)
- {
- System.out.println("AtomicObject exception raised.");
+ assertEquals(7, val2);
- A.abort();
- B.abort();
- C.abort();
- }
+ C.commit();
+ }
+ catch (TestException e)
+ {
+ A.abort();
+ B.abort();
+ C.abort();
- if (passed)
- System.out.println("Test passed");
- else
- System.out.println("Test failed");
+ fail("AtomicObject exception raised.");
+ }
+
}
-
-};
+
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/objectmodeltest/ObjectModelTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/objectmodeltest/ObjectModelTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/objectmodeltest/ObjectModelTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,92 +32,35 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.arjuna.common.*;
import com.arjuna.ats.arjuna.gandiva.*;
-import com.arjuna.ats.txoj.common.*;
-import com.arjuna.ats.txoj.*;
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
+import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+
public class ObjectModelTest
{
-
-public static void main (String[] args)
+ @Test
+ public void test() throws IOException, TestException
{
- ObjectName objName = null;
- boolean write = false;
- String uid = null;
- long objectModel = ObjectModel.SINGLE;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-single") == 0)
- objectModel = ObjectModel.SINGLE;
- if (args[i].compareTo("-multiple") == 0)
- objectModel = ObjectModel.MULTIPLE;
- if (args[i].compareTo("-write") == 0)
- write = true;
- if (args[i].compareTo("-uid") == 0)
- uid = args[i+1];
- if (args[i].compareTo("-help") == 0)
- {
- System.out.println("Usage: com.hp.mwtests.ts.txoj.objectmodeltest.ObjectModelTest [-uid <uid>] [-single] [-multiple] [-write] [-help]");
- System.exit(0);
- }
- }
+ long objectModel = ObjectModel.SINGLE;
+ ObjectName objName = ObjectName.uniqueObjectName("PNS");
+ objName.setLongAttribute(ArjunaNames.StateManager_objectModel(), objectModel);
- try
- {
- objName = ObjectName.uniqueObjectName("PNS");
- objName.setLongAttribute(ArjunaNames.StateManager_objectModel(), objectModel);
+ AtomicObject obj = new AtomicObject(objName);
+ AtomicAction A = new AtomicAction();
- System.out.println("ObjectName: "+objName);
- }
- catch (Exception e)
- {
- System.err.println(e);
- System.exit(-1);
- }
+ A.begin();
- try
- {
- AtomicObject obj = null;
+ obj.set(1234);
- if (uid != null)
- {
- Uid u = new Uid(uid);
-
- obj = new AtomicObject(u, objName);
- }
- else
- obj = new AtomicObject(objName);
+ A.commit();
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (write)
- {
- obj.set(1234);
- System.out.println("set state to 1234");
- }
- else
- System.out.println("got "+obj.get());
-
- System.out.println("Thread sleeping");
-
- Thread.sleep(10000);
-
- A.commit();
-
- obj = null;
- }
- catch (Exception e)
- {
- System.err.println(e);
- System.exit(-1);
- }
+ assertEquals(1234, obj.get());
}
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest1.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest1.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest1.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,142 +32,57 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
import com.hp.mwtests.ts.txoj.common.resources.RecoverableObject;
-import org.jboss.dtf.testframework.unittest.Test;
-import org.jboss.dtf.testframework.utils.PerformanceLogger;
-import java.lang.NumberFormatException;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class PerformanceTest1 extends Test
+public class PerformanceTest1
{
-
- public void run(String[] args)
+ @Test
+ public void recoverableTest()
{
- boolean persistent = true;
- long startIters = 1000;
- long endIters = 2000;
- long incrementIters = 250;
+ long iters = 4;
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-recoverable") == 0)
- persistent = false;
+ RecoverableObject foo = new RecoverableObject();
+ AtomicAction A = new AtomicAction();
+ long t1 = System.currentTimeMillis();
- if (args[i].compareTo("-start") == 0)
- {
- try
- {
- startIters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
+ A.begin();
- if (args[i].compareTo("-end") == 0)
- {
- try
- {
- endIters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
-
- if (args[i].compareTo("-inc") == 0)
- {
- try
- {
- incrementIters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
-
- if ( ( ( ( startIters - endIters) % incrementIters ) != 0 ) || ( endIters < startIters ) )
+ for (int c = 0; c < iters; c++)
{
- System.out.println("Invalid iteration parameters");
+ foo.set(2);
}
- else
- {
- long thisTime = 0;
- PerformanceLogger logger = new PerformanceLogger("PerformanceTest1");
- logInformation("Performing "+startIters+" - "+endIters+" (step "+incrementIters+") iterations");
+ A.commit();
+ }
- for (long iters=startIters;iters<=endIters;iters += incrementIters)
- {
- if (persistent)
- thisTime = persistentTest(iters);
- else
- thisTime = recoverableTest(iters);
+ @Test
+ public void persistentTest()
+ {
+ long iters = 4;
- logInformation("Number of Iterations:"+ iters +", Time Taken:" +thisTime);
+ AtomicObject foo = new AtomicObject();
+ AtomicAction A = new AtomicAction();
+ long t1 = System.currentTimeMillis();
- logger.addData( iters, (double)((double)iters/((double)thisTime/1000)) );
- }
+ A.begin();
- try
+ try {
+ for (int c = 0; c < iters; c++)
{
- logger.output(System.out);
- assertSuccess();
+ foo.set(2);
}
- catch (Exception e)
- {
- System.err.println("Unexpected exception - "+e);
- assertFailure();
- }
}
- }
+ catch (TestException e)
+ {
+ fail("AtomicObject exception raised.");
+ }
-public static long recoverableTest (long iters)
- {
- RecoverableObject foo = new RecoverableObject();
- AtomicAction A = new AtomicAction();
- long t1 = System.currentTimeMillis();
-
- A.begin();
-
- for (int c = 0; c < iters; c++)
- {
- foo.set(2);
- }
-
- A.commit();
-
- return System.currentTimeMillis() - t1;
+ A.commit();
}
-
-public static long persistentTest (long iters)
- {
- AtomicObject foo = new AtomicObject();
- AtomicAction A = new AtomicAction();
- long t1 = System.currentTimeMillis();
-
- A.begin();
-
- try
- {
- for (int c = 0; c < iters; c++)
- {
- foo.set(2);
- }
- }
- catch (TestException e)
- {
- System.out.println("AtomicObject exception raised.");
- }
-
- A.commit();
-
- return System.currentTimeMillis() - t1;
- }
-
-};
+}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest2.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest2.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest2.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,7 +32,6 @@
*/
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
@@ -40,109 +39,61 @@
import java.lang.NumberFormatException;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
public class PerformanceTest2
{
-
-public static void main (String[] args)
+ @Test
+ public void recoverableTest()
{
- boolean persistent = true;
- long iters = 1000;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-recoverable") == 0)
- persistent = false;
+ long iters = 1000;
- if (args[i].compareTo("-iter") == 0)
- {
- try
- {
- iters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
+ RecoverableObject foo = new RecoverableObject();
+ AtomicAction A = null;
+ long t1 = System.currentTimeMillis();
- long totalTime = 0;
+ for (int c = 0; c < iters; c++)
+ {
+ A = new AtomicAction();
- AtomicAction A = new AtomicAction();
- A.begin();
- A.commit();
- A = null;
+ A.begin();
- if (persistent)
- totalTime = persistentTest(iters);
- else
- totalTime = recoverableTest(iters);
+ foo.set(2);
- System.out.print("Time taken to perform "+iters+" iterations on a ");
-
- if (persistent)
- System.out.print("persistent object: ");
- else
- System.out.print("recoverable object: ");
-
- System.out.println(totalTime+" milliseconds");
+ A.commit();
+ }
}
-public static long recoverableTest (long iters)
+ @Test
+ public void persistentTest()
{
- RecoverableObject foo = new RecoverableObject();
- AtomicAction A = null;
- long t1 = System.currentTimeMillis();
+ long iters = 1000;
- for (int c = 0; c < iters; c++)
- {
- A = new AtomicAction();
-
- A.begin();
-
- foo.set(2);
+ AtomicObject foo = new AtomicObject();
+ AtomicAction A = null;
+ long t1 = System.currentTimeMillis();
- A.commit();
+ try
+ {
+ for (int c = 0; c < iters; c++)
+ {
+ A = new AtomicAction();
- A = null;
- }
+ A.begin();
- foo = null;
-
- return System.currentTimeMillis() - t1;
- }
+ foo.set(2);
-public static long persistentTest (long iters)
- {
- AtomicObject foo = new AtomicObject();
- AtomicAction A = null;
- long t1 = System.currentTimeMillis();
+ A.commit();
+ }
+ }
+ catch (TestException e)
+ {
+ if (A != null)
+ A.abort();
- try
- {
- for (int c = 0; c < iters; c++)
- {
- A = new AtomicAction();
-
- A.begin();
-
- foo.set(2);
+ fail("AtomicObject exception raised.");
+ }
+ }
- A.commit();
-
- A = null;
- }
- }
- catch (TestException e)
- {
- System.out.println("AtomicObject exception raised.");
-
- if (A != null)
- A.abort();
- }
-
- foo = null;
-
- return System.currentTimeMillis() - t1;
- }
-
-};
+}
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest3.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest3.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest3.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -1,78 +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.txoj.performance;
-
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: PerformanceTest3.java 2342 2006-03-30 13:06:17Z $
- */
-
-import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-import com.hp.mwtests.ts.txoj.common.resources.SimpleObject;
-
-import java.lang.NumberFormatException;
-
-public class PerformanceTest3
-{
-
-public static void main (String[] args)
- {
- long iters = 1000;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-iter") == 0)
- {
- try
- {
- iters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
-
- SimpleObject foo = new SimpleObject();
- long t1 = System.currentTimeMillis();
-
- for (int c = 0; c < iters; c++)
- {
- foo.set(c);
- }
-
- long t2 = System.currentTimeMillis();
-
- System.out.print("Time taken to perform "+iters+" iterations on a simple object: ");
-
- System.out.println(t2-t1+" milliseconds.");
- }
-
-};
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest4.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest4.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest4.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -1,117 +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.txoj.performance;
-
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: PerformanceTest4.java 2342 2006-03-30 13:06:17Z $
- */
-
-import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-import java.lang.NumberFormatException;
-
-public class PerformanceTest4
-{
-
-public static void main (String[] args)
- {
- long iters = 1000;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-iter") == 0)
- {
- try
- {
- iters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
-
- AtomicAction A = new AtomicAction();
- A.begin();
- A.commit();
- A = null;
-
- long t1 = System.currentTimeMillis();
-
- for (int c = 0; c < iters; c++)
- {
- A = new AtomicAction();
-
- A.begin();
-
- A.commit();
-
- A = null;
- }
-
- long t2 = System.currentTimeMillis();
-
- System.out.println(t1+" "+t2);
-
- System.out.print("Time taken to create/commit "+iters+" atomic actions: ");
-
- System.out.println(t2-t1+" milliseconds");
-
- AtomicAction B = null;
- t1 = System.currentTimeMillis();
-
- for (int c = 0; c < iters; c++)
- {
- A = new AtomicAction();
-
- A.begin();
-
- B = new AtomicAction();
-
- B.begin();
-
- B.commit();
-
- A.commit();
-
- B = null;
- A = null;
- }
-
- t2 = System.currentTimeMillis();
-
- System.out.println(t1+" "+t2);
-
- System.out.print("Time taken to create/commit "+iters+" nested atomic actions: ");
-
- System.out.println(t2-t1+" milliseconds.");
- }
-
-};
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest5.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest5.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest5.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -1,117 +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.txoj.performance;
-
-/*
- * Copyright (C) 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: PerformanceTest5.java 2342 2006-03-30 13:06:17Z $
- */
-
-import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-import java.util.*;
-
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-import java.lang.NumberFormatException;
-
-public class PerformanceTest5
-{
-
-public static void main (String[] args)
- {
- try
- {
- double iters = 1000.0;
- boolean doCommit = true;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-rollback"))
- doCommit = false;
- else
- {
- if (args[i].equals("-help"))
- {
- System.out.println("Usage: com.hp.mwtests.ts.txoj.performance.PerformanceTest5 [-rollback] [-help]");
- System.exit(0);
- }
- else
- {
- System.err.println("Unknown option: "+args[i]);
- System.exit(0);
- }
- }
- }
-
- // Run ten interations first.
-
- for (int i = 0; i < 10; i++)
- {
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (doCommit)
- A.commit(true);
- else
- A.abort();
- }
-
- // Record the start time.
-
- Date startTime = new Date();
-
- // Run 1000 interations.
-
- for (int i = 0; i < iters; i++)
- {
- AtomicAction A = new AtomicAction();
-
- A.begin();
-
- if (doCommit)
- A.commit(true);
- else
- A.abort();
- }
-
- // Record the end time.
-
- Date endTime = new Date();
- double txnTime = (float)((endTime.getTime()-startTime.getTime())/iters);
- double txnPSec = 1000.0/txnTime;
-
- System.out.println("Average time for empty transaction = "+txnTime);
- System.out.println("Transactions per second = "+txnPSec);
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
-
-};
Deleted: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest6.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest6.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/performance/PerformanceTest6.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -1,156 +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.txoj.performance;
-
-/*
- * Copyright (C) 1998, 1999, 2000,
- *
- * Arjuna Solutions Limited,
- * Newcastle upon Tyne,
- * Tyne and Wear,
- * UK.
- *
- * $Id: PerformanceTest6.java 2342 2006-03-30 13:06:17Z $
- */
-
-import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.txoj.common.*;
-
-import com.arjuna.ats.internal.arjuna.coordinator.*;
-
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
-import com.hp.mwtests.ts.txoj.common.resources.AtomicObjectLog;
-import com.hp.mwtests.ts.txoj.common.resources.RecoverableObject;
-
-import java.lang.NumberFormatException;
-
-public class PerformanceTest6
-{
-
-public static void main (String[] args)
- {
- boolean persistent = true;
- long iters = 1000;
-
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].compareTo("-recoverable") == 0)
- persistent = false;
-
- if (args[i].compareTo("-iter") == 0)
- {
- try
- {
- iters = Long.parseLong(args[i+1]);
- }
- catch (NumberFormatException e)
- {
- }
- }
- }
-
- long totalTime = 0;
-
- AtomicAction A = new AtomicAction();
- A.begin();
- A.commit();
- A = null;
-
- if (persistent)
- totalTime = persistentTest(iters);
- else
- totalTime = recoverableTest(iters);
-
- System.out.print("Time taken to perform "+iters+" iterations on a ");
-
- if (persistent)
- System.out.print("persistent object: ");
- else
- System.out.print("recoverable object: ");
-
- System.out.println(totalTime+" milliseconds");
- }
-
-public static long recoverableTest (long iters)
- {
- RecoverableObject foo = new RecoverableObject();
- AtomicAction A = null;
- long t1 = System.currentTimeMillis();
-
- for (int c = 0; c < iters; c++)
- {
- A = new AtomicAction();
-
- A.begin();
-
- foo.set(2);
-
- A.commit();
-
- A = null;
- }
-
- foo = null;
-
- return System.currentTimeMillis() - t1;
- }
-
-public static long persistentTest (long iters)
- {
- AtomicAction A = null;
- long t1 = System.currentTimeMillis();
-
- try
- {
- for (int c = 0; c < iters; c++)
- {
- A = new AppendLogTransaction();
- AtomicObjectLog foo = new AtomicObjectLog();
-
- A.begin();
-
- AppendLogTransaction wt = (AppendLogTransaction) A;
- AppendLogTransaction previous = foo.getTransaction();
-
- wt.setLoggedTransaction(previous);
-
- // foo.destroy();
-
- A.commit();
-
- A = null;
- }
- }
- // catch (TestException e)
- catch (Exception e)
- {
- System.out.println("AtomicObjectLog exception raised.");
-
- if (A != null)
- A.abort();
- }
-
- // foo = null;
-
- return System.currentTimeMillis() - t1;
- }
-
-};
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/recovery/RecoveryTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/recovery/RecoveryTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/recovery/RecoveryTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -32,68 +32,43 @@
package com.hp.mwtests.ts.txoj.recovery;
import com.arjuna.ats.arjuna.*;
-import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.arjuna.state.*;
-import com.arjuna.ats.arjuna.gandiva.*;
import com.arjuna.ats.arjuna.common.*;
-import java.util.Random;
-import java.lang.Math;
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.AtomicObject;
-import org.jboss.dtf.testframework.unittest.Test;
+import org.junit.Test;
+import static org.junit.Assert.*;
-public class RecoveryTest extends Test
+public class RecoveryTest
{
-
- public void run (String[] args)
+ @Test
+ public void test()
{
- try
- {
- AtomicObject obj = new AtomicObject();
- Uid objRef = obj.get_uid();
+ try {
+ AtomicObject obj = new AtomicObject();
+ Uid objRef = obj.get_uid();
- AtomicAction A = new AtomicAction();
+ AtomicAction A = new AtomicAction();
- A.begin();
+ A.begin();
- obj.set(1234);
+ obj.set(1234);
- A.commit();
+ A.commit();
- AtomicObject recObj = new AtomicObject(objRef);
+ AtomicObject recObj = new AtomicObject(objRef);
- AtomicAction B = new AtomicAction();
+ AtomicAction B = new AtomicAction();
- B.begin();
+ B.begin();
- if (recObj.get() == 1234)
- {
- System.out.print("Passed.");
+ assertEquals(1234, recObj.get());
- assertSuccess();
- }
- else
- {
- assertFailure();
- }
-
- B.abort();
- }
- catch (Exception ex)
- {
- assertFailure();
- }
+ B.abort();
+ }
+ catch (Exception ex)
+ {
+ fail(ex.toString());
+ }
}
-
- public static void main (String args[])
- {
- RecoveryTest rt = new RecoveryTest();
-
- rt.initialise(null, null, args, new org.jboss.dtf.testframework.unittest.LocalHarness());
-
- rt.run(args);
- }
-
}
Modified: labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/threadaction/ThreadActionTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/threadaction/ThreadActionTest.java 2009-07-06 11:51:24 UTC (rev 27612)
+++ labs/jbosstm/trunk/ArjunaCore/txoj/tests/classes/com/hp/mwtests/ts/txoj/threadaction/ThreadActionTest.java 2009-07-06 11:55:48 UTC (rev 27613)
@@ -31,19 +31,18 @@
* $Id: ThreadActionTest.java 2342 2006-03-30 13:06:17Z $
*/
-import com.arjuna.ats.arjuna.*;
import com.arjuna.ats.arjuna.coordinator.*;
-import com.arjuna.ats.txoj.common.*;
-import com.hp.mwtests.ts.txoj.common.exceptions.TestException;
import com.hp.mwtests.ts.txoj.common.resources.BasicThreadedObject;
import java.lang.InterruptedException;
-
+
+import org.junit.Test;
+
public class ThreadActionTest
{
-
-public static void main (String[] args)
+ @Test
+ public void test()
{
BasicThreadedObject object1 = new BasicThreadedObject(true);
BasicThreadedObject object2 = new BasicThreadedObject(false);
@@ -67,4 +66,4 @@
System.out.println("Main thread has action "+BasicAction.Current());
}
-};
+}
More information about the jboss-svn-commits
mailing list