Change TransformedMap test cases to use good Transformer for serialization

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131659 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Stephen Colebourne 2004-04-10 22:22:57 +00:00
parent f655a04d2d
commit 60dc88188c
7 changed files with 10 additions and 14 deletions

View File

@ -15,7 +15,6 @@
*/ */
package org.apache.commons.collections.collection; package org.apache.commons.collections.collection;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -25,31 +24,26 @@ import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.apache.commons.collections.Transformer; import org.apache.commons.collections.Transformer;
import org.apache.commons.collections.TransformerUtils;
/** /**
* Extension of {@link TestCollection} for exercising the {@link TransformedCollection} * Extension of {@link TestCollection} for exercising the {@link TransformedCollection}
* implementation. * implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:40 $ * @version $Revision: 1.6 $ $Date: 2004/04/10 22:22:57 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
public class TestTransformedCollection extends AbstractTestCollection { public class TestTransformedCollection extends AbstractTestCollection {
private static class Noop implements Transformer, Serializable { private static class StringToInteger implements Transformer {
public Object transform(Object input) {
return input;
}
}
private static class StringToInteger implements Transformer, Serializable {
public Object transform(Object input) { public Object transform(Object input) {
return new Integer((String) input); return new Integer((String) input);
} }
} }
public static final Transformer NOOP_TRANSFORMER = new Noop(); public static final Transformer NOOP_TRANSFORMER = TransformerUtils.nopTransformer();
public static final Transformer STRING_TO_INTEGER_TRANSFORMER = new StringToInteger(); public static final Transformer STRING_TO_INTEGER_TRANSFORMER = new StringToInteger();
public TestTransformedCollection(String testName) { public TestTransformedCollection(String testName) {

View File

@ -22,6 +22,7 @@ import java.util.Set;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.apache.commons.collections.TransformerUtils;
import org.apache.commons.collections.collection.TestTransformedCollection; import org.apache.commons.collections.collection.TestTransformedCollection;
/** /**
@ -29,7 +30,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection;
* implementation. * implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.6 $ $Date: 2004/04/09 09:43:09 $ * @version $Revision: 1.7 $ $Date: 2004/04/10 22:22:56 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
@ -50,7 +51,7 @@ public class TestTransformedMap extends AbstractTestMap {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public Map makeEmptyMap() { public Map makeEmptyMap() {
return TransformedMap.decorate(new HashMap(), TestTransformedCollection.NOOP_TRANSFORMER, TestTransformedCollection.NOOP_TRANSFORMER); return TransformedMap.decorate(new HashMap(), TransformerUtils.nopTransformer(), TransformerUtils.nopTransformer());
} }
//----------------------------------------------------------------------- //-----------------------------------------------------------------------

View File

@ -22,6 +22,7 @@ import java.util.TreeMap;
import junit.framework.Test; import junit.framework.Test;
import org.apache.commons.collections.BulkTest; import org.apache.commons.collections.BulkTest;
import org.apache.commons.collections.TransformerUtils;
import org.apache.commons.collections.collection.TestTransformedCollection; import org.apache.commons.collections.collection.TestTransformedCollection;
/** /**
@ -29,7 +30,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection;
* implementation. * implementation.
* *
* @since Commons Collections 3.0 * @since Commons Collections 3.0
* @version $Revision: 1.5 $ $Date: 2004/04/09 09:43:09 $ * @version $Revision: 1.6 $ $Date: 2004/04/10 22:22:57 $
* *
* @author Stephen Colebourne * @author Stephen Colebourne
*/ */
@ -50,7 +51,7 @@ public class TestTransformedSortedMap extends AbstractTestSortedMap {
//----------------------------------------------------------------------- //-----------------------------------------------------------------------
public Map makeEmptyMap() { public Map makeEmptyMap() {
return TransformedSortedMap.decorate(new TreeMap(), TestTransformedCollection.NOOP_TRANSFORMER, TestTransformedCollection.NOOP_TRANSFORMER); return TransformedSortedMap.decorate(new TreeMap(), TransformerUtils.nopTransformer(), TransformerUtils.nopTransformer());
} }
public boolean isSubMapViewsSerializable() { public boolean isSubMapViewsSerializable() {