Add isEqualsCheckable and fix testSerializeDeserializeThenCompare in Collection
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@131757 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
145b19acc4
commit
111e7b39de
|
@ -112,7 +112,7 @@ import org.apache.commons.collections.AbstractTestObject;
|
|||
* you may still use this base set of cases. Simply override the
|
||||
* test case (method) your {@link Collection} fails.
|
||||
*
|
||||
* @version $Revision: 1.5 $ $Date: 2004/04/09 15:16:24 $
|
||||
* @version $Revision: 1.6 $ $Date: 2004/05/31 19:09:14 $
|
||||
*
|
||||
* @author Rodney Waldhoff
|
||||
* @author Paul Jack
|
||||
|
@ -228,6 +228,14 @@ public abstract class AbstractTestCollection extends AbstractTestObject {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true to indicate that the collection supports equals() comparisons.
|
||||
* The default implementation returns false;
|
||||
*/
|
||||
public boolean isEqualsCheckable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Verifies that {@link #collection} and {@link #confirmed} have
|
||||
|
@ -1301,7 +1309,9 @@ public abstract class AbstractTestCollection extends AbstractTestObject {
|
|||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
|
||||
Object dest = in.readObject();
|
||||
in.close();
|
||||
assertEquals("obj != deserialize(serialize(obj)) - EMPTY Collection", obj, dest);
|
||||
if (isEqualsCheckable()) {
|
||||
assertEquals("obj != deserialize(serialize(obj)) - EMPTY Collection", obj, dest);
|
||||
}
|
||||
}
|
||||
obj = makeFullCollection();
|
||||
if (obj instanceof Serializable) {
|
||||
|
@ -1313,7 +1323,10 @@ public abstract class AbstractTestCollection extends AbstractTestObject {
|
|||
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray()));
|
||||
Object dest = in.readObject();
|
||||
in.close();
|
||||
assertEquals("obj != deserialize(serialize(obj)) - FULL Collection", obj, dest);
|
||||
if (isEqualsCheckable()) {
|
||||
assertEquals("obj != deserialize(serialize(obj)) - FULL Collection", obj, dest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.apache.commons.collections.iterators.AbstractTestListIterator;
|
|||
* test case (method) your {@link List} fails or override one of the
|
||||
* protected methods from AbstractTestCollection.
|
||||
*
|
||||
* @version $Revision: 1.7 $ $Date: 2004/05/12 22:20:54 $
|
||||
* @version $Revision: 1.8 $ $Date: 2004/05/31 19:09:14 $
|
||||
*
|
||||
* @author Rodney Waldhoff
|
||||
* @author Paul Jack
|
||||
|
@ -109,6 +109,13 @@ public abstract class AbstractTestList extends AbstractTestCollection {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* List equals method is defined.
|
||||
*/
|
||||
public boolean isEqualsCheckable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty {@link ArrayList}.
|
||||
*/
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.apache.commons.collections.collection.AbstractTestCollection;
|
|||
* elements may be added; see {@link AbstractTestCollection} for more details.
|
||||
*
|
||||
* @since Commons Collections 3.0
|
||||
* @version $Revision: 1.4 $ $Date: 2004/02/18 01:20:39 $
|
||||
* @version $Revision: 1.5 $ $Date: 2004/05/31 19:09:14 $
|
||||
*
|
||||
* @author Paul Jack
|
||||
*/
|
||||
|
@ -72,6 +72,13 @@ public abstract class AbstractTestSet extends AbstractTestCollection {
|
|||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
/**
|
||||
* Set equals method is defined.
|
||||
*/
|
||||
public boolean isEqualsCheckable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an empty Set for use in modification testing.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue