From 884b3a50e0080d2d54474bf044b5046f6af945b0 Mon Sep 17 00:00:00 2001 From: Morgan James Delagrange Date: Fri, 22 Feb 2002 06:25:10 +0000 Subject: [PATCH] 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 --- .../collections/TestSequencedHashMap.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/org/apache/commons/collections/TestSequencedHashMap.java b/src/test/org/apache/commons/collections/TestSequencedHashMap.java index 30f146ffe..a722cce3e 100644 --- a/src/test/org/apache/commons/collections/TestSequencedHashMap.java +++ b/src/test/org/apache/commons/collections/TestSequencedHashMap.java @@ -54,6 +54,8 @@ package org.apache.commons.collections; * . */ +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; }