COLLECTIONS-363 TransformedMap is Serializable but its superclass doesn't define an accessible void constructor
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@1051248 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b5e8745a41
commit
7d1c0ab090
|
@ -47,6 +47,13 @@ public class AbstractIterableGetMapDecorator<K, V> implements IterableGet<K, V>
|
||||||
this.map = decorated;
|
this.map = decorated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor only used in deserialization, do not use otherwise.
|
||||||
|
*/
|
||||||
|
protected AbstractIterableGetMapDecorator() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the map being decorated.
|
* Gets the map being decorated.
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.commons.collections.splitmap;
|
package org.apache.commons.collections.splitmap;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.*;
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.HashMap;
|
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<String, String, String, String> map = TransformedMap.decorate(
|
TransformedMap<String, String, String, String> map = TransformedMap.decorate(
|
||||||
new HashMap<String, String>(),
|
new HashMap<String, String>(),
|
||||||
NOPTransformer.<String>getInstance(),
|
NOPTransformer.<String>getInstance(),
|
||||||
NOPTransformer.<String>getInstance() );
|
NOPTransformer.<String>getInstance() );
|
||||||
|
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
ObjectInputStream in = new ObjectInputStream( new FileInputStream( "data/test/TransformedMap.emptyCollection.version3.2.obj" ) );
|
||||||
ObjectOutputStream out = new ObjectOutputStream(bytes);
|
|
||||||
out.writeObject(map);
|
|
||||||
out.close();
|
|
||||||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(bytes.toByteArray()));
|
|
||||||
Object readObject = in.readObject();
|
Object readObject = in.readObject();
|
||||||
in.close();
|
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<String, String, String, String> map = TransformedMap.decorate(
|
||||||
|
new HashMap<String, String>(),
|
||||||
|
NOPTransformer.<String>getInstance(),
|
||||||
|
NOPTransformer.<String>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<String, String, String, String> map = TransformedMap.decorate(
|
||||||
|
// new HashMap<String, String>(),
|
||||||
|
// NOPTransformer.<String>getInstance(),
|
||||||
|
// NOPTransformer.<String>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 );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue