commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwaldh...@apache.org
Subject cvs commit: jakarta-commons/collections/src/test/org/apache/commons/collections/comparators TestComparator.java
Date Wed, 26 Feb 2003 01:33:22 GMT
rwaldhoff    2003/02/25 17:33:22

  Modified:    collections maven.xml
               collections/src/test/org/apache/commons/collections
                        TestList.java TestMap.java TestObject.java
               collections/src/test/org/apache/commons/collections/comparators
                        TestComparator.java
  Log:
  dynamically disable certain serialization tests when run under clover
  
  Revision  Changes    Path
  1.2       +5 -3      jakarta-commons/collections/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	23 Jul 2002 16:41:11 -0000	1.1
  +++ maven.xml	26 Feb 2003 01:33:22 -0000	1.2
  @@ -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>
  
  
  
  1.16      +12 -8     jakarta-commons/collections/src/test/org/apache/commons/collections/TestList.java
  
  Index: TestList.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestList.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- TestList.java	25 Jan 2003 12:55:43 -0000	1.15
  +++ TestList.java	26 Feb 2003 01:33:22 -0000	1.16
  @@ -925,9 +925,11 @@
           */
   
           // 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 @@
           */
   
           // 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);
  +        }
       }
   
   
  
  
  
  1.23      +14 -10    jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java
  
  Index: TestMap.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMap.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TestMap.java	1 Nov 2002 19:36:54 -0000	1.22
  +++ TestMap.java	26 Feb 2003 01:33:22 -0000	1.23
  @@ -633,9 +633,11 @@
           */
   
           // 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 @@
           */
   
           // 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);
  +        }
       }
   
       /**
  
  
  
  1.20      +6 -2      jakarta-commons/collections/src/test/org/apache/commons/collections/TestObject.java
  
  Index: TestObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestObject.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TestObject.java	26 Feb 2003 00:35:19 -0000	1.19
  +++ TestObject.java	26 Feb 2003 01:33:22 -0000	1.20
  @@ -334,6 +334,10 @@
           return readExternalFormFromStream(stream);
       }
   
  +    protected boolean skipSerializedCanonicalTests() {
  +        return Boolean.getBoolean("org.apache.commons.collections:with-clover");
  +    }
  +
       // private
       // ------------------------------------------------------------------------
   
  
  
  
  1.8       +34 -34    jakarta-commons/collections/src/test/org/apache/commons/collections/comparators/TestComparator.java
  
  Index: TestComparator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/comparators/TestComparator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestComparator.java	19 Feb 2003 20:33:20 -0000	1.7
  +++ TestComparator.java	26 Feb 2003 01:33:22 -0000	1.8
  @@ -131,40 +131,40 @@
        * 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));
  +        }
       }
   
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message