[jboss-cvs] JBossCache/tests/functional/org/jboss/cache ...
Manik Surtani
msurtani at jboss.com
Wed Dec 6 08:10:31 EST 2006
User: msurtani
Date: 06/12/06 08:10:31
Modified: tests/functional/org/jboss/cache GlobalTransactionTest.java
Log:
JBCACHE-895
Revision Changes Path
1.8 +91 -58 JBossCache/tests/functional/org/jboss/cache/GlobalTransactionTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: GlobalTransactionTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/GlobalTransactionTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- GlobalTransactionTest.java 22 Aug 2006 11:46:07 -0000 1.7
+++ GlobalTransactionTest.java 6 Dec 2006 13:10:31 -0000 1.8
@@ -12,114 +12,124 @@
import junit.framework.TestSuite;
import org.jgroups.stack.IpAddress;
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.net.UnknownHostException;
/**
* @author <a href="mailto:bela at jboss.org">Bela Ban</a> Apr 14, 2003
- * @version $Id: GlobalTransactionTest.java,v 1.7 2006/08/22 11:46:07 msurtani Exp $
+ * @version $Id: GlobalTransactionTest.java,v 1.8 2006/12/06 13:10:31 msurtani Exp $
*/
-public class GlobalTransactionTest extends TestCase {
+public class GlobalTransactionTest extends TestCase
+{
- public GlobalTransactionTest(String name) {
+ public GlobalTransactionTest(String name)
+ {
super(name);
}
-
public void testEquality() throws UnknownHostException
{
- IpAddress a1=new IpAddress("localhost", 4444);
+ IpAddress a1 = new IpAddress("localhost", 4444);
GlobalTransaction tx1, tx2;
- tx1=GlobalTransaction.create(a1);
- tx2=GlobalTransaction.create(a1);
+ tx1 = GlobalTransaction.create(a1);
+ tx2 = GlobalTransaction.create(a1);
System.out.println("\ntx1: " + tx1 + "\ntx2: " + tx2);
assertTrue(tx1.equals(tx2) == false);
- tx2=tx1;
+ tx2 = tx1;
assertTrue(tx1.equals(tx2));
}
public void testEqualityWithOtherObject() throws UnknownHostException
{
- IpAddress a1=new IpAddress("localhost", 4444);
- GlobalTransaction tx1=GlobalTransaction.create(a1);
+ IpAddress a1 = new IpAddress("localhost", 4444);
+ GlobalTransaction tx1 = GlobalTransaction.create(a1);
System.out.println("\ntx1: " + tx1);
assertFalse(tx1.equals(Thread.currentThread()));
}
public void testEqualityWithNull() throws UnknownHostException
{
- IpAddress a1=new IpAddress("localhost", 4444);
- GlobalTransaction tx1=GlobalTransaction.create(a1);
+ IpAddress a1 = new IpAddress("localhost", 4444);
+ GlobalTransaction tx1 = GlobalTransaction.create(a1);
System.out.println("\ntx1: " + tx1);
assertFalse(tx1.equals(null));
}
public void testHashcode() throws UnknownHostException
{
- IpAddress a1=new IpAddress("localhost", 4444);
+ IpAddress a1 = new IpAddress("localhost", 4444);
GlobalTransaction tx1, tx2;
- tx1=GlobalTransaction.create(a1);
- tx2=GlobalTransaction.create(a1);
+ tx1 = GlobalTransaction.create(a1);
+ tx2 = GlobalTransaction.create(a1);
System.out.println("\ntx1: " + tx1 + "\ntx2: " + tx2);
assertTrue(tx1.equals(tx2) == false);
- int hcode_1=tx1.hashCode();
- int hcode_2=tx2.hashCode();
+ int hcode_1 = tx1.hashCode();
+ int hcode_2 = tx2.hashCode();
assertFalse(hcode_1 == hcode_2);
- tx2=tx1;
+ tx2 = tx1;
assertTrue(tx1.equals(tx2));
- hcode_1=tx1.hashCode();
- hcode_2=tx2.hashCode();
+ hcode_1 = tx1.hashCode();
+ hcode_2 = tx2.hashCode();
assertEquals(hcode_1, hcode_2);
}
public void testExternalization() throws UnknownHostException
{
- IpAddress a1=new IpAddress("localhost", 4444);
- IpAddress a2=new IpAddress("localhost", 5555);
- GlobalTransaction tx1, tx2, tx1_copy=null, tx2_copy=null;
- ByteArrayOutputStream bos=null;
- ByteArrayInputStream bis=null;
- ObjectOutputStream out=null;
- ObjectInputStream in=null;
- byte[] buf=null;
-
- tx1=GlobalTransaction.create(a1);
- tx2=GlobalTransaction.create(a2);
-
- try {
- bos=new ByteArrayOutputStream(1024);
- out=new ObjectOutputStream(bos);
+ IpAddress a1 = new IpAddress("localhost", 4444);
+ IpAddress a2 = new IpAddress("localhost", 5555);
+ GlobalTransaction tx1, tx2, tx1_copy = null, tx2_copy = null;
+ ByteArrayOutputStream bos = null;
+ ByteArrayInputStream bis = null;
+ ObjectOutputStream out = null;
+ ObjectInputStream in = null;
+ byte[] buf = null;
+
+ tx1 = GlobalTransaction.create(a1);
+ tx2 = GlobalTransaction.create(a2);
+
+ try
+ {
+ bos = new ByteArrayOutputStream(1024);
+ out = new ObjectOutputStream(bos);
out.writeObject(tx1);
out.writeObject(tx2);
out.flush();
- buf=bos.toByteArray();
+ buf = bos.toByteArray();
}
- catch(IOException ex) {
+ catch (IOException ex)
+ {
fail("creation of output stream");
}
- try {
- bis=new ByteArrayInputStream(buf);
- in=new ObjectInputStream(bis);
- tx1_copy=(GlobalTransaction)in.readObject();
- tx2_copy=(GlobalTransaction)in.readObject();
+ try
+ {
+ bis = new ByteArrayInputStream(buf);
+ in = new ObjectInputStream(bis);
+ tx1_copy = (GlobalTransaction) in.readObject();
+ tx2_copy = (GlobalTransaction) in.readObject();
}
- catch(IOException ex) {
+ catch (IOException ex)
+ {
fail("creation of input stream");
}
- catch(ClassNotFoundException e) {
+ catch (ClassNotFoundException e)
+ {
e.printStackTrace();
fail();
}
@@ -132,10 +142,10 @@
assertEquals(tx1, tx1_copy);
assertEquals(tx2, tx2_copy);
- int hcode_1=tx1.hashCode();
- int hcode_2=tx2.hashCode();
- int hcode_3=tx1_copy.hashCode();
- int hcode_4=tx2_copy.hashCode();
+ int hcode_1 = tx1.hashCode();
+ int hcode_2 = tx2.hashCode();
+ int hcode_3 = tx1_copy.hashCode();
+ int hcode_4 = tx2_copy.hashCode();
assertFalse(hcode_1 == hcode_2);
assertFalse(hcode_3 == hcode_4);
assertEquals(hcode_1, hcode_3);
@@ -143,28 +153,51 @@
}
- public void testWithNullAddress() {
+ public void testWithNullAddress()
+ {
GlobalTransaction tx1, tx2, tmp_tx1;
- tx1=GlobalTransaction.create(null);
- tx2=GlobalTransaction.create(null);
+ tx1 = GlobalTransaction.create(null);
+ tx2 = GlobalTransaction.create(null);
- tmp_tx1=tx1;
+ tmp_tx1 = tx1;
assertEquals(tx1, tmp_tx1);
assertTrue(tx1.equals(tx2) == false);
}
+ public void testOneNullAddress() throws UnknownHostException
+ {
+ GlobalTransaction tx1, tx2;
+ tx1 = GlobalTransaction.create(null);
- void log(String msg) {
+ assertFalse(tx1.equals(null));
+
+ tx2 = GlobalTransaction.create(null);
+
+ assertFalse(tx1.equals(tx2));
+ assertFalse(tx2.equals(tx1));
+
+ IpAddress a1 = new IpAddress("localhost", 4444);
+ tx2 = GlobalTransaction.create(a1);
+
+ assertFalse(tx1.equals(tx2));
+ assertFalse(tx2.equals(tx1));
+ }
+
+
+ void log(String msg)
+ {
System.out.println("-- [" + Thread.currentThread() + "]: " + msg);
}
- public static Test suite() {
- TestSuite s=new TestSuite(GlobalTransactionTest.class);
+ public static Test suite()
+ {
+ TestSuite s = new TestSuite(GlobalTransactionTest.class);
return s;
}
- public static void main(String[] args) {
+ public static void main(String[] args)
+ {
junit.textui.TestRunner.run(suite());
}
More information about the jboss-cvs-commits
mailing list