scolebourne    2004/12/19 08:56:31

  Modified:    collections/src/java/org/apache/commons/collections
                        MapUtils.java ListUtils.java CollectionUtils.java
               collections/src/test/org/apache/commons/collections
                        TestMapUtils.java TestListUtils.java
                        TestCollectionUtils.java
  Log:
  Fix formatting
  
  Revision  Changes    Path
  1.51      +11 -11    
jakarta-commons/collections/src/java/org/apache/commons/collections/MapUtils.java
  
  Index: MapUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/MapUtils.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- MapUtils.java     11 Dec 2004 06:26:13 -0000      1.50
  +++ MapUtils.java     19 Dec 2004 16:56:30 -0000      1.51
  @@ -1222,19 +1222,19 @@
           return UnmodifiableMap.decorate(map);
       }
       
  -     /**
  -      * Returns an unmodifiable copy of the map.
  +    /**
  +     * Returns an unmodifiable copy of the map.
        * @param map  the map to make an unmodifiable copy of, must not be null
        * @return an unmodifiable map backed by the given map
        * @throws IllegalArgumentException  if the map is null
  -      */
  -     public static Map unmodifiableMapCopy(final Map map) {
  -             if (map == null) throw new IllegalArgumentException("null not 
permitted.");
  -             
  -             final Map copy = new HashMap(map.size(), 1.0f);
  -             copy.putAll(map);
  -             return MapUtils.unmodifiableMap(copy);
  -     }
  +     */
  +    public static Map unmodifiableMapCopy(Map map) {
  +        if (map == null) throw new IllegalArgumentException("null not 
permitted.");
  +        
  +        Map copy = new HashMap(map.size(), 1.0f);
  +        copy.putAll(map);
  +        return MapUtils.unmodifiableMap(copy);
  +    }
   
       /**
        * Returns a predicated (validating) map backed by the given map.
  
  
  
  1.30      +66 -76    
jakarta-commons/collections/src/java/org/apache/commons/collections/ListUtils.java
  
  Index: ListUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/ListUtils.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ListUtils.java    11 Dec 2004 06:22:58 -0000      1.29
  +++ ListUtils.java    19 Dec 2004 16:56:30 -0000      1.30
  @@ -259,21 +259,21 @@
       }
   
       
  -     /**
  -      * Returns an unmodifiable list copy of the collection.
  -      * <p>
  -      * This method uses the unmodifiable list implementation in the 
decorators subpackage.
  -      * @param collection the <code>Collection</code> to copy.
  -      * @return an unmodifiable <code>List</code>.
  -      * @throws IllegalArgumentException if collection is null.
  -      */
  -     public static List unmodifiableListCopy(final Collection collection) {
  -             if (collection == null) throw new 
IllegalArgumentException("null not permitted.");
  -             
  -             final List copy = new ArrayList(collection.size());
  -             copy.addAll(collection);
  -             return UnmodifiableList.decorate(copy);
  -     }
  +    /**
  +     * Returns an unmodifiable list copy of the collection.
  +     * <p>
  +     * This method uses the unmodifiable list implementation in the 
decorators subpackage.
  +     * @param collection the <code>Collection</code> to copy.
  +     * @return an unmodifiable <code>List</code>.
  +     * @throws IllegalArgumentException if collection is null.
  +     */
  +    public static List unmodifiableListCopy(final Collection collection) {
  +        if (collection == null) throw new IllegalArgumentException("null not 
permitted.");
  +        
  +        final List copy = new ArrayList(collection.size());
  +        copy.addAll(collection);
  +        return UnmodifiableList.decorate(copy);
  +    }
       
       /**
        * Returns a predicated (validating) list backed by the given list.
  @@ -369,65 +369,55 @@
       }
   
       /**
  -      * Returns a List containing all the elements in <code>collection</code>
  -      * that are also in <code>retain</code>. The cardinality of an element 
<code>e</code>
  -      * in the returned list is the same as the cardinality of <code>e</code>
  -      * in <code>collection</code> unless <code>retain</code> does not 
contain <code>e</code>, in which
  -      * case the cardinality is zero. This method is useful if you do not 
wish to modify
  -      * the collection <code>c</code> and thus cannot call 
<code>collection.retainAll(retain);</code>.
  -      * 
  -      * @param collection the collection whose contents are the target of 
the #retailAll operation
  -      * @param retain the collection containing the elements to be retained 
in the returned collection
  -      * @return a <code>List</code> containing all the elements of 
<code>c</code>
  -      * that occur at least once in <code>retain</code>.
  -      * @throws NullPointerException if either parameter is null
  -      */
  -     public static List retainAll(final Collection collection, final 
Collection retain) {
  -             final List list = new ArrayList(Math.min(collection.size(), 
retain.size()));
  -
  -             Object item = null;
  -             for (final Iterator iter = collection.iterator(); 
iter.hasNext();)
  -             {
  -                     item = iter.next();
  -
  -                     if (retain.contains(item))
  -                     {
  -                             list.add(item);
  -                     }
  -             }
  -
  -             return list;
  -     }
  -     
  -     /**
  -      * Removes the elements in <code>remove</code> from 
<code>collection</code>. That is, this
  -      * method returns a list containing all the elements in <code>c</code>
  -      * that are not in <code>remove</code>. The cardinality of an element 
<code>e</code>
  -      * in the returned collection is the same as the cardinality of 
<code>e</code>
  -      * in <code>collection</code> unless <code>remove</code> contains 
<code>e</code>, in which
  -      * case the cardinality is zero. This method is useful if you do not 
wish to modify
  -      * <code>collection</code> and thus cannot call 
<code>collection.removeAll(remove);</code>.
  -      * 
  -      * @param collection the collection from which items are removed (in 
the returned collection)
  -      * @param remove the items to be removed from the returned 
<code>collection</code>
  -      * @return a <code>List</code> containing all the elements of 
<code>c</code> except
  -      * any elements that also occur in <code>remove</code>.
  -      * @throws NullPointerException if either parameter is null
  -      */
  -     public static List removeAll(final Collection collection, final 
Collection remove) {
  -             final List list = new ArrayList();
  -
  -             Object o = null;
  -             for (final Iterator iter = collection.iterator(); 
iter.hasNext();)
  -             {
  -                     o = iter.next();
  -                     if (remove.contains(o) == false)
  -                     {
  -                             list.add(o);
  -                     }
  -             }
  +     * Returns a List containing all the elements in <code>collection</code>
  +     * that are also in <code>retain</code>. The cardinality of an element 
<code>e</code>
  +     * in the returned list is the same as the cardinality of <code>e</code>
  +     * in <code>collection</code> unless <code>retain</code> does not 
contain <code>e</code>, in which
  +     * case the cardinality is zero. This method is useful if you do not 
wish to modify
  +     * the collection <code>c</code> and thus cannot call 
<code>collection.retainAll(retain);</code>.
  +     * 
  +     * @param collection  the collection whose contents are the target of 
the #retailAll operation
  +     * @param retain  the collection containing the elements to be retained 
in the returned collection
  +     * @return a <code>List</code> containing all the elements of 
<code>c</code>
  +     * that occur at least once in <code>retain</code>.
  +     * @throws NullPointerException if either parameter is null
  +     */
  +    public static List retainAll(Collection collection, Collection retain) {
  +        List list = new ArrayList(Math.min(collection.size(), 
retain.size()));
  +
  +        for (Iterator iter = collection.iterator(); iter.hasNext();) {
  +            Object obj = iter.next();
  +            if (retain.contains(obj)) {
  +                list.add(obj);
  +            }
  +        }
  +        return list;
  +    }
  +
  +    /**
  +     * Removes the elements in <code>remove</code> from 
<code>collection</code>. That is, this
  +     * method returns a list containing all the elements in <code>c</code>
  +     * that are not in <code>remove</code>. The cardinality of an element 
<code>e</code>
  +     * in the returned collection is the same as the cardinality of 
<code>e</code>
  +     * in <code>collection</code> unless <code>remove</code> contains 
<code>e</code>, in which
  +     * case the cardinality is zero. This method is useful if you do not 
wish to modify
  +     * <code>collection</code> and thus cannot call 
<code>collection.removeAll(remove);</code>.
  +     * 
  +     * @param collection  the collection from which items are removed (in 
the returned collection)
  +     * @param remove  the items to be removed from the returned 
<code>collection</code>
  +     * @return a <code>List</code> containing all the elements of 
<code>c</code> except
  +     * any elements that also occur in <code>remove</code>.
  +     * @throws NullPointerException if either parameter is null
  +     */
  +    public static List removeAll(Collection collection, Collection remove) {
  +        List list = new ArrayList();
  +        for (Iterator iter = collection.iterator(); iter.hasNext();) {
  +            Object obj = iter.next();
  +            if (remove.contains(obj) == false) {
  +                list.add(obj);
  +            }
  +        }
  +        return list;
  +    }
   
  -             return list;
  -     }
  -    
   }
  
  
  
  1.64      +53 -53    
jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java
  
  Index: CollectionUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/CollectionUtils.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- CollectionUtils.java      11 Dec 2004 06:30:38 -0000      1.63
  +++ CollectionUtils.java      19 Dec 2004 16:56:30 -0000      1.64
  @@ -55,7 +55,7 @@
    */
   public class CollectionUtils {
   
  -     /** Constant to avoid repeated object creation */
  +    /** Constant to avoid repeated object creation */
       private static Integer INTEGER_ONE = new Integer(1);
   
       /**
  @@ -1049,22 +1049,23 @@
           return UnmodifiableCollection.decorate(collection);
       }
   
  -     /**
  -      * Returns an unmodifiable copy of the collection.
  -      * <p>
  +    /**
  +     * Returns an unmodifiable copy of the collection.
  +     * <p>
        * This method uses the implementation in the decorators subpackage.
        * 
  -      * @param collection the <code>Collection</code> to copy.
  -      * @return an unmodifiable <code>Collection</code>.
  -      * @throws IllegalArgumentException if collection is null
  -      */
  -     public static Collection unmodifiableCollectionCopy(final Collection 
collection){
  -             if (collection == null) throw new 
IllegalArgumentException("null not permitted.");
  -             
  -             final Collection copy = new ArrayList(collection.size());
  -             copy.addAll(collection);
  -             return UnmodifiableCollection.decorate(copy);
  -     }
  +     * @param collection the <code>Collection</code> to copy.
  +     * @return an unmodifiable <code>Collection</code>.
  +     * @throws IllegalArgumentException if collection is null
  +     */
  +    public static Collection unmodifiableCollectionCopy(final Collection 
collection){
  +        if (collection == null) throw new IllegalArgumentException("null not 
permitted.");
  +        
  +        final Collection copy = new ArrayList(collection.size());
  +        copy.addAll(collection);
  +        return UnmodifiableCollection.decorate(copy);
  +    }
  +
       /**
        * Returns a predicated (validating) collection backed by the given 
collection.
        * <p>
  @@ -1111,42 +1112,41 @@
           return TransformedCollection.decorate(collection, transformer);
       }
      
  -     /**
  -      * Returns a collection containing all the elements in 
<code>collection</code>
  -      * that are also in <code>retain</code>. The cardinality of an element 
<code>e</code>
  -      * in the returned collection is the same as the cardinality of 
<code>e</code>
  -      * in <code>collection</code> unless <code>retain</code> does not 
contain <code>e</code>, in which
  -      * case the cardinality is zero. This method is useful if you do not 
wish to modify
  -      * the collection <code>c</code> and thus cannot call 
<code>c.retainAll(retain);</code>.
  -      * 
  -      * @param collection the collection whose contents are the target of 
the #retailAll operation
  -      * @param retain the collection containing the elements to be retained 
in the returned collection
  -      * @return a <code>Collection</code> containing all the elements of 
<code>collection</code>
  -      * that occur at least once in <code>retain</code>.
  -      * @throws NullPointerException if either parameter is null
  -      */
  -     public static Collection retainAll(final Collection collection, final 
Collection retain) {
  -             return ListUtils.retainAll(collection, retain);
  -     }
  -
  -     /**
  -      * Removes the elements in <code>remove</code> from 
<code>collection</code>. That is, this
  -      * method returns a collection containing all the elements in 
<code>c</code>
  -      * that are not in <code>remove</code>. The cardinality of an element 
<code>e</code>
  -      * in the returned collection is the same as the cardinality of 
<code>e</code>
  -      * in <code>collection</code> unless <code>remove</code> contains 
<code>e</code>, in which
  -      * case the cardinality is zero. This method is useful if you do not 
wish to modify
  -      * the collection <code>c</code> and thus cannot call 
<code>collection.removeAll(remove);</code>.
  -      * 
  -      * @param collection the collection from which items are removed (in 
the returned collection)
  -      * @param remove the items to be removed from the returned 
<code>collection</code>
  -      * @return a <code>Collection</code> containing all the elements of 
<code>collection</code> except
  -      * any elements that also occur in <code>remove</code>.
  -      * @throws NullPointerException if either parameter is null
  -      */
  -     public static Collection removeAll(final Collection collection, final 
Collection remove) {
  -             return ListUtils.retainAll(collection, remove);
  -     }
  -     
  +    /**
  +     * Returns a collection containing all the elements in 
<code>collection</code>
  +     * that are also in <code>retain</code>. The cardinality of an element 
<code>e</code>
  +     * in the returned collection is the same as the cardinality of 
<code>e</code>
  +     * in <code>collection</code> unless <code>retain</code> does not 
contain <code>e</code>, in which
  +     * case the cardinality is zero. This method is useful if you do not 
wish to modify
  +     * the collection <code>c</code> and thus cannot call 
<code>c.retainAll(retain);</code>.
  +     * 
  +     * @param collection  the collection whose contents are the target of 
the #retailAll operation
  +     * @param retain  the collection containing the elements to be retained 
in the returned collection
  +     * @return a <code>Collection</code> containing all the elements of 
<code>collection</code>
  +     * that occur at least once in <code>retain</code>.
  +     * @throws NullPointerException if either parameter is null
  +     */
  +    public static Collection retainAll(Collection collection, Collection 
retain) {
  +        return ListUtils.retainAll(collection, retain);
  +    }
  +
  +    /**
  +     * Removes the elements in <code>remove</code> from 
<code>collection</code>. That is, this
  +     * method returns a collection containing all the elements in 
<code>c</code>
  +     * that are not in <code>remove</code>. The cardinality of an element 
<code>e</code>
  +     * in the returned collection is the same as the cardinality of 
<code>e</code>
  +     * in <code>collection</code> unless <code>remove</code> contains 
<code>e</code>, in which
  +     * case the cardinality is zero. This method is useful if you do not 
wish to modify
  +     * the collection <code>c</code> and thus cannot call 
<code>collection.removeAll(remove);</code>.
  +     * 
  +     * @param collection  the collection from which items are removed (in 
the returned collection)
  +     * @param remove  the items to be removed from the returned 
<code>collection</code>
  +     * @return a <code>Collection</code> containing all the elements of 
<code>collection</code> except
  +     * any elements that also occur in <code>remove</code>.
  +     * @throws NullPointerException if either parameter is null
  +     */
  +    public static Collection removeAll(Collection collection, Collection 
remove) {
  +        return ListUtils.retainAll(collection, remove);
  +    }
   
   }
  
  
  
  1.26      +26 -32    
jakarta-commons/collections/src/test/org/apache/commons/collections/TestMapUtils.java
  
  Index: TestMapUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMapUtils.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- TestMapUtils.java 11 Dec 2004 06:26:13 -0000      1.25
  +++ TestMapUtils.java 19 Dec 2004 16:56:31 -0000      1.26
  @@ -771,36 +771,30 @@
           assertEquals(EXPECTED_OUT, out.toString());
       }
       
  -     public void testUnmodifiableMapCopy() {
  -             Map map = new HashMap();
  -             map.put("key", "value");
  +    public void testUnmodifiableMapCopy() {
  +        Map map = new HashMap();
  +        map.put("key", "value");
   
  -             Map copy = MapUtils.unmodifiableMapCopy(map);
  -             assertTrue(copy instanceof Unmodifiable);
  -             assertEquals(map, copy);
  -             map.clear();
  -             assertFalse(map.equals(copy));
  +        Map copy = MapUtils.unmodifiableMapCopy(map);
  +        assertTrue(copy instanceof Unmodifiable);
  +        assertEquals(map, copy);
  +        map.clear();
  +        assertFalse(map.equals(copy));
   
  -             try
  -             {
  -                     copy.clear();
  -                     fail("should be unmodifiable.");
  -             }
  -             catch (UnsupportedOperationException uoe)
  -             {
  -                     // this is what we want
  -             }
  -             
  -             try
  -             {
  -                     map = MapUtils.unmodifiableMapCopy(null);
  -                     fail("expecting IllegalArgumentException");
  -             }
  -             catch (IllegalArgumentException iae)
  -             {
  -                     // this is what we want
  -             }
  +        try {
  +            copy.clear();
  +            fail("should be unmodifiable.");
  +        } catch (UnsupportedOperationException uoe) {
  +            // this is what we want
  +        }
  +        
  +        try {
  +            map = MapUtils.unmodifiableMapCopy(null);
  +            fail("expecting IllegalArgumentException");
  +        } catch (IllegalArgumentException iae) {
  +            // this is what we want
  +        }
  +
  +    }
   
  -     }
  -    
   }
  
  
  
  1.21      +93 -105   
jakarta-commons/collections/src/test/org/apache/commons/collections/TestListUtils.java
  
  Index: TestListUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestListUtils.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- TestListUtils.java        11 Dec 2004 06:24:10 -0000      1.20
  +++ TestListUtils.java        19 Dec 2004 16:56:31 -0000      1.21
  @@ -35,17 +35,17 @@
    */
   public class TestListUtils extends BulkTest {
   
  -     private static final String a = "a";
  -     private static final String b = "b";
  -     private static final String c = "c";
  -     private static final String d = "d";
  -     private static final String e = "e";
  -     private static final String x = "x";
  -
  -     private String[] fullArray;
  -     private List fullList;
  -     
  -     public TestListUtils(String name) {
  +    private static final String a = "a";
  +    private static final String b = "b";
  +    private static final String c = "c";
  +    private static final String d = "d";
  +    private static final String e = "e";
  +    private static final String x = "x";
  +
  +    private String[] fullArray;
  +    private List fullList;
  +    
  +    public TestListUtils(String name) {
           super(name);
       }
   
  @@ -53,10 +53,10 @@
           return BulkTest.makeSuite(TestListUtils.class);
       }
   
  -     public void setUp() {
  -             fullArray = new String[]{a, b, c, d, e};
  -             fullList = new ArrayList(Arrays.asList(fullArray));
  -     }
  +    public void setUp() {
  +        fullArray = new String[]{a, b, c, d, e};
  +        fullList = new ArrayList(Arrays.asList(fullArray));
  +    }
       
       
       public void testNothing() {
  @@ -106,12 +106,12 @@
           assertEquals(6, list.size());
       }
   
  -     public void testEquals() {
  -             Collection data = Arrays.asList( new String[] { "a", "b", "c" 
});
  -             
  -             List a = new ArrayList( data );
  -             List b = new ArrayList( data );
  -             
  +    public void testEquals() {
  +        Collection data = Arrays.asList( new String[] { "a", "b", "c" });
  +        
  +        List a = new ArrayList( data );
  +        List b = new ArrayList( data );
  +        
           assertEquals(true, a.equals(b));
           assertEquals(true, ListUtils.isEqualList(a, b));
           a.clear();
  @@ -119,14 +119,14 @@
           assertEquals(false, ListUtils.isEqualList(a, null));
           assertEquals(false, ListUtils.isEqualList(null, b));
           assertEquals(true, ListUtils.isEqualList(null, null));
  -     }
  -     
  -     public void testHashCode() {
  -             Collection data = Arrays.asList( new String[] { "a", "b", "c" 
});
  -                     
  -             List a = new ArrayList( data );
  -             List b = new ArrayList( data );
  -             
  +    }
  +    
  +    public void testHashCode() {
  +        Collection data = Arrays.asList( new String[] { "a", "b", "c" });
  +            
  +        List a = new ArrayList( data );
  +        List b = new ArrayList( data );
  +        
           assertEquals(true, a.hashCode() == b.hashCode());
           assertEquals(true, a.hashCode() == ListUtils.hashCodeForList(a));
           assertEquals(true, b.hashCode() == ListUtils.hashCodeForList(b));
  @@ -134,79 +134,67 @@
           a.clear();
           assertEquals(false, ListUtils.hashCodeForList(a) == 
ListUtils.hashCodeForList(b));
           assertEquals(0, ListUtils.hashCodeForList(null));
  -     }
  -     
  -     public void testUnmodifiableListCopy() {
  -             List list = new ArrayList();
  -             list.add("a");
  -             List copy = ListUtils.unmodifiableListCopy(list);
  -
  -             assertTrue(copy instanceof Unmodifiable);
  -             assertTrue(list.equals(copy));
  -             list.clear();
  -             assertTrue(copy.isEmpty() == false);
  -
  -             try
  -             {
  -                     copy.clear();
  -                     fail("should be unmodifiable.");
  -             }
  -             catch (UnsupportedOperationException uoe)
  -             {
  -                     // this is what we want
  -             }
  -             
  -             try
  -             {
  -                     list = ListUtils.unmodifiableListCopy(null);
  -                     fail("expecting IllegalArgumentException");
  -             }
  -             catch (IllegalArgumentException iae)
  -             {
  -                     // this is what we want
  -             }
  -     }
  -     
  -     public void testRetainAll() {
  -             List sub = new ArrayList();
  -             sub.add(a);
  -             sub.add(b);
  -             sub.add(x);
  -
  -             List retained = ListUtils.retainAll(fullList, sub);
  -             assertTrue(retained.size() == 2);
  -             sub.remove(x);
  -             assertTrue(retained.equals(sub));
  -             fullList.retainAll(sub);
  -             assertTrue(retained.equals(fullList));
  -             
  -             try
  -             {
  -                     List list = ListUtils.retainAll(null, null);
  -                     fail("expecting NullPointerException");
  -             }
  -             catch(NullPointerException npe)
  -             {} // this is what we want
  -     }
  -
  -     public void testRemoveAll() {
  -             List sub = new ArrayList();
  -             sub.add(a);
  -             sub.add(b);
  -             sub.add(x);
  -
  -             List remainder = ListUtils.removeAll(fullList, sub);
  -             assertTrue(remainder.size() == 3);
  -             fullList.removeAll(sub);
  -             assertTrue(remainder.equals(fullList));
  -             
  -             try
  -             {
  -                     List list = ListUtils.removeAll(null, null);
  -                     fail("expecting NullPointerException");
  -             }
  -             catch(NullPointerException npe)
  -             {} // this is what we want
  -     }
  -     
  +    }
  +    
  +    public void testUnmodifiableListCopy() {
  +        List list = new ArrayList();
  +        list.add("a");
  +        List copy = ListUtils.unmodifiableListCopy(list);
  +
  +        assertTrue(copy instanceof Unmodifiable);
  +        assertTrue(list.equals(copy));
  +        list.clear();
  +        assertTrue(copy.isEmpty() == false);
  +
  +        try {
  +            copy.clear();
  +            fail("should be unmodifiable.");
  +        } catch (UnsupportedOperationException uoe) {
  +            // this is what we want
  +        }
  +        
  +        try {
  +            list = ListUtils.unmodifiableListCopy(null);
  +            fail("expecting IllegalArgumentException");
  +        } catch (IllegalArgumentException iae) {
  +            // this is what we want
  +        }
  +    }
  +    
  +    public void testRetainAll() {
  +        List sub = new ArrayList();
  +        sub.add(a);
  +        sub.add(b);
  +        sub.add(x);
  +
  +        List retained = ListUtils.retainAll(fullList, sub);
  +        assertTrue(retained.size() == 2);
  +        sub.remove(x);
  +        assertTrue(retained.equals(sub));
  +        fullList.retainAll(sub);
  +        assertTrue(retained.equals(fullList));
  +        
  +        try {
  +            List list = ListUtils.retainAll(null, null);
  +            fail("expecting NullPointerException");
  +        } catch(NullPointerException npe){} // this is what we want
  +    }
  +
  +    public void testRemoveAll() {
  +        List sub = new ArrayList();
  +        sub.add(a);
  +        sub.add(b);
  +        sub.add(x);
  +
  +        List remainder = ListUtils.removeAll(fullList, sub);
  +        assertTrue(remainder.size() == 3);
  +        fullList.removeAll(sub);
  +        assertTrue(remainder.equals(fullList));
  +        
  +        try {
  +            List list = ListUtils.removeAll(null, null);
  +            fail("expecting NullPointerException");
  +        } catch(NullPointerException npe) {} // this is what we want
  +    }
  +    
   }
  
  
  
  1.43      +16 -21    
jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java
  
  Index: TestCollectionUtils.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestCollectionUtils.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- TestCollectionUtils.java  11 Dec 2004 06:30:38 -0000      1.42
  +++ TestCollectionUtils.java  19 Dec 2004 16:56:31 -0000      1.43
  @@ -17,7 +17,6 @@
   
   import java.util.ArrayList;
   import java.util.Collection;
  -import java.util.Collections;
   import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.HashSet;
  @@ -1198,30 +1197,26 @@
       }
       
       public void testUnmodifiableCollectionCopy() {
  -             Collection collection = new ArrayList();
  -             collection.add("a");
  -     Collection copy = 
CollectionUtils.unmodifiableCollectionCopy(collection);
  -
  -             assertTrue(copy instanceof Unmodifiable);
  -             assertTrue(CollectionUtils.isEqualCollection(collection, copy));
  -             collection.clear();
  -             assertTrue(copy.isEmpty() == false);
  +        Collection collection = new ArrayList();
  +        collection.add("a");
  +        Collection copy = 
CollectionUtils.unmodifiableCollectionCopy(collection);
  +
  +        assertTrue(copy instanceof Unmodifiable);
  +        assertTrue(CollectionUtils.isEqualCollection(collection, copy));
  +        collection.clear();
  +        assertTrue(copy.isEmpty() == false);
   
  -             try
  -             {
  +        try {
                        copy.clear();
                        fail("should be unmodifiable.");
  -             }
  -             catch (UnsupportedOperationException uoe)
  -             {} // this is what we want
  -             
  -             try
  -             {
  +             } catch (UnsupportedOperationException uoe) {
  +             } // this is what we want
  +
  +             try {
                        copy = CollectionUtils.unmodifiableCollectionCopy(null);
                        fail("should throw IllegalArgumentException");
  +             } catch (IllegalArgumentException iae) {
                }
  -             catch(IllegalArgumentException iae)
  -             {}
  -     }
  +    }
       
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to