more specific in-memory serialization tests for SequencedHashMap

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Morgan James Delagrange 2002-02-22 06:25:10 +00:00
parent 93951f7a9d
commit 884b3a50e0
1 changed files with 24 additions and 0 deletions

View File

@ -54,6 +54,8 @@ package org.apache.commons.collections;
* <http://www.apache.org/>.
*/
import java.io.IOException;
import java.io.Serializable;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@ -177,6 +179,28 @@ implements TestMap.SupportsPut, TestMap.EntrySetSupportsRemove
assertTrue("second key is reassigned to first",labRat.get(0).equals(new Integer(2)));
}
// override TestMap method with more specific tests
public void testFullMapSerialization()
throws IOException, ClassNotFoundException {
SequencedHashMap map = (SequencedHashMap) makeFullMap();
if (!(map instanceof Serializable)) return;
byte[] objekt = writeExternalFormToBytes((Serializable) map);
SequencedHashMap map2 = (SequencedHashMap) readExternalFormFromBytes(objekt);
assertEquals("Both maps are same size",map.size(), getSampleKeys().length);
assertEquals("Both maps are same size",map2.size(),getSampleKeys().length);
assertEquals("Both maps have the same first key",
map.getFirstKey(),getSampleKeys()[0]);
assertEquals("Both maps have the same first key",
map2.getFirstKey(),getSampleKeys()[0]);
assertEquals("Both maps have the same last key",
map.getLastKey(),getSampleKeys()[0]);
assertEquals("Both maps have the same last key",
map2.getLastKey(),getSampleKeys()[0]);
}
protected void tearDown() {
labRat = null;
}