diff --git a/data/test/FixedSizeList.emptyCollection.version3.1.obj b/data/test/FixedSizeList.emptyCollection.version3.1.obj new file mode 100644 index 000000000..e8f063824 Binary files /dev/null and b/data/test/FixedSizeList.emptyCollection.version3.1.obj differ diff --git a/data/test/FixedSizeList.fullCollection.version3.1.obj b/data/test/FixedSizeList.fullCollection.version3.1.obj new file mode 100644 index 000000000..10e60a8da Binary files /dev/null and b/data/test/FixedSizeList.fullCollection.version3.1.obj differ diff --git a/data/test/ListOrderedSet.emptyCollection.version3.1.obj b/data/test/ListOrderedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..9ef613cd9 Binary files /dev/null and b/data/test/ListOrderedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/ListOrderedSet.fullCollection.version3.1.obj b/data/test/ListOrderedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..d8f57dfbb Binary files /dev/null and b/data/test/ListOrderedSet.fullCollection.version3.1.obj differ diff --git a/data/test/MapBackedSet.emptyCollection.version3.1.obj b/data/test/MapBackedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..5c34fb61b Binary files /dev/null and b/data/test/MapBackedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/MapBackedSet.fullCollection.version3.1.obj b/data/test/MapBackedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..b02dd61df Binary files /dev/null and b/data/test/MapBackedSet.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedBag.emptyCollection.version3.1.obj b/data/test/PredicatedBag.emptyCollection.version3.1.obj new file mode 100644 index 000000000..f1c626c35 Binary files /dev/null and b/data/test/PredicatedBag.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedBag.fullCollection.version3.1.obj b/data/test/PredicatedBag.fullCollection.version3.1.obj new file mode 100644 index 000000000..1af48edc2 Binary files /dev/null and b/data/test/PredicatedBag.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedBuffer.emptyCollection.version3.1.obj b/data/test/PredicatedBuffer.emptyCollection.version3.1.obj new file mode 100644 index 000000000..c34eb412d Binary files /dev/null and b/data/test/PredicatedBuffer.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedBuffer.fullCollection.version3.1.obj b/data/test/PredicatedBuffer.fullCollection.version3.1.obj new file mode 100644 index 000000000..ae8f0e955 Binary files /dev/null and b/data/test/PredicatedBuffer.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedCollection.emptyCollection.version3.1.obj b/data/test/PredicatedCollection.emptyCollection.version3.1.obj new file mode 100644 index 000000000..547dd649e Binary files /dev/null and b/data/test/PredicatedCollection.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedCollection.fullCollection.version3.1.obj b/data/test/PredicatedCollection.fullCollection.version3.1.obj new file mode 100644 index 000000000..ae8f0e955 Binary files /dev/null and b/data/test/PredicatedCollection.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedList.emptyCollection.version3.1.obj b/data/test/PredicatedList.emptyCollection.version3.1.obj new file mode 100644 index 000000000..772d9ebb8 Binary files /dev/null and b/data/test/PredicatedList.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedList.fullCollection.version3.1.obj b/data/test/PredicatedList.fullCollection.version3.1.obj new file mode 100644 index 000000000..1e1410bdc Binary files /dev/null and b/data/test/PredicatedList.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedSet.emptyCollection.version3.1.obj b/data/test/PredicatedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..1e74c661e Binary files /dev/null and b/data/test/PredicatedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedSet.fullCollection.version3.1.obj b/data/test/PredicatedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..3faca8f23 Binary files /dev/null and b/data/test/PredicatedSet.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedSortedBag.emptyCollection.version3.1.obj b/data/test/PredicatedSortedBag.emptyCollection.version3.1.obj new file mode 100644 index 000000000..4494f63de Binary files /dev/null and b/data/test/PredicatedSortedBag.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedSortedBag.fullCollection.version3.1.obj b/data/test/PredicatedSortedBag.fullCollection.version3.1.obj new file mode 100644 index 000000000..f1a62a184 Binary files /dev/null and b/data/test/PredicatedSortedBag.fullCollection.version3.1.obj differ diff --git a/data/test/PredicatedSortedSet.emptyCollection.version3.1.obj b/data/test/PredicatedSortedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..948058251 Binary files /dev/null and b/data/test/PredicatedSortedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/PredicatedSortedSet.fullCollection.version3.1.obj b/data/test/PredicatedSortedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..780265b21 Binary files /dev/null and b/data/test/PredicatedSortedSet.fullCollection.version3.1.obj differ diff --git a/data/test/SetUniqueList.emptyCollection.version3.1.obj b/data/test/SetUniqueList.emptyCollection.version3.1.obj new file mode 100644 index 000000000..6fbadaebd Binary files /dev/null and b/data/test/SetUniqueList.emptyCollection.version3.1.obj differ diff --git a/data/test/SetUniqueList.fullCollection.version3.1.obj b/data/test/SetUniqueList.fullCollection.version3.1.obj new file mode 100644 index 000000000..37a21b6bf Binary files /dev/null and b/data/test/SetUniqueList.fullCollection.version3.1.obj differ diff --git a/data/test/SynchronizedBuffer.emptyCollection.version3.1.obj b/data/test/SynchronizedBuffer.emptyCollection.version3.1.obj new file mode 100644 index 000000000..b93fa227a Binary files /dev/null and b/data/test/SynchronizedBuffer.emptyCollection.version3.1.obj differ diff --git a/data/test/SynchronizedBuffer.fullCollection.version3.1.obj b/data/test/SynchronizedBuffer.fullCollection.version3.1.obj new file mode 100644 index 000000000..cec0322b4 Binary files /dev/null and b/data/test/SynchronizedBuffer.fullCollection.version3.1.obj differ diff --git a/data/test/TransformedBag.emptyCollection.version3.1.obj b/data/test/TransformedBag.emptyCollection.version3.1.obj new file mode 100644 index 000000000..28ee32051 Binary files /dev/null and b/data/test/TransformedBag.emptyCollection.version3.1.obj differ diff --git a/data/test/TransformedBag.fullCollection.version3.1.obj b/data/test/TransformedBag.fullCollection.version3.1.obj new file mode 100644 index 000000000..e494e44b5 Binary files /dev/null and b/data/test/TransformedBag.fullCollection.version3.1.obj differ diff --git a/data/test/TransformedCollection.emptyCollection.version3.1.obj b/data/test/TransformedCollection.emptyCollection.version3.1.obj new file mode 100644 index 000000000..9eec5fd56 Binary files /dev/null and b/data/test/TransformedCollection.emptyCollection.version3.1.obj differ diff --git a/data/test/TransformedCollection.fullCollection.version3.1.obj b/data/test/TransformedCollection.fullCollection.version3.1.obj new file mode 100644 index 000000000..4a579cf42 Binary files /dev/null and b/data/test/TransformedCollection.fullCollection.version3.1.obj differ diff --git a/data/test/TransformedList.emptyCollection.version3.1.obj b/data/test/TransformedList.emptyCollection.version3.1.obj new file mode 100644 index 000000000..d1c2b16d5 Binary files /dev/null and b/data/test/TransformedList.emptyCollection.version3.1.obj differ diff --git a/data/test/TransformedList.fullCollection.version3.1.obj b/data/test/TransformedList.fullCollection.version3.1.obj new file mode 100644 index 000000000..9ab8e06ff Binary files /dev/null and b/data/test/TransformedList.fullCollection.version3.1.obj differ diff --git a/data/test/TransformedSet.emptyCollection.version3.1.obj b/data/test/TransformedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..a6e376b87 Binary files /dev/null and b/data/test/TransformedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/TransformedSet.fullCollection.version3.1.obj b/data/test/TransformedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..402382ba3 Binary files /dev/null and b/data/test/TransformedSet.fullCollection.version3.1.obj differ diff --git a/data/test/TransformedSortedBag.emptyCollection.version3.1.obj b/data/test/TransformedSortedBag.emptyCollection.version3.1.obj new file mode 100644 index 000000000..8c38659ee Binary files /dev/null and b/data/test/TransformedSortedBag.emptyCollection.version3.1.obj differ diff --git a/data/test/TransformedSortedBag.fullCollection.version3.1.obj b/data/test/TransformedSortedBag.fullCollection.version3.1.obj new file mode 100644 index 000000000..b98e583ea Binary files /dev/null and b/data/test/TransformedSortedBag.fullCollection.version3.1.obj differ diff --git a/data/test/TransformedSortedSet.emptyCollection.version3.1.obj b/data/test/TransformedSortedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..3b132cabe Binary files /dev/null and b/data/test/TransformedSortedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/TransformedSortedSet.fullCollection.version3.1.obj b/data/test/TransformedSortedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..7f8c5529c Binary files /dev/null and b/data/test/TransformedSortedSet.fullCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableBuffer.emptyCollection.version3.1.obj b/data/test/UnmodifiableBuffer.emptyCollection.version3.1.obj new file mode 100644 index 000000000..cb16bc954 Binary files /dev/null and b/data/test/UnmodifiableBuffer.emptyCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableBuffer.fullCollection.version3.1.obj b/data/test/UnmodifiableBuffer.fullCollection.version3.1.obj new file mode 100644 index 000000000..e078e8ec0 Binary files /dev/null and b/data/test/UnmodifiableBuffer.fullCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableCollection.emptyCollection.version3.1.obj b/data/test/UnmodifiableCollection.emptyCollection.version3.1.obj new file mode 100644 index 000000000..a2e3b31ca Binary files /dev/null and b/data/test/UnmodifiableCollection.emptyCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableCollection.fullCollection.version3.1.obj b/data/test/UnmodifiableCollection.fullCollection.version3.1.obj new file mode 100644 index 000000000..0034a9af6 Binary files /dev/null and b/data/test/UnmodifiableCollection.fullCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableList.emptyCollection.version3.1.obj b/data/test/UnmodifiableList.emptyCollection.version3.1.obj new file mode 100644 index 000000000..c7f049547 Binary files /dev/null and b/data/test/UnmodifiableList.emptyCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableList.fullCollection.version3.1.obj b/data/test/UnmodifiableList.fullCollection.version3.1.obj new file mode 100644 index 000000000..5fb11cf45 Binary files /dev/null and b/data/test/UnmodifiableList.fullCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableSet.emptyCollection.version3.1.obj b/data/test/UnmodifiableSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..c53a7c856 Binary files /dev/null and b/data/test/UnmodifiableSet.emptyCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableSet.fullCollection.version3.1.obj b/data/test/UnmodifiableSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..888e6adce Binary files /dev/null and b/data/test/UnmodifiableSet.fullCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableSortedSet.emptyCollection.version3.1.obj b/data/test/UnmodifiableSortedSet.emptyCollection.version3.1.obj new file mode 100644 index 000000000..abedad76e Binary files /dev/null and b/data/test/UnmodifiableSortedSet.emptyCollection.version3.1.obj differ diff --git a/data/test/UnmodifiableSortedSet.fullCollection.version3.1.obj b/data/test/UnmodifiableSortedSet.fullCollection.version3.1.obj new file mode 100644 index 000000000..4b46e50a8 Binary files /dev/null and b/data/test/UnmodifiableSortedSet.fullCollection.version3.1.obj differ diff --git a/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java b/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java index c5ba35404..3a9f52793 100644 --- a/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java +++ b/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java @@ -26,13 +26,21 @@ import org.apache.commons.collections.collection.AbstractCollectionDecorator; * Methods are forwarded directly to the decorated bag. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:56:25 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 21:53:02 $ * * @author Stephen Colebourne */ public abstract class AbstractBagDecorator extends AbstractCollectionDecorator implements Bag { + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractBagDecorator() { + super(); + } + /** * Constructor that wraps (not copies). * diff --git a/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java b/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java index e5444fbe2..c8d345fc6 100644 --- a/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java +++ b/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java @@ -25,13 +25,21 @@ import org.apache.commons.collections.SortedBag; * Methods are forwarded directly to the decorated bag. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 00:56:25 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 21:53:02 $ * * @author Stephen Colebourne */ public abstract class AbstractSortedBagDecorator extends AbstractBagDecorator implements SortedBag { + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractSortedBagDecorator() { + super(); + } + /** * Constructor that wraps (not copies). * diff --git a/src/java/org/apache/commons/collections/bag/PredicatedBag.java b/src/java/org/apache/commons/collections/bag/PredicatedBag.java index 62fa16c03..c8f40f877 100644 --- a/src/java/org/apache/commons/collections/bag/PredicatedBag.java +++ b/src/java/org/apache/commons/collections/bag/PredicatedBag.java @@ -31,9 +31,11 @@ import org.apache.commons.collections.collection.PredicatedCollection; *

* One usage would be to ensure that no null entries are added to the bag. *

Bag bag = PredicatedBag.decorate(new HashBag(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/05/21 21:38:40 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 21:56:19 $ * * @author Stephen Colebourne * @author Paul Jack diff --git a/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java b/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java index f01a388c9..b0bdc89b4 100644 --- a/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java +++ b/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java @@ -30,9 +30,11 @@ import org.apache.commons.collections.SortedBag; *

* One usage would be to ensure that no null entries are added to the bag. *

SortedBag bag = PredicatedSortedBag.decorate(new TreeBag(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/05/21 21:38:40 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 21:56:19 $ * * @author Stephen Colebourne * @author Paul Jack diff --git a/src/java/org/apache/commons/collections/bag/TransformedBag.java b/src/java/org/apache/commons/collections/bag/TransformedBag.java index a2e9d62f7..e2bc61959 100644 --- a/src/java/org/apache/commons/collections/bag/TransformedBag.java +++ b/src/java/org/apache/commons/collections/bag/TransformedBag.java @@ -29,9 +29,11 @@ import org.apache.commons.collections.set.TransformedSet; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/05/15 12:27:04 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 21:56:19 $ * * @author Stephen Colebourne */ diff --git a/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java b/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java index 3ac9460b3..b99806f45 100644 --- a/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java +++ b/src/java/org/apache/commons/collections/bag/TransformedSortedBag.java @@ -27,9 +27,11 @@ import org.apache.commons.collections.Transformer; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/05/15 12:27:04 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 21:56:19 $ * * @author Stephen Colebourne */ diff --git a/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java b/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java index c78c036e8..a104cb6d3 100644 --- a/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java +++ b/src/java/org/apache/commons/collections/bag/UnmodifiableBag.java @@ -15,6 +15,10 @@ */ package org.apache.commons.collections.bag; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.Set; @@ -26,14 +30,19 @@ import org.apache.commons.collections.set.UnmodifiableSet; /** * Decorates another Bag to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.7 $ $Date: 2004/05/15 12:27:04 $ + * @version $Revision: 1.8 $ $Date: 2004/06/02 21:56:19 $ * * @author Stephen Colebourne */ public final class UnmodifiableBag - extends AbstractBagDecorator implements Unmodifiable { + extends AbstractBagDecorator implements Unmodifiable, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = -1873799975157099624L; /** * Factory method to create an unmodifiable bag. @@ -62,6 +71,30 @@ public final class UnmodifiableBag super(bag); } + //----------------------------------------------------------------------- + /** + * Write the collection out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the collection in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + //----------------------------------------------------------------------- public Iterator iterator() { return UnmodifiableIterator.decorate(getCollection().iterator()); diff --git a/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java b/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java index 5302e92fb..ac6d8cffc 100644 --- a/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java +++ b/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java @@ -15,6 +15,10 @@ */ package org.apache.commons.collections.bag; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.Set; @@ -26,14 +30,19 @@ import org.apache.commons.collections.set.UnmodifiableSet; /** * Decorates another SortedBag to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.8 $ $Date: 2004/05/15 12:27:04 $ + * @version $Revision: 1.9 $ $Date: 2004/06/02 21:56:19 $ * * @author Stephen Colebourne */ public final class UnmodifiableSortedBag - extends AbstractSortedBagDecorator implements Unmodifiable { + extends AbstractSortedBagDecorator implements Unmodifiable, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = -3190437252665717841L; /** * Factory method to create an unmodifiable bag. @@ -62,6 +71,30 @@ public final class UnmodifiableSortedBag super(bag); } + //----------------------------------------------------------------------- + /** + * Write the collection out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the collection in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + //----------------------------------------------------------------------- public Iterator iterator() { return UnmodifiableIterator.decorate(getCollection().iterator()); diff --git a/src/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java b/src/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java index 18e623027..3ab71c11c 100644 --- a/src/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java +++ b/src/java/org/apache/commons/collections/buffer/AbstractBufferDecorator.java @@ -24,12 +24,20 @@ import org.apache.commons.collections.collection.AbstractCollectionDecorator; * Methods are forwarded directly to the decorated buffer. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:58:18 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:02 $ * * @author Stephen Colebourne */ public abstract class AbstractBufferDecorator extends AbstractCollectionDecorator implements Buffer { + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractBufferDecorator() { + super(); + } + /** * Constructor that wraps (not copies). * diff --git a/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java b/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java index 50e2d0916..b069559d8 100644 --- a/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java +++ b/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java @@ -29,9 +29,11 @@ import org.apache.commons.collections.collection.PredicatedCollection; *

* One usage would be to ensure that no null entries are added to the buffer. *

Buffer buffer = PredicatedBuffer.decorate(new UnboundedFifoBuffer(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/05/21 21:38:48 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 21:57:03 $ * * @author Stephen Colebourne * @author Paul Jack diff --git a/src/java/org/apache/commons/collections/buffer/TransformedBuffer.java b/src/java/org/apache/commons/collections/buffer/TransformedBuffer.java index d7ad8f09b..180486aef 100644 --- a/src/java/org/apache/commons/collections/buffer/TransformedBuffer.java +++ b/src/java/org/apache/commons/collections/buffer/TransformedBuffer.java @@ -26,9 +26,11 @@ import org.apache.commons.collections.collection.TransformedCollection; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/05/15 12:33:23 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 21:57:03 $ * * @author Stephen Colebourne */ diff --git a/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java b/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java index edc7ec27b..476f16735 100644 --- a/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java +++ b/src/java/org/apache/commons/collections/buffer/UnmodifiableBuffer.java @@ -15,6 +15,10 @@ */ package org.apache.commons.collections.buffer; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; @@ -24,13 +28,20 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; /** * Decorates another Buffer to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/05/15 12:33:23 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 21:57:03 $ * * @author Stephen Colebourne */ -public final class UnmodifiableBuffer extends AbstractBufferDecorator implements Unmodifiable { +public final class UnmodifiableBuffer + extends AbstractBufferDecorator + implements Unmodifiable, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 1832948656215393357L; /** * Factory method to create an unmodifiable buffer. @@ -59,6 +70,30 @@ public final class UnmodifiableBuffer extends AbstractBufferDecorator implements super(buffer); } + //----------------------------------------------------------------------- + /** + * Write the collection out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the collection in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + //----------------------------------------------------------------------- public Iterator iterator() { return UnmodifiableIterator.decorate(getCollection().iterator()); diff --git a/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java b/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java index 152182248..79bd9ed33 100644 --- a/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java +++ b/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java @@ -34,7 +34,7 @@ import java.util.Iterator; * to write an unmodifiable implementation it might provide a loophole. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 00:58:53 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:03 $ * * @author Stephen Colebourne * @author Paul Jack @@ -42,7 +42,15 @@ import java.util.Iterator; public abstract class AbstractCollectionDecorator implements Collection { /** The collection being decorated */ - protected final Collection collection; + protected Collection collection; + + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractCollectionDecorator() { + super(); + } /** * Constructor that wraps (not copies). diff --git a/src/java/org/apache/commons/collections/collection/AbstractSerializableCollectionDecorator.java b/src/java/org/apache/commons/collections/collection/AbstractSerializableCollectionDecorator.java new file mode 100644 index 000000000..136b04ca3 --- /dev/null +++ b/src/java/org/apache/commons/collections/collection/AbstractSerializableCollectionDecorator.java @@ -0,0 +1,68 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.collection; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Collection; + +/** + * Serializable subclass of AbstractCollectionDecorator. + * + * @author Stephen Colebourne + * @since Commons Collections 3.1 + */ +public abstract class AbstractSerializableCollectionDecorator + extends AbstractCollectionDecorator + implements Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 6249888059822088500L; + + /** + * Constructor. + */ + protected AbstractSerializableCollectionDecorator(Collection coll) { + super(coll); + } + + //----------------------------------------------------------------------- + /** + * Write the collection out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the collection in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + +} diff --git a/src/java/org/apache/commons/collections/collection/PredicatedCollection.java b/src/java/org/apache/commons/collections/collection/PredicatedCollection.java index 3028a7ec5..3a9dadfc2 100644 --- a/src/java/org/apache/commons/collections/collection/PredicatedCollection.java +++ b/src/java/org/apache/commons/collections/collection/PredicatedCollection.java @@ -30,14 +30,16 @@ import org.apache.commons.collections.Predicate; *

* One usage would be to ensure that no null entries are added to the collection. *

Collection coll = PredicatedCollection.decorate(new ArrayList(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/05/21 21:38:40 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 21:58:06 $ * * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedCollection extends AbstractCollectionDecorator { +public class PredicatedCollection extends AbstractSerializableCollectionDecorator { /** The predicate to use */ protected final Predicate predicate; diff --git a/src/java/org/apache/commons/collections/collection/TransformedCollection.java b/src/java/org/apache/commons/collections/collection/TransformedCollection.java index 8af5e4345..fe49ef492 100644 --- a/src/java/org/apache/commons/collections/collection/TransformedCollection.java +++ b/src/java/org/apache/commons/collections/collection/TransformedCollection.java @@ -29,13 +29,15 @@ import org.apache.commons.collections.Transformer; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/05/15 12:39:13 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 21:58:06 $ * * @author Stephen Colebourne */ -public class TransformedCollection extends AbstractCollectionDecorator { +public class TransformedCollection extends AbstractSerializableCollectionDecorator { /** The transformer to use */ protected final Transformer transformer; diff --git a/src/java/org/apache/commons/collections/collection/UnmodifiableBoundedCollection.java b/src/java/org/apache/commons/collections/collection/UnmodifiableBoundedCollection.java index a7f14a5b1..7a412f668 100644 --- a/src/java/org/apache/commons/collections/collection/UnmodifiableBoundedCollection.java +++ b/src/java/org/apache/commons/collections/collection/UnmodifiableBoundedCollection.java @@ -30,13 +30,17 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; * longer accessible. * The factory on this class will attempt to retrieve the bounded nature by * examining the package scope variables. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.8 $ $Date: 2004/05/15 12:39:13 $ + * @version $Revision: 1.9 $ $Date: 2004/06/02 21:58:06 $ * * @author Stephen Colebourne */ -public final class UnmodifiableBoundedCollection extends AbstractCollectionDecorator implements BoundedCollection { +public final class UnmodifiableBoundedCollection + extends AbstractSerializableCollectionDecorator + implements BoundedCollection { /** * Factory method to create an unmodifiable bounded collection. @@ -130,5 +134,5 @@ public final class UnmodifiableBoundedCollection extends AbstractCollectionDecor public int maxSize() { return ((BoundedCollection) collection).maxSize(); } - + } diff --git a/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java b/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java index 0cb6f97be..f55307d8d 100644 --- a/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java +++ b/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java @@ -23,13 +23,17 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; /** * Decorates another Collection to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/05/15 12:39:13 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 21:58:06 $ * * @author Stephen Colebourne */ -public final class UnmodifiableCollection extends AbstractCollectionDecorator implements Unmodifiable { +public final class UnmodifiableCollection + extends AbstractSerializableCollectionDecorator + implements Unmodifiable { /** * Factory method to create an unmodifiable collection. diff --git a/src/java/org/apache/commons/collections/list/AbstractListDecorator.java b/src/java/org/apache/commons/collections/list/AbstractListDecorator.java index 230e8201f..8cfa1e09b 100644 --- a/src/java/org/apache/commons/collections/list/AbstractListDecorator.java +++ b/src/java/org/apache/commons/collections/list/AbstractListDecorator.java @@ -27,12 +27,20 @@ import org.apache.commons.collections.collection.AbstractCollectionDecorator; * Methods are forwarded directly to the decorated list. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:12:26 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:02 $ * * @author Stephen Colebourne */ public abstract class AbstractListDecorator extends AbstractCollectionDecorator implements List { + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractListDecorator() { + super(); + } + /** * Constructor that wraps (not copies). * diff --git a/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java b/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java new file mode 100644 index 000000000..fbccf5481 --- /dev/null +++ b/src/java/org/apache/commons/collections/list/AbstractSerializableListDecorator.java @@ -0,0 +1,69 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.list; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Collection; +import java.util.List; + +/** + * Serializable subclass of AbstractListDecorator. + * + * @author Stephen Colebourne + * @since Commons Collections 3.1 + */ +public abstract class AbstractSerializableListDecorator + extends AbstractListDecorator + implements Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 2684959196747496299L; + + /** + * Constructor. + */ + protected AbstractSerializableListDecorator(List list) { + super(list); + } + + //----------------------------------------------------------------------- + /** + * Write the list out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the list in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + +} diff --git a/src/java/org/apache/commons/collections/list/FixedSizeList.java b/src/java/org/apache/commons/collections/list/FixedSizeList.java index fb7b96e79..9ff8a719f 100644 --- a/src/java/org/apache/commons/collections/list/FixedSizeList.java +++ b/src/java/org/apache/commons/collections/list/FixedSizeList.java @@ -29,14 +29,18 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; *

* The add, remove, clear and retain operations are unsupported. * The set method is allowed (as it doesn't change the list size). + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:12:26 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 21:59:49 $ * * @author Stephen Colebourne * @author Paul Jack */ -public class FixedSizeList extends AbstractListDecorator implements BoundedCollection { +public class FixedSizeList + extends AbstractSerializableListDecorator + implements BoundedCollection { /** * Factory method to create a fixed size list. diff --git a/src/java/org/apache/commons/collections/list/LazyList.java b/src/java/org/apache/commons/collections/list/LazyList.java index 5793900c5..dd79f1433 100644 --- a/src/java/org/apache/commons/collections/list/LazyList.java +++ b/src/java/org/apache/commons/collections/list/LazyList.java @@ -45,15 +45,17 @@ import org.apache.commons.collections.Factory; * a new Date instance. Furthermore, that Date * instance is the fourth element in the list. The first, second, * and third element are all set to null. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 01:12:26 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 21:59:49 $ * * @author Stephen Colebourne * @author Arron Bates * @author Paul Jack */ -public class LazyList extends AbstractListDecorator { +public class LazyList extends AbstractSerializableListDecorator { /** The factory to use to lazily instantiate the objects */ protected final Factory factory; diff --git a/src/java/org/apache/commons/collections/list/PredicatedList.java b/src/java/org/apache/commons/collections/list/PredicatedList.java index eecb391da..bb5655038 100644 --- a/src/java/org/apache/commons/collections/list/PredicatedList.java +++ b/src/java/org/apache/commons/collections/list/PredicatedList.java @@ -34,9 +34,11 @@ import org.apache.commons.collections.iterators.AbstractListIteratorDecorator; *

* One usage would be to ensure that no null entries are added to the list. *

List list = PredicatedList.decorate(new ArrayList(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/05/21 21:38:40 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 21:59:49 $ * * @author Stephen Colebourne * @author Paul Jack diff --git a/src/java/org/apache/commons/collections/list/SetUniqueList.java b/src/java/org/apache/commons/collections/list/SetUniqueList.java index 239c0fa6b..14fe4d607 100644 --- a/src/java/org/apache/commons/collections/list/SetUniqueList.java +++ b/src/java/org/apache/commons/collections/list/SetUniqueList.java @@ -39,14 +39,16 @@ import org.apache.commons.collections.set.UnmodifiableSet; * The {@link org.apache.commons.collections.set.ListOrderedSet ListOrderedSet} * class provides an alternative approach, by wrapping an existing Set and * retaining insertion order in the iterator. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:12:26 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 21:59:49 $ * * @author Matthew Hawthorne * @author Stephen Colebourne */ -public class SetUniqueList extends AbstractListDecorator { +public class SetUniqueList extends AbstractSerializableListDecorator { /** * Internal Set to maintain uniqueness. diff --git a/src/java/org/apache/commons/collections/list/TransformedList.java b/src/java/org/apache/commons/collections/list/TransformedList.java index 5cd138016..7ce782e73 100644 --- a/src/java/org/apache/commons/collections/list/TransformedList.java +++ b/src/java/org/apache/commons/collections/list/TransformedList.java @@ -30,9 +30,11 @@ import org.apache.commons.collections.iterators.AbstractListIteratorDecorator; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:12:26 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 21:59:49 $ * * @author Stephen Colebourne */ diff --git a/src/java/org/apache/commons/collections/list/UnmodifiableList.java b/src/java/org/apache/commons/collections/list/UnmodifiableList.java index 6f21159e9..c8aeff15a 100644 --- a/src/java/org/apache/commons/collections/list/UnmodifiableList.java +++ b/src/java/org/apache/commons/collections/list/UnmodifiableList.java @@ -26,13 +26,17 @@ import org.apache.commons.collections.iterators.UnmodifiableListIterator; /** * Decorates another List to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:12:26 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 21:59:49 $ * * @author Stephen Colebourne */ -public final class UnmodifiableList extends AbstractListDecorator implements Unmodifiable { +public final class UnmodifiableList + extends AbstractSerializableListDecorator + implements Unmodifiable { /** * Factory method to create an unmodifiable list. diff --git a/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java b/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java new file mode 100644 index 000000000..dc1a5b04a --- /dev/null +++ b/src/java/org/apache/commons/collections/set/AbstractSerializableSetDecorator.java @@ -0,0 +1,69 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.set; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Collection; +import java.util.Set; + +/** + * Serializable subclass of AbstractSetDecorator. + * + * @author Stephen Colebourne + * @since Commons Collections 3.1 + */ +public abstract class AbstractSerializableSetDecorator + extends AbstractSetDecorator + implements Serializable { + + /** Serialization version */ + private static final long serialVersionUID = 1229469966212206107L; + + /** + * Constructor. + */ + protected AbstractSerializableSetDecorator(Set set) { + super(set); + } + + //----------------------------------------------------------------------- + /** + * Write the set out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the set in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + +} diff --git a/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java b/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java index d58d2a1f6..c483dfef4 100644 --- a/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java +++ b/src/java/org/apache/commons/collections/set/AbstractSetDecorator.java @@ -25,12 +25,20 @@ import org.apache.commons.collections.collection.AbstractCollectionDecorator; * Methods are forwarded directly to the decorated set. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:03 $ * * @author Stephen Colebourne */ public abstract class AbstractSetDecorator extends AbstractCollectionDecorator implements Set { + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractSetDecorator() { + super(); + } + /** * Constructor that wraps (not copies). * diff --git a/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java b/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java index 5a2b29a0e..2e3045821 100644 --- a/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java +++ b/src/java/org/apache/commons/collections/set/AbstractSortedSetDecorator.java @@ -25,12 +25,20 @@ import java.util.SortedSet; * Methods are forwarded directly to the decorated set. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 21:53:03 $ * * @author Stephen Colebourne */ public abstract class AbstractSortedSetDecorator extends AbstractSetDecorator implements SortedSet { + /** + * Constructor only used in deserialization, do not use otherwise. + * @since Commons Collections 3.1 + */ + protected AbstractSortedSetDecorator() { + super(); + } + /** * Constructor that wraps (not copies). * diff --git a/src/java/org/apache/commons/collections/set/ListOrderedSet.java b/src/java/org/apache/commons/collections/set/ListOrderedSet.java index f4d177d40..2544e4923 100644 --- a/src/java/org/apache/commons/collections/set/ListOrderedSet.java +++ b/src/java/org/apache/commons/collections/set/ListOrderedSet.java @@ -40,14 +40,16 @@ import org.apache.commons.collections.list.UnmodifiableList; *

* This class cannot implement the List interface directly as * various interface methods (notably equals/hashCode) are incompatable with a set. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne * @author Henning P. Schmiedehausen */ -public class ListOrderedSet extends AbstractSetDecorator implements Set { +public class ListOrderedSet extends AbstractSerializableSetDecorator implements Set { /** Internal list to hold the sequence of objects */ protected final List setOrder; diff --git a/src/java/org/apache/commons/collections/set/PredicatedSet.java b/src/java/org/apache/commons/collections/set/PredicatedSet.java index 9e5f0b8f2..ae3c2517a 100644 --- a/src/java/org/apache/commons/collections/set/PredicatedSet.java +++ b/src/java/org/apache/commons/collections/set/PredicatedSet.java @@ -30,9 +30,11 @@ import org.apache.commons.collections.collection.PredicatedCollection; *

* One usage would be to ensure that no null entries are added to the set. *

Set set = PredicatedSet.decorate(new HashSet(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/05/21 21:38:42 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne * @author Paul Jack diff --git a/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java b/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java index db0515bad..cdeef0022 100644 --- a/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java +++ b/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java @@ -30,9 +30,11 @@ import org.apache.commons.collections.Predicate; *

* One usage would be to ensure that no null entries are added to the set. *

SortedSet set = PredicatedSortedSet.decorate(new TreeSet(), NotNullPredicate.INSTANCE);
+ *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/05/21 21:38:42 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne * @author Paul Jack diff --git a/src/java/org/apache/commons/collections/set/TransformedSet.java b/src/java/org/apache/commons/collections/set/TransformedSet.java index 895f17c2b..8a6f74f67 100644 --- a/src/java/org/apache/commons/collections/set/TransformedSet.java +++ b/src/java/org/apache/commons/collections/set/TransformedSet.java @@ -27,9 +27,11 @@ import org.apache.commons.collections.collection.TransformedCollection; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne */ diff --git a/src/java/org/apache/commons/collections/set/TransformedSortedSet.java b/src/java/org/apache/commons/collections/set/TransformedSortedSet.java index ee1d5048c..86037ff80 100644 --- a/src/java/org/apache/commons/collections/set/TransformedSortedSet.java +++ b/src/java/org/apache/commons/collections/set/TransformedSortedSet.java @@ -27,9 +27,11 @@ import org.apache.commons.collections.Transformer; * Thus objects must be removed or searched for using their transformed form. * For example, if the transformation converts Strings to Integers, you must * use the Integer form to remove objects. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne */ diff --git a/src/java/org/apache/commons/collections/set/UnmodifiableSet.java b/src/java/org/apache/commons/collections/set/UnmodifiableSet.java index e313e956c..f2a1dea31 100644 --- a/src/java/org/apache/commons/collections/set/UnmodifiableSet.java +++ b/src/java/org/apache/commons/collections/set/UnmodifiableSet.java @@ -24,13 +24,17 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; /** * Decorates another Set to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne */ -public final class UnmodifiableSet extends AbstractSetDecorator implements Unmodifiable { +public final class UnmodifiableSet + extends AbstractSerializableSetDecorator + implements Unmodifiable { /** * Factory method to create an unmodifiable set. diff --git a/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java b/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java index ae0996488..0853ae4c3 100644 --- a/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java +++ b/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java @@ -15,6 +15,10 @@ */ package org.apache.commons.collections.set; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; import java.util.Collection; import java.util.Iterator; import java.util.SortedSet; @@ -24,13 +28,20 @@ import org.apache.commons.collections.iterators.UnmodifiableIterator; /** * Decorates another SortedSet to ensure it can't be altered. + *

+ * This class is Serializable from Commons Collections 3.1. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:14:27 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:02:34 $ * * @author Stephen Colebourne */ -public final class UnmodifiableSortedSet extends AbstractSortedSetDecorator implements Unmodifiable { +public final class UnmodifiableSortedSet + extends AbstractSortedSetDecorator + implements Unmodifiable, Serializable { + + /** Serialization version */ + private static final long serialVersionUID = -725356885467962424L; /** * Factory method to create an unmodifiable set. @@ -45,6 +56,30 @@ public final class UnmodifiableSortedSet extends AbstractSortedSetDecorator impl return new UnmodifiableSortedSet(set); } + //----------------------------------------------------------------------- + /** + * Write the collection out using a custom routine. + * + * @param out the output stream + * @throws IOException + */ + private void writeObject(ObjectOutputStream out) throws IOException { + out.defaultWriteObject(); + out.writeObject(collection); + } + + /** + * Read the collection in using a custom routine. + * + * @param in the input stream + * @throws IOException + * @throws ClassNotFoundException + */ + private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { + in.defaultReadObject(); + collection = (Collection) in.readObject(); + } + //----------------------------------------------------------------------- /** * Constructor that wraps (not copies). diff --git a/src/test/org/apache/commons/collections/TestBufferUtils.java b/src/test/org/apache/commons/collections/TestBufferUtils.java index 55f1173bd..7983f55b4 100644 --- a/src/test/org/apache/commons/collections/TestBufferUtils.java +++ b/src/test/org/apache/commons/collections/TestBufferUtils.java @@ -15,18 +15,14 @@ */ package org.apache.commons.collections; -import java.util.Arrays; -import java.util.Collection; - import junit.framework.Test; import org.apache.commons.collections.buffer.PredicatedBuffer; -import org.apache.commons.collections.collection.AbstractTestCollection; /** * Tests for BufferUtils. * - * @version $Revision: 1.12 $ $Date: 2004/02/18 01:20:35 $ + * @version $Revision: 1.13 $ $Date: 2004/06/02 22:12:14 $ * * @author Unknown */ @@ -67,38 +63,4 @@ public class TestBufferUtils extends BulkTest { } } - - public BulkTest bulkTestUnmodifiableBuffer() { - return new AbstractTestCollection("") { - public boolean isAddSupported() { - return false; - } - - public boolean isRemoveSupported() { - return false; - } - - public Collection makeCollection() { - return BufferUtils.unmodifiableBuffer(new ArrayStack()); - } - - public Collection makeFullCollection() { - ArrayStack a = new ArrayStack(); - a.addAll(Arrays.asList(getFullElements())); - return BufferUtils.unmodifiableBuffer(a); - } - - - public Collection makeConfirmedCollection() { - return new ArrayStack(); - } - - public Collection makeConfirmedFullCollection() { - ArrayStack a = new ArrayStack(); - a.addAll(Arrays.asList(getFullElements())); - return a; - } - - }; - } } diff --git a/src/test/org/apache/commons/collections/TestListUtils.java b/src/test/org/apache/commons/collections/TestListUtils.java index a14a8866d..aa846dbe5 100644 --- a/src/test/org/apache/commons/collections/TestListUtils.java +++ b/src/test/org/apache/commons/collections/TestListUtils.java @@ -22,13 +22,12 @@ import java.util.List; import junit.framework.Test; -import org.apache.commons.collections.list.AbstractTestList; import org.apache.commons.collections.list.PredicatedList; /** * Tests for ListUtils. * - * @version $Revision: 1.18 $ $Date: 2004/02/18 01:20:35 $ + * @version $Revision: 1.19 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne * @author Neil O'Toole @@ -73,34 +72,6 @@ public class TestListUtils extends BulkTest { } } - public BulkTest bulkTestTypedList() { - return new TestTypedCollection("") { - - public Collection typedCollection() { - Class type = getType(); - return ListUtils.typedList(new ArrayList(), type); - } - - public BulkTest bulkTestAll() { - return new AbstractTestList("") { - public List makeEmptyList() { - return (List)typedCollection(); - } - - public Object[] getFullElements() { - return getFullNonNullStringElements(); - } - - public Object[] getOtherElements() { - return getOtherNonNullStringElements(); - } - - }; - } - }; - } - - public void testLazyList() { List list = ListUtils.lazyList(new ArrayList(), new Factory() { diff --git a/src/test/org/apache/commons/collections/TestSetUtils.java b/src/test/org/apache/commons/collections/TestSetUtils.java index ea663f3b8..f45724ee8 100644 --- a/src/test/org/apache/commons/collections/TestSetUtils.java +++ b/src/test/org/apache/commons/collections/TestSetUtils.java @@ -22,13 +22,12 @@ import java.util.Set; import junit.framework.Test; -import org.apache.commons.collections.set.AbstractTestSet; import org.apache.commons.collections.set.PredicatedSet; /** * Tests for SetUtils. * - * @version $Revision: 1.15 $ $Date: 2004/02/18 01:20:35 $ + * @version $Revision: 1.16 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne * @author Neil O'Toole @@ -70,33 +69,6 @@ public class TestSetUtils extends BulkTest { } } - - public BulkTest bulkTestTypedSet() { - return new TestTypedCollection("") { - - public Collection typedCollection() { - Class type = getType(); - return SetUtils.typedSet(new HashSet(), type); - } - - public BulkTest bulkTestAll() { - return new AbstractTestSet("") { - public Set makeEmptySet() { - return (Set)typedCollection(); - } - - public Object[] getFullElements() { - return getFullNonNullStringElements(); - } - - public Object[] getOtherElements() { - return getOtherNonNullStringElements(); - } - }; - } - }; - } - public void testEquals() { Collection data = Arrays.asList( new String[] { "a", "b", "c" }); diff --git a/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java b/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java index 4a1423010..867548008 100644 --- a/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java +++ b/src/test/org/apache/commons/collections/bag/TestPredicatedBag.java @@ -29,7 +29,7 @@ import org.apache.commons.collections.PredicateUtils; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:05:03 $ * * @author Phil Steitz */ @@ -123,4 +123,21 @@ public class TestPredicatedBag extends AbstractTestBag { // expected } } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// Bag bag = makeBag(); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/PredicatedBag.emptyCollection.version3.1.obj"); +// bag = makeBag(); +// bag.add("A"); +// bag.add("A"); +// bag.add("B"); +// bag.add("B"); +// bag.add("C"); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/PredicatedBag.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java b/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java index 0928768d1..cd8526564 100644 --- a/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java +++ b/src/test/org/apache/commons/collections/bag/TestPredicatedSortedBag.java @@ -30,7 +30,7 @@ import org.apache.commons.collections.SortedBag; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.7 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.8 $ $Date: 2004/06/02 22:05:03 $ * * @author Phil Steitz */ @@ -103,4 +103,21 @@ public class TestPredicatedSortedBag extends AbstractTestSortedBag { Comparator c = bag.comparator(); assertTrue("natural order, so comparator should be null", c == null); } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// Bag bag = makeBag(); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/PredicatedSortedBag.emptyCollection.version3.1.obj"); +// bag = makeBag(); +// bag.add("A"); +// bag.add("A"); +// bag.add("B"); +// bag.add("B"); +// bag.add("C"); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/PredicatedSortedBag.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/bag/TestTransformedBag.java b/src/test/org/apache/commons/collections/bag/TestTransformedBag.java index 6e12c79e6..3dac4be22 100644 --- a/src/test/org/apache/commons/collections/bag/TestTransformedBag.java +++ b/src/test/org/apache/commons/collections/bag/TestTransformedBag.java @@ -26,7 +26,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:05:03 $ * * @author Stephen Colebourne */ @@ -64,4 +64,21 @@ public class TestTransformedBag extends AbstractTestBag { assertEquals(true, bag.remove(new Integer((String) els[0]))); } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// Bag bag = makeBag(); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/TransformedBag.emptyCollection.version3.1.obj"); +// bag = makeBag(); +// bag.add("A"); +// bag.add("A"); +// bag.add("B"); +// bag.add("B"); +// bag.add("C"); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/TransformedBag.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java b/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java index 3eb13e852..86abb55bb 100644 --- a/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java +++ b/src/test/org/apache/commons/collections/bag/TestTransformedSortedBag.java @@ -26,7 +26,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:05:03 $ * * @author Stephen Colebourne */ @@ -62,4 +62,21 @@ public class TestTransformedSortedBag extends AbstractTestSortedBag { assertEquals(true, bag.remove(new Integer((String) els[0]))); } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// Bag bag = makeBag(); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/TransformedSortedBag.emptyCollection.version3.1.obj"); +// bag = makeBag(); +// bag.add("A"); +// bag.add("A"); +// bag.add("B"); +// bag.add("B"); +// bag.add("C"); +// writeExternalFormToDisk((java.io.Serializable) bag, "D:/dev/collections/data/test/TransformedSortedBag.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/bag/TestTypedBag.java b/src/test/org/apache/commons/collections/bag/TestTypedBag.java index 9d49c7a9b..54f07b38d 100644 --- a/src/test/org/apache/commons/collections/bag/TestTypedBag.java +++ b/src/test/org/apache/commons/collections/bag/TestTypedBag.java @@ -27,7 +27,7 @@ import org.apache.commons.collections.Bag; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:05:03 $ * * @author Phil Steitz */ @@ -115,4 +115,9 @@ public class TestTypedBag extends AbstractTestBag { // expected } } + + protected boolean skipSerializedCanonicalTests() { + return true; + } + } diff --git a/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java b/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java index 3a08772a6..9bd11b97f 100644 --- a/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java +++ b/src/test/org/apache/commons/collections/bag/TestTypedSortedBag.java @@ -28,7 +28,7 @@ import org.apache.commons.collections.SortedBag; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.7 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.8 $ $Date: 2004/06/02 22:05:03 $ * * @author Phil Steitz */ @@ -93,4 +93,9 @@ public class TestTypedSortedBag extends AbstractTestSortedBag { Comparator c = bag.comparator(); assertTrue("natural order, so comparator should be null", c == null); } + + protected boolean skipSerializedCanonicalTests() { + return true; + } + } diff --git a/src/test/org/apache/commons/collections/buffer/TestAll.java b/src/test/org/apache/commons/collections/buffer/TestAll.java index 4ee1909f2..d042916c0 100644 --- a/src/test/org/apache/commons/collections/buffer/TestAll.java +++ b/src/test/org/apache/commons/collections/buffer/TestAll.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Entry point for tests. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:37 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:05:54 $ * * @author Stephen Colebourne */ @@ -49,7 +49,9 @@ public class TestAll extends TestCase { suite.addTest(TestBlockingBuffer.suite()); suite.addTest(TestPredicatedBuffer.suite()); + suite.addTest(TestSynchronizedBuffer.suite()); suite.addTest(TestTransformedBuffer.suite()); + suite.addTest(TestUnmodifiableBuffer.suite()); return suite; } diff --git a/src/test/org/apache/commons/collections/buffer/TestPredicatedBuffer.java b/src/test/org/apache/commons/collections/buffer/TestPredicatedBuffer.java index ff080ea29..dfecd4ebf 100644 --- a/src/test/org/apache/commons/collections/buffer/TestPredicatedBuffer.java +++ b/src/test/org/apache/commons/collections/buffer/TestPredicatedBuffer.java @@ -31,7 +31,7 @@ import org.apache.commons.collections.collection.TestPredicatedCollection; * {@link PredicatedBuffer} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:20:37 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 22:05:54 $ * * @author Phil Steitz */ @@ -101,4 +101,16 @@ public class TestPredicatedBuffer extends TestPredicatedCollection { // expected } } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedBuffer.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedBuffer.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/buffer/TestSynchronizedBuffer.java b/src/test/org/apache/commons/collections/buffer/TestSynchronizedBuffer.java new file mode 100644 index 000000000..39fdc53ec --- /dev/null +++ b/src/test/org/apache/commons/collections/buffer/TestSynchronizedBuffer.java @@ -0,0 +1,90 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.buffer; + +import java.util.Arrays; +import java.util.Collection; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.commons.collections.ArrayStack; +import org.apache.commons.collections.Buffer; +import org.apache.commons.collections.collection.AbstractTestCollection; + +/** + * Extension of {@link AbstractTestCollection} for exercising the + * {@link SynchronizedBuffer} implementation. + * + * @since Commons Collections 3.1 + * @version $Revision: 1.1 $ $Date: 2004/06/02 22:05:54 $ + * + * @author Phil Steitz + * @author Stephen Colebourne + */ +public class TestSynchronizedBuffer extends AbstractTestCollection { + + public TestSynchronizedBuffer(String testName) { + super(testName); + } + + public static Test suite() { + return new TestSuite(TestSynchronizedBuffer.class); + } + + public static void main(String args[]) { + String[] testCaseName = { TestSynchronizedBuffer.class.getName()}; + junit.textui.TestRunner.main(testCaseName); + } + + //----------------------------------------------------------------------- + public Collection makeCollection() { + return SynchronizedBuffer.decorate(new UnboundedFifoBuffer()); + } + + public Collection makeFullCollection() { + Buffer buffer = new UnboundedFifoBuffer(); + buffer.addAll(Arrays.asList(getFullElements())); + return SynchronizedBuffer.decorate(buffer); + } + + public Collection makeConfirmedCollection() { + ArrayStack list = new ArrayStack(); + return list; + } + + public Collection makeConfirmedFullCollection() { + ArrayStack list = new ArrayStack(); + list.addAll(Arrays.asList(getFullElements())); + return list; + } + + public boolean isNullSupported() { + return false; + } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SynchronizedBuffer.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SynchronizedBuffer.fullCollection.version3.1.obj"); +// } + +} diff --git a/src/test/org/apache/commons/collections/buffer/TestUnmodifiableBuffer.java b/src/test/org/apache/commons/collections/buffer/TestUnmodifiableBuffer.java new file mode 100644 index 000000000..586b8e3cd --- /dev/null +++ b/src/test/org/apache/commons/collections/buffer/TestUnmodifiableBuffer.java @@ -0,0 +1,107 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.buffer; + +import java.util.Arrays; +import java.util.Collection; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.commons.collections.ArrayStack; +import org.apache.commons.collections.Buffer; +import org.apache.commons.collections.collection.AbstractTestCollection; + +/** + * Extension of {@link AbstractTestCollection} for exercising the + * {@link UnmodifiableBuffer} implementation. + * + * @since Commons Collections 3.1 + * @version $Revision: 1.1 $ $Date: 2004/06/02 22:05:54 $ + * + * @author Phil Steitz + * @author Stephen Colebourne + */ +public class TestUnmodifiableBuffer extends AbstractTestCollection { + + public TestUnmodifiableBuffer(String testName) { + super(testName); + } + + public static Test suite() { + return new TestSuite(TestUnmodifiableBuffer.class); + } + + public static void main(String args[]) { + String[] testCaseName = { TestUnmodifiableBuffer.class.getName()}; + junit.textui.TestRunner.main(testCaseName); + } + + //----------------------------------------------------------------------- + public Collection makeCollection() { + return UnmodifiableBuffer.decorate(new UnboundedFifoBuffer()); + } + + public Collection makeFullCollection() { + Buffer buffer = new UnboundedFifoBuffer(); + buffer.addAll(Arrays.asList(getFullElements())); + return UnmodifiableBuffer.decorate(buffer); + } + + public Collection makeConfirmedCollection() { + ArrayStack list = new ArrayStack(); + return list; + } + + public Collection makeConfirmedFullCollection() { + ArrayStack list = new ArrayStack(); + list.addAll(Arrays.asList(getFullElements())); + return list; + } + + public boolean isAddSupported() { + return false; + } + + public boolean isRemoveSupported() { + return false; + } + + public boolean isNullSupported() { + return false; + } + + public void testBufferRemove() { + resetEmpty(); + Buffer buffer = (Buffer) collection; + try { + buffer.remove(); + fail(); + } catch (UnsupportedOperationException ex) {} + } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableBuffer.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableBuffer.fullCollection.version3.1.obj"); +// } + +} diff --git a/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java b/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java index 292009f40..89db9cfea 100644 --- a/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java +++ b/src/test/org/apache/commons/collections/collection/TestPredicatedCollection.java @@ -31,7 +31,7 @@ import org.apache.commons.collections.PredicateUtils; * {@link PredicatedCollection} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:40 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:06:33 $ * * @author Phil Steitz */ @@ -50,7 +50,7 @@ public class TestPredicatedCollection extends AbstractTestCollection { junit.textui.TestRunner.main(testCaseName); } - //------------------------------------------------------------------------ + //------------------------------------------------------------------------ protected Predicate truePredicate = PredicateUtils.truePredicate(); @@ -131,4 +131,15 @@ public class TestPredicatedCollection extends AbstractTestCollection { !c.contains("four")); } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedCollection.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedCollection.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java b/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java index 51d62ee1b..2edfb2a27 100644 --- a/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java +++ b/src/test/org/apache/commons/collections/collection/TestTransformedCollection.java @@ -31,7 +31,7 @@ import org.apache.commons.collections.TransformerUtils; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/04/10 22:22:57 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:06:33 $ * * @author Stephen Colebourne */ @@ -103,5 +103,16 @@ public class TestTransformedCollection extends AbstractTestCollection { assertEquals(true, coll.remove(new Integer((String) els[0]))); } - + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedCollection.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedCollection.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java b/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java index 31b21920f..8f7aaa273 100644 --- a/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java +++ b/src/test/org/apache/commons/collections/collection/TestUnmodifiableCollection.java @@ -28,7 +28,7 @@ import junit.framework.TestSuite; * {@link UnmodifiableCollection} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:20:40 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 22:06:33 $ * * @author Phil Steitz * @author Stephen Colebourne @@ -78,4 +78,15 @@ public class TestUnmodifiableCollection extends AbstractTestCollection { return false; } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableCollection.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableCollection.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/list/TestAll.java b/src/test/org/apache/commons/collections/list/TestAll.java index 8f25985f8..03302ab20 100644 --- a/src/test/org/apache/commons/collections/list/TestAll.java +++ b/src/test/org/apache/commons/collections/list/TestAll.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Entry point for tests. * * @since Commons Collections 3.0 - * @version $Revision: 1.7 $ $Date: 2004/06/01 23:08:04 $ + * @version $Revision: 1.8 $ $Date: 2004/06/02 22:07:53 $ * * @author Stephen Colebourne */ @@ -50,7 +50,7 @@ public class TestAll extends TestCase { suite.addTest(TestSetUniqueList.suite()); suite.addTest(TestSynchronizedList.suite()); suite.addTest(TestTransformedList.suite()); -// suite.addTest(TestTypedList.suite()); + suite.addTest(TestTypedList.suite()); suite.addTest(TestUnmodifiableList.suite()); return suite; diff --git a/src/test/org/apache/commons/collections/list/TestFixedSizeList.java b/src/test/org/apache/commons/collections/list/TestFixedSizeList.java index 535a76c2c..f62d0ad79 100644 --- a/src/test/org/apache/commons/collections/list/TestFixedSizeList.java +++ b/src/test/org/apache/commons/collections/list/TestFixedSizeList.java @@ -27,7 +27,7 @@ import junit.framework.TestSuite; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:34 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:07:53 $ * * @author Stephen Colebourne */ @@ -64,4 +64,15 @@ public class TestFixedSizeList extends AbstractTestList { return false; } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/FixedSizeList.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/FixedSizeList.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/list/TestPredicatedList.java b/src/test/org/apache/commons/collections/list/TestPredicatedList.java index 0b39c1549..2ebeef40d 100644 --- a/src/test/org/apache/commons/collections/list/TestPredicatedList.java +++ b/src/test/org/apache/commons/collections/list/TestPredicatedList.java @@ -29,7 +29,7 @@ import org.apache.commons.collections.PredicateUtils; * {@link PredicatedList} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:34 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:07:53 $ * * @author Phil Steitz */ @@ -140,5 +140,16 @@ public class TestPredicatedList extends AbstractTestList { assertTrue("List should contain legal element", list.contains("three")); } - + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedList.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedList.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/list/TestSetUniqueList.java b/src/test/org/apache/commons/collections/list/TestSetUniqueList.java index 0b3c9f892..d16008541 100644 --- a/src/test/org/apache/commons/collections/list/TestSetUniqueList.java +++ b/src/test/org/apache/commons/collections/list/TestSetUniqueList.java @@ -29,7 +29,7 @@ import junit.textui.TestRunner; * JUnit tests. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:34 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:07:53 $ * * @author Matthew Hawthorne */ @@ -275,4 +275,15 @@ public class TestSetUniqueList extends AbstractTestList { assertEquals("Duplicate element was added", 2, lset.size()); } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SetUniqueList.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/SetUniqueList.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/list/TestTransformedList.java b/src/test/org/apache/commons/collections/list/TestTransformedList.java index f696d1fad..29e3a4857 100644 --- a/src/test/org/apache/commons/collections/list/TestTransformedList.java +++ b/src/test/org/apache/commons/collections/list/TestTransformedList.java @@ -31,7 +31,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:34 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:07:53 $ * * @author Stephen Colebourne */ @@ -116,4 +116,16 @@ public class TestTransformedList extends AbstractTestList { assertEquals(new Integer(3), list.get(1)); assertEquals(new Integer(2), list.get(2)); } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedList.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedList.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/list/TestTypedList.java b/src/test/org/apache/commons/collections/list/TestTypedList.java new file mode 100644 index 000000000..9dd7916d3 --- /dev/null +++ b/src/test/org/apache/commons/collections/list/TestTypedList.java @@ -0,0 +1,65 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.list; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * Extension of {@link TestList} for exercising the {@link TypedList} + * implementation. + * + * @since Commons Collections 3.1 + * @version $Revision: 1.1 $ $Date: 2004/06/02 22:07:53 $ + * + * @author Stephen Colebourne + */ +public class TestTypedList extends AbstractTestList { + + public TestTypedList(String testName) { + super(testName); + } + + public static Test suite() { + return new TestSuite(TestTypedList.class); + } + + public static void main(String args[]) { + String[] testCaseName = { TestTypedList.class.getName()}; + junit.textui.TestRunner.main(testCaseName); + } + + public Collection makeConfirmedCollection() { + return new ArrayList(); + } + + public List makeEmptyList() { + return TypedList.decorate(new ArrayList(), Object.class); + } + + public boolean isNullSupported() { + return false; + } + + public boolean skipSerializedCanonicalTests() { + return true; // TypedList and PredicatedList get confused + } + +} diff --git a/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java b/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java index ec9da7c17..6663ff48f 100644 --- a/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java +++ b/src/test/org/apache/commons/collections/list/TestUnmodifiableList.java @@ -28,7 +28,7 @@ import junit.framework.TestSuite; * {@link UnmodifiableList} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:34 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:07:53 $ * * @author Phil Steitz */ @@ -166,4 +166,16 @@ public class TestUnmodifiableList extends AbstractTestList { // expected } } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableList.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableList.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/set/TestAll.java b/src/test/org/apache/commons/collections/set/TestAll.java index 8e2fa9db4..4d07f30f5 100644 --- a/src/test/org/apache/commons/collections/set/TestAll.java +++ b/src/test/org/apache/commons/collections/set/TestAll.java @@ -23,7 +23,7 @@ import junit.framework.TestSuite; * Entry point for tests. * * @since Commons Collections 3.0 - * @version $Revision: 1.7 $ $Date: 2004/06/01 23:08:50 $ + * @version $Revision: 1.8 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne */ @@ -51,7 +51,7 @@ public class TestAll extends TestCase { suite.addTest(TestSynchronizedSortedSet.suite()); suite.addTest(TestTransformedSet.suite()); suite.addTest(TestTransformedSortedSet.suite()); -// suite.addTest(TestTypedSet.suite()); + suite.addTest(TestTypedSet.suite()); suite.addTest(TestTypedSortedSet.suite()); suite.addTest(TestUnmodifiableSet.suite()); suite.addTest(TestUnmodifiableSortedSet.suite()); diff --git a/src/test/org/apache/commons/collections/set/TestListOrderedSet.java b/src/test/org/apache/commons/collections/set/TestListOrderedSet.java index 53b1954fd..2d4fe4b29 100644 --- a/src/test/org/apache/commons/collections/set/TestListOrderedSet.java +++ b/src/test/org/apache/commons/collections/set/TestListOrderedSet.java @@ -29,7 +29,7 @@ import junit.framework.TestSuite; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:12:14 $ * * @author Henning P. Schmiedehausen * @author Stephen Colebourne @@ -166,4 +166,15 @@ public class TestListOrderedSet extends AbstractTestSet { assertSame(ONE, set.get(3)); } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/ListOrderedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/ListOrderedSet.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/set/TestMapBackedSet.java b/src/test/org/apache/commons/collections/set/TestMapBackedSet.java index 331513148..52ac0e181 100644 --- a/src/test/org/apache/commons/collections/set/TestMapBackedSet.java +++ b/src/test/org/apache/commons/collections/set/TestMapBackedSet.java @@ -26,7 +26,7 @@ import org.apache.commons.collections.map.HashedMap; * JUnit test. * * @since Commons Collections 3.1 - * @version $Revision: 1.1 $ $Date: 2004/04/20 23:51:31 $ + * @version $Revision: 1.2 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne */ @@ -49,4 +49,15 @@ public class TestMapBackedSet extends AbstractTestSet { return MapBackedSet.decorate(new HashedMap()); } + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/MapBackedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/MapBackedSet.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java b/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java index 7c96e9031..c47cf78a1 100644 --- a/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java +++ b/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java @@ -27,7 +27,7 @@ import org.apache.commons.collections.map.LinkedMap; * JUnit test. * * @since Commons Collections 3.1 - * @version $Revision: 1.1 $ $Date: 2004/04/20 23:51:31 $ + * @version $Revision: 1.2 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne */ @@ -90,5 +90,11 @@ public class TestMapBackedSet2 extends AbstractTestSet { assertEquals("Sequence is wrong", Integer.toString(i), it.next()); } } - + + public void testCanonicalEmptyCollectionExists() { + } + + public void testCanonicalFullCollectionExists() { + } + } diff --git a/src/test/org/apache/commons/collections/set/TestPredicatedSet.java b/src/test/org/apache/commons/collections/set/TestPredicatedSet.java index e04388c7d..0bb8037f2 100644 --- a/src/test/org/apache/commons/collections/set/TestPredicatedSet.java +++ b/src/test/org/apache/commons/collections/set/TestPredicatedSet.java @@ -29,7 +29,7 @@ import org.apache.commons.collections.PredicateUtils; * {@link PredicatedSet} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:12:14 $ * * @author Phil Steitz */ @@ -118,5 +118,16 @@ public class TestPredicatedSet extends AbstractTestSet{ assertTrue("Set shouldn't contain illegal element", !set.contains("four")); } - + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedSet.fullCollection.version3.1.obj"); +// } + } \ No newline at end of file diff --git a/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java b/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java index 0462fbf7f..0b4a14457 100644 --- a/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java +++ b/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java @@ -33,7 +33,7 @@ import org.apache.commons.collections.map.TestPredicatedSortedMap; * {@link PredicatedSortedSet} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 22:12:14 $ * * @author Phil Steitz */ @@ -127,5 +127,16 @@ public class TestPredicatedSortedSet extends AbstractTestSortedSet{ Comparator c = set.comparator(); assertTrue("natural order, so comparator should be null", c == null); } - -} \ No newline at end of file + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedSortedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/PredicatedSortedSet.fullCollection.version3.1.obj"); +// } + +} diff --git a/src/test/org/apache/commons/collections/set/TestTransformedSet.java b/src/test/org/apache/commons/collections/set/TestTransformedSet.java index 02ed3458d..2aca03d1b 100644 --- a/src/test/org/apache/commons/collections/set/TestTransformedSet.java +++ b/src/test/org/apache/commons/collections/set/TestTransformedSet.java @@ -30,7 +30,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne */ @@ -84,4 +84,16 @@ public class TestTransformedSet extends AbstractTestSet { assertEquals(true, set.remove(new Integer((String) els[0]))); } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedSet.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java b/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java index 3bf75c3bd..d0265d9c5 100644 --- a/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java +++ b/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java @@ -31,7 +31,7 @@ import org.apache.commons.collections.collection.TestTransformedCollection; * implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.5 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.6 $ $Date: 2004/06/02 22:12:14 $ * * @author Stephen Colebourne */ @@ -77,4 +77,16 @@ public class TestTransformedSortedSet extends AbstractTestSortedSet { assertEquals(true, set.remove(new Integer((String) els[0]))); } + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedSortedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/TransformedSortedSet.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/set/TestTypedSet.java b/src/test/org/apache/commons/collections/set/TestTypedSet.java new file mode 100644 index 000000000..28477639d --- /dev/null +++ b/src/test/org/apache/commons/collections/set/TestTypedSet.java @@ -0,0 +1,62 @@ +/* + * Copyright 2004 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.collections.set; + +import java.util.HashSet; +import java.util.Set; + +import junit.framework.Test; + +import org.apache.commons.collections.BulkTest; + +/** + * Extension of {@link AbstractTestSet} for exercising the + * {@link TypedSet} implementation. + * + * @since Commons Collections 3.1 + * @version $Revision: 1.1 $ $Date: 2004/06/02 22:12:14 $ + * + * @author Phil Steitz + */ +public class TestTypedSet extends AbstractTestSet{ + + public TestTypedSet(String testName) { + super(testName); + } + + public static Test suite() { + return BulkTest.makeSuite(TestTypedSet.class); + } + + public static void main(String args[]) { + String[] testCaseName = { TestTypedSet.class.getName()}; + junit.textui.TestRunner.main(testCaseName); + } + + //------------------------------------------------------------------- + public Set makeEmptySet() { + return TypedSet.decorate(new HashSet(), Object.class); + } + + public boolean isNullSupported() { + return false; + } + + public boolean skipSerializedCanonicalTests() { + return true; // Typed and Predicated get confused + } + +} diff --git a/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java b/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java index 12563e20a..b556ee8b3 100644 --- a/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java +++ b/src/test/org/apache/commons/collections/set/TestTypedSortedSet.java @@ -30,7 +30,7 @@ import org.apache.commons.collections.BulkTest; * {@link TypedSortedSet} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.4 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.5 $ $Date: 2004/06/02 22:12:14 $ * * @author Phil Steitz */ @@ -101,4 +101,9 @@ public class TestTypedSortedSet extends AbstractTestSortedSet{ assertTrue("Collection shouldn't convert long to int", !set.contains(getNextAsInt())); } -} \ No newline at end of file + + public boolean skipSerializedCanonicalTests() { + return true; // Typed and Predicated get confused + } + +} diff --git a/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java b/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java index 1c180d165..904fba09a 100644 --- a/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java +++ b/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java @@ -28,7 +28,7 @@ import org.apache.commons.collections.BulkTest; * {@link UnmodifiableSet} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.3 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.4 $ $Date: 2004/06/02 22:12:14 $ * * @author Phil Steitz */ @@ -65,5 +65,16 @@ public class TestUnmodifiableSet extends AbstractTestSet{ public boolean isRemoveSupported() { return false; } - + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableSet.fullCollection.version3.1.obj"); +// } + } diff --git a/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java b/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java index eeb98266f..ead891192 100644 --- a/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java +++ b/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java @@ -30,7 +30,7 @@ import org.apache.commons.collections.BulkTest; * {@link UnmodifiableSortedSet} implementation. * * @since Commons Collections 3.0 - * @version $Revision: 1.6 $ $Date: 2004/02/18 01:20:39 $ + * @version $Revision: 1.7 $ $Date: 2004/06/02 22:12:14 $ * * @author Phil Steitz */ @@ -136,4 +136,16 @@ public class TestUnmodifiableSortedSet extends AbstractTestSortedSet{ Comparator c = set.comparator(); assertTrue("natural order, so comparator should be null", c == null); } -} \ No newline at end of file + + public String getCompatibilityVersion() { + return "3.1"; + } + +// public void testCreate() throws Exception { +// resetEmpty(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableSortedSet.emptyCollection.version3.1.obj"); +// resetFull(); +// writeExternalFormToDisk((java.io.Serializable) collection, "D:/dev/collections/data/test/UnmodifiableSortedSet.fullCollection.version3.1.obj"); +// } + +}