dynamically disable certain serialization tests when run under clover

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/collections/trunk@130977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rodney Waldhoff 2003-02-26 01:33:22 +00:00
parent fa08d185aa
commit 4b88bc49c1
5 changed files with 71 additions and 57 deletions

View File

@ -1,4 +1,6 @@
<project default="java:jar"
xmlns:j="jelly:core">
<project default="java:jar" xmlns:j="jelly:core">
<postGoal name="clover:on">
<j:set var="maven.junit.sysproperties" value="${maven.junit.sysproperties} org.apache.commons.collections:with-clover"/>
<j:set var="org.apache.commons.collections:with-clover" value="true"/>
</postGoal>
</project>

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestList.java,v 1.15 2003/01/25 12:55:43 scolebourne Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestList.java,v 1.16 2003/02/26 01:33:22 rwaldhoff Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@ -82,7 +82,7 @@ import java.util.NoSuchElementException;
* you may still use this base set of cases. Simply override the
* test case (method) your {@link List} fails.
*
* @version $Revision: 1.15 $ $Date: 2003/01/25 12:55:43 $
* @version $Revision: 1.16 $ $Date: 2003/02/26 01:33:22 $
*
* @author Rodney Waldhoff
* @author Paul Jack
@ -925,9 +925,11 @@ public abstract class TestList extends TestCollection {
*/
// test to make sure the canonical form has been preserved
if (!(makeEmptyList() instanceof Serializable)) return;
List list = (List) readExternalFormFromDisk(getCanonicalEmptyCollectionName(makeEmptyList()));
assertTrue("List is empty",list.size() == 0);
List list = makeEmptyList();
if(list instanceof Serializable && !skipSerializedCanonicalTests()) {
List list2 = (List) readExternalFormFromDisk(getCanonicalEmptyCollectionName(list));
assertTrue("List is empty",list2.size() == 0);
}
}
/**
@ -944,9 +946,11 @@ public abstract class TestList extends TestCollection {
*/
// test to make sure the canonical form has been preserved
if (!(makeFullList() instanceof Serializable)) return;
List list = (List) readExternalFormFromDisk(getCanonicalFullCollectionName(makeFullList()));
assertEquals("List is the right size",list.size(), 4);
List list = makeFullList();
if(list instanceof Serializable && !skipSerializedCanonicalTests()) {
List list2 = (List) readExternalFormFromDisk(getCanonicalFullCollectionName(list));
assertEquals("List is the right size",list2.size(), 4);
}
}

View File

@ -1,7 +1,7 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.22 2002/11/01 19:36:54 rwaldhoff Exp $
* $Revision: 1.22 $
* $Date: 2002/11/01 19:36:54 $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestMap.java,v 1.23 2003/02/26 01:33:22 rwaldhoff Exp $
* $Revision: 1.23 $
* $Date: 2003/02/26 01:33:22 $
*
* ====================================================================
*
@ -152,7 +152,7 @@ import java.util.Set;
* @author Michael Smith
* @author Rodney Waldhoff
* @author Paul Jack
* @version $Revision: 1.22 $ $Date: 2002/11/01 19:36:54 $
* @version $Revision: 1.23 $ $Date: 2003/02/26 01:33:22 $
*/
public abstract class TestMap extends TestObject {
@ -633,9 +633,11 @@ public abstract class TestMap extends TestObject {
*/
// test to make sure the canonical form has been preserved
if (!(makeEmptyMap() instanceof Serializable)) return;
Map map = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(makeEmptyMap()));
assertTrue("Map is empty",map.isEmpty() == true);
Map map = makeEmptyMap();
if(map instanceof Serializable && !skipSerializedCanonicalTests()) {
Map map2 = (Map) readExternalFormFromDisk(getCanonicalEmptyCollectionName(map));
assertTrue("Map is empty",map2.isEmpty());
}
}
/**
@ -652,9 +654,11 @@ public abstract class TestMap extends TestObject {
*/
// test to make sure the canonical form has been preserved
if (!(makeFullMap() instanceof Serializable)) return;
Map map = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(makeFullMap()));
assertEquals("Map is the right size",map.size(), getSampleKeys().length);
Map map = makeFullMap();
if(map instanceof Serializable && !skipSerializedCanonicalTests()) {
Map map2 = (Map) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
assertEquals("Map is the right size",map2.size(), getSampleKeys().length);
}
}
/**

View File

@ -1,5 +1,5 @@
/*
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestObject.java,v 1.19 2003/02/26 00:35:19 rwaldhoff Exp $
* $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/Attic/TestObject.java,v 1.20 2003/02/26 01:33:22 rwaldhoff Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@ -83,7 +83,7 @@ import java.io.Serializable;
* @author Rodney Waldhoff
* @author Anonymous
*
* @version $Revision: 1.19 $ $Date: 2003/02/26 00:35:19 $
* @version $Revision: 1.20 $ $Date: 2003/02/26 01:33:22 $
*/
public abstract class TestObject extends BulkTest {
@ -334,6 +334,10 @@ public abstract class TestObject extends BulkTest {
return readExternalFormFromStream(stream);
}
protected boolean skipSerializedCanonicalTests() {
return Boolean.getBoolean("org.apache.commons.collections:with-clover");
}
// private
// ------------------------------------------------------------------------

View File

@ -131,40 +131,40 @@ public abstract class TestComparator extends TestObject {
* against the canonical version in CVS.
*/
public void testComparatorCompatibility() throws IOException, ClassNotFoundException {
Comparator comparator = null;
// test to make sure the canonical form has been preserved
try {
comparator =
(Comparator) readExternalFormFromDisk
(getCanonicalComparatorName(makeComparator()));
} catch (FileNotFoundException exception) {
boolean autoCreateSerialized = false;
if(autoCreateSerialized) {
comparator = makeComparator();
String fileName = getCanonicalComparatorName(comparator);
writeExternalFormToDisk((Serializable) comparator, fileName);
fail("Serialized form could not be found. A serialized version " +
"has now been written (and should be added to CVS): " + fileName);
} else {
fail("The Serialized form could be located to test serialization " +
"compatibility: " + exception.getMessage());
}
}
// make sure the canonical form produces the ordering we currently
// expect
List randomList = getComparableObjectsOrdered();
reverseObjects(randomList);
sortObjects(randomList,comparator);
List orderedList = getComparableObjectsOrdered();
assertTrue("Comparator did not reorder the List correctly",
orderedList.equals(randomList));
if(!skipSerializedCanonicalTests()) {
Comparator comparator = null;
// test to make sure the canonical form has been preserved
try {
comparator = (Comparator) readExternalFormFromDisk(getCanonicalComparatorName(makeComparator()));
} catch (FileNotFoundException exception) {
boolean autoCreateSerialized = false;
if(autoCreateSerialized) {
comparator = makeComparator();
String fileName = getCanonicalComparatorName(comparator);
writeExternalFormToDisk((Serializable) comparator, fileName);
fail("Serialized form could not be found. A serialized version " +
"has now been written (and should be added to CVS): " + fileName);
} else {
fail("The Serialized form could be located to test serialization " +
"compatibility: " + exception.getMessage());
}
}
// make sure the canonical form produces the ordering we currently
// expect
List randomList = getComparableObjectsOrdered();
reverseObjects(randomList);
sortObjects(randomList,comparator);
List orderedList = getComparableObjectsOrdered();
assertTrue("Comparator did not reorder the List correctly",
orderedList.equals(randomList));
}
}
}