in-memory serialization tests

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Morgan James Delagrange 2002-02-22 06:16:35 +00:00
parent 13d014655a
commit 93951f7a9d
1 changed files with 30 additions and 4 deletions

View File

@ -1,7 +1,7 @@
/* /*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.8 2002/02/22 02:18:50 mas Exp $ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.9 2002/02/22 06:16:35 morgand Exp $
* $Revision: 1.8 $ * $Revision: 1.9 $
* $Date: 2002/02/22 02:18:50 $ * $Date: 2002/02/22 06:16:35 $
* *
* ==================================================================== * ====================================================================
* *
@ -62,6 +62,8 @@
package org.apache.commons.collections; package org.apache.commons.collections;
import junit.framework.*; import junit.framework.*;
import java.io.IOException;
import java.io.Serializable;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Collection; import java.util.Collection;
@ -85,7 +87,7 @@ import java.util.NoSuchElementException;
* *
* @author Michael Smith * @author Michael Smith
* @author Rodney Waldhoff * @author Rodney Waldhoff
* @version $Id: TestMap.java,v 1.8 2002/02/22 02:18:50 mas Exp $ * @version $Id: TestMap.java,v 1.9 2002/02/22 06:16:35 morgand Exp $
*/ */
public abstract class TestMap extends TestObject { public abstract class TestMap extends TestObject {
public TestMap(String testName) { public TestMap(String testName) {
@ -903,6 +905,30 @@ public abstract class TestMap extends TestObject {
} }
public void testEmptyMapSerialization()
throws IOException, ClassNotFoundException {
Map map = makeEmptyMap();
if (!(map instanceof Serializable)) return;
byte[] objekt = writeExternalFormToBytes((Serializable) map);
Map map2 = (Map) readExternalFormFromBytes(objekt);
assertTrue("Both maps are empty",map.isEmpty() == true);
assertTrue("Both maps are empty",map2.isEmpty() == true);
}
public void testFullMapSerialization()
throws IOException, ClassNotFoundException {
Map map = makeFullMap();
if (!(map instanceof Serializable)) return;
byte[] objekt = writeExternalFormToBytes((Serializable) map);
Map map2 = (Map) readExternalFormFromBytes(objekt);
assertEquals("Both maps are same size",map.size(), getSampleKeys().length);
assertEquals("Both maps are same size",map2.size(),getSampleKeys().length);
}
/* /*
// optional operation // optional operation
public void testMapClear() { public void testMapClear() {