[jboss-svn-commits] JBL Code SVN: r31477 - in labs/jbosstm/trunk/ArjunaCore/arjuna: tests/classes/com/hp/mwtests/ts/arjuna/common and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Feb 7 06:31:03 EST 2010
Author: mark.little at jboss.com
Date: 2010-02-07 06:31:03 -0500 (Sun, 07 Feb 2010)
New Revision: 31477
Added:
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/MutexUnitTest.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUnitTest.java
Modified:
labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java
labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUniqueness.java
Log:
https://jira.jboss.org/jira/browse/JBTM-698
Modified: labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java 2010-02-07 03:41:13 UTC (rev 31476)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/classes/com/arjuna/ats/arjuna/common/Uid.java 2010-02-07 11:31:03 UTC (rev 31477)
@@ -692,6 +692,8 @@
{
try
{
+ hostAddr = new long[2];
+
hostAddr[0] = in.readLong();
hostAddr[1] = in.readLong();
process = in.readInt();
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/MutexUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/MutexUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/common/MutexUnitTest.java 2010-02-07 11:31:03 UTC (rev 31477)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2007,
+ * @author JBoss, a division of Red Hat.
+ */
+package com.hp.mwtests.ts.arjuna.common;
+
+import org.junit.Test;
+
+import com.arjuna.ats.arjuna.common.Mutex;
+
+import static org.junit.Assert.*;
+
+public class MutexUnitTest
+{
+ @Test
+ public void testBasicMutex () throws Exception
+ {
+ Mutex mx = new Mutex();
+
+ mx.lock();
+
+ mx.unlock();
+ }
+
+ @Test
+ public void testReentrantMutex () throws Exception
+ {
+ Mutex mx = new Mutex();
+
+ mx.lock();
+
+ assertEquals(mx.tryLock(), Mutex.WOULD_BLOCK);
+
+ mx.unlock();
+
+ mx = new Mutex(true);
+
+ mx.lock();
+
+ assertEquals(mx.tryLock(), Mutex.LOCKED);
+
+ mx.unlock();
+ mx.unlock();
+ }
+}
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 2010-02-07 03:41:13 UTC (rev 31476)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUniqueness.java 2010-02-07 11:31:03 UTC (rev 31477)
@@ -34,6 +34,8 @@
import com.arjuna.ats.arjuna.common.*;
import org.junit.Test;
+import static org.junit.Assert.*;
+
public class UidUniqueness
{
@Test
@@ -43,6 +45,20 @@
Uid u = new Uid();
System.out.println(u + " " + u.hashCode());
}
+
+ assertTrue(Uid.maxUid().greaterThan(Uid.minUid()));
+
+ try
+ {
+ Uid a = new Uid();
+ Uid b = (Uid) a.clone();
+
+ assertTrue(a.equals(b));
+ }
+ catch (final Exception ex)
+ {
+ fail();
+ }
}
}
Added: labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUnitTest.java
===================================================================
--- labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUnitTest.java (rev 0)
+++ labs/jbosstm/trunk/ArjunaCore/arjuna/tests/classes/com/hp/mwtests/ts/arjuna/uid/UidUnitTest.java 2010-02-07 11:31:03 UTC (rev 31477)
@@ -0,0 +1,66 @@
+/*
+ * 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.uid;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+
+import com.arjuna.ats.arjuna.common.*;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class UidUnitTest
+{
+ @Test
+ public void test () throws Exception
+ {
+ long[] dummy = {0, 0};
+
+ Uid u = new Uid(dummy, 0, 0, 0);
+
+ assertTrue(u.lessThan(Uid.maxUid()));
+ assertTrue(u.getHexPid() != null);
+
+ u.print(new PrintStream("foo"));
+ }
+
+ @Test
+ public void testSerialization () throws Exception
+ {
+ Uid u1 = new Uid();
+ ByteArrayOutputStream bs = new ByteArrayOutputStream();
+ ObjectOutputStream os = new ObjectOutputStream(bs);
+
+ os.writeObject(u1);
+
+ ByteArrayInputStream bis = new ByteArrayInputStream(bs.toByteArray());
+ ObjectInputStream is = new ObjectInputStream(bis);
+
+ Uid u2 = (Uid) is.readObject();
+
+ assertTrue(u1.equals(u2));
+ }
+
+}
More information about the jboss-svn-commits
mailing list