diff --git a/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java b/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java index fa5271fd4..7ce439250 100644 --- a/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java +++ b/src/java/org/apache/commons/collections/splitmap/AbstractIterableGetMapDecorator.java @@ -47,6 +47,13 @@ public class AbstractIterableGetMapDecorator implements IterableGet this.map = decorated; } + /** + * Constructor only used in deserialization, do not use otherwise. + */ + protected AbstractIterableGetMapDecorator() { + super(); + } + /** * Gets the map being decorated. * diff --git a/src/test/org/apache/commons/collections/splitmap/TestTransformedMap.java b/src/test/org/apache/commons/collections/splitmap/TestTransformedMap.java index 21d7d01a0..1fe588566 100644 --- a/src/test/org/apache/commons/collections/splitmap/TestTransformedMap.java +++ b/src/test/org/apache/commons/collections/splitmap/TestTransformedMap.java @@ -16,10 +16,7 @@ */ package org.apache.commons.collections.splitmap; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import java.io.*; import java.math.BigInteger; import java.util.HashMap; @@ -123,20 +120,57 @@ public class TestTransformedMap extends BulkTest { } } - public void TODOtestCollections363() throws Exception { + public void testEmptyMap() throws IOException, ClassNotFoundException { TransformedMap map = TransformedMap.decorate( - new HashMap(), - NOPTransformer. getInstance(), - NOPTransformer. getInstance()); - - ByteArrayOutputStream bytes = new ByteArrayOutputStream(); - ObjectOutputStream out = new ObjectOutputStream(bytes); - out.writeObject(map); - out.close(); - ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray())); + new HashMap(), + NOPTransformer.getInstance(), + NOPTransformer.getInstance() ); + + ObjectInputStream in = new ObjectInputStream( new FileInputStream( "data/test/TransformedMap.emptyCollection.version3.2.obj" ) ); Object readObject = in.readObject(); in.close(); - assertEquals("deserializing class: " + map.getClass().getName(), map.getClass(), readObject - .getClass()); + + TransformedMap readMap = (TransformedMap) readObject; + assertTrue( "Map should be empty", readMap.size() == 0 ); + assertEquals( map.entrySet(), readMap.entrySet() ); } + + public void testFullMap() throws IOException, ClassNotFoundException { + TransformedMap map = TransformedMap.decorate( + new HashMap(), + NOPTransformer.getInstance(), + NOPTransformer.getInstance() ); + map.put( "a", "b" ); + map.put( "c", "d" ); + map.put( "e", "f" ); + map.put( "g", "h" ); + + ObjectInputStream in = new ObjectInputStream( new FileInputStream( "data/test/TransformedMap.fullCollection.version3.2.obj" ) ); + Object readObject = in.readObject(); + in.close(); + + TransformedMap readMap = (TransformedMap) readObject; + assertFalse( "Map should not be empty", readMap.size() == 0 ); + assertEquals( map.entrySet(), readMap.entrySet() ); + } +// +// public void testCreate() throws IOException { +// TransformedMap map = TransformedMap.decorate( +// new HashMap(), +// NOPTransformer.getInstance(), +// NOPTransformer.getInstance() ); +// +// ObjectOutputStream out = new ObjectOutputStream( +// new FileOutputStream( "data/test/TransformedMap.emptyCollection.version3.2.obj" ) ); +// out.writeObject( map ); +// +// map.put( "a", "b" ); +// map.put( "c", "d" ); +// map.put( "e", "f" ); +// map.put( "g", "h" ); +// +// out = new ObjectOutputStream( +// new FileOutputStream( "data/test/TransformedMap.fullCollection.version3.2.obj" ) ); +// out.writeObject( map ); +// } }