Author: manik.surtani(a)jboss.com
Date: 2009-01-05 10:51:37 -0500 (Mon, 05 Jan 2009)
New Revision: 7371
Added:
core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
Log:
Test FCHM
Added: core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java
(rev 0)
+++
core/trunk/src/test/java/org/jboss/cache/util/FastCopyHashMapSerialTest.java 2009-01-05
15:51:37 UTC (rev 7371)
@@ -0,0 +1,34 @@
+package org.jboss.cache.util;
+
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Map;
+
+@Test(groups = "functional")
+public class FastCopyHashMapSerialTest
+{
+ public void testSerialization() throws Exception
+ {
+ Map map = new FastCopyHashMap();
+ map.put("k1", "v1");
+ map.put("k2", "v2");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(map);
+ oos.close();
+ baos.close();
+
+ ObjectInputStream ois = new ObjectInputStream(new
ByteArrayInputStream(baos.toByteArray()));
+ Map map2 = (Map) ois.readObject();
+ ois.close();
+
+ assert map2 instanceof FastCopyHashMap;
+ assert map2.size() == map.size();
+ for (Object key : map.keySet()) assert map2.containsKey(key);
+ }
+}
Show replies by date