commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1713167 - in /commons/proper/collections/branches/COLLECTIONS_3_2_X/src: changes/changes.xml java/org/apache/commons/collections/CollectionUtils.java test/org/apache/commons/collections/TestCollectionUtils.java
Date Sat, 07 Nov 2015 19:44:04 GMT
Author: tn
Date: Sat Nov  7 19:44:03 2015
New Revision: 1713167

URL: http://svn.apache.org/viewvc?rev=1713167&view=rev
Log:
Backport COLLECTIONS-219 to 3.2.2

Modified:
    commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml
    commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/CollectionUtils.java
    commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestCollectionUtils.java

Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml?rev=1713167&r1=1713166&r2=1713167&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml (original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/changes/changes.xml Sat Nov
 7 19:44:03 2015
@@ -22,6 +22,10 @@
   <body>
 
   <release version="3.2.2" date="20XX-XX-XX" description="This is a bugfix release.">
+
+    <action issue="COLLECTIONS-219" dev="scolebourne" type="fix" due-to="Tom Leccese">
+      "CollectionUtils#removeAll" wrongly called "ListUtils#retainAll".
+    </action>
   
   <!--  Bugfixes planned to backport from 4.0
   
@@ -94,9 +98,6 @@
       "MultiValueMap#put(Object, Object)" and "MultiValueMap#putAll(Object, Collection)"
       now correctly return if the map has changed by this operation.
     </action>
-    <action issue="COLLECTIONS-219" dev="scolebourne" type="fix" due-to="Tom Leccese">
-      "CollectionUtils#removeAll" wrongly called "ListUtils#retainAll".
-    </action>
     <action issue="COLLECTIONS-217" dev="scolebourne" type="fix" due-to="Matt Bishop">
       Calling "setValue(Object)" on any Entry returned by a "Flat3Map" will now
       correctly set the value for the current entry.

Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/CollectionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/CollectionUtils.java?rev=1713167&r1=1713166&r2=1713167&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/CollectionUtils.java
(original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/java/org/apache/commons/collections/CollectionUtils.java
Sat Nov  7 19:44:03 2015
@@ -1119,7 +1119,7 @@ public class CollectionUtils {
      * @since Commons Collections 3.2
      */
     public static Collection removeAll(Collection collection, Collection remove) {
-        return ListUtils.retainAll(collection, remove);
+        return ListUtils.removeAll(collection, remove);
     }
 
     //-----------------------------------------------------------------------

Modified: commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestCollectionUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestCollectionUtils.java?rev=1713167&r1=1713166&r2=1713167&view=diff
==============================================================================
--- commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestCollectionUtils.java
(original)
+++ commons/proper/collections/branches/COLLECTIONS_3_2_X/src/test/org/apache/commons/collections/TestCollectionUtils.java
Sat Nov  7 19:44:03 2015
@@ -1239,7 +1239,73 @@ public class TestCollectionUtils extends
         assertEquals(eltc,eltb);
     }
     
-     public void testTransformedCollection() {
+    // -----------------------------------------------------------------------
+
+    public void testRetainAll() {
+        final List base = new ArrayList();
+        base.add("A");
+        base.add("B");
+        base.add("C");
+        final List sub = new ArrayList();
+        sub.add("A");
+        sub.add("C");
+        sub.add("X");
+
+        final Collection result = CollectionUtils.retainAll(base, sub);
+        assertEquals(2, result.size());
+        assertEquals(true, result.contains("A"));
+        assertFalse(result.contains("B"));
+        assertEquals(true, result.contains("C"));
+        assertEquals(3, base.size());
+        assertEquals(true, base.contains("A"));
+        assertEquals(true, base.contains("B"));
+        assertEquals(true, base.contains("C"));
+        assertEquals(3, sub.size());
+        assertEquals(true, sub.contains("A"));
+        assertEquals(true, sub.contains("C"));
+        assertEquals(true, sub.contains("X"));
+
+        try {
+            CollectionUtils.retainAll(null, null);
+            fail("expecting NullPointerException");
+        } catch (final NullPointerException npe) {
+        } // this is what we want
+    }
+
+    public void testRemoveAll() {
+        final List base = new ArrayList();
+        base.add("A");
+        base.add("B");
+        base.add("C");
+        final List sub = new ArrayList();
+        sub.add("A");
+        sub.add("C");
+        sub.add("X");
+
+        final Collection result = CollectionUtils.removeAll(base, sub);
+        assertEquals(1, result.size());
+        assertFalse(result.contains("A"));
+        assertEquals(true, result.contains("B"));
+        assertFalse(result.contains("C"));
+        assertEquals(3, base.size());
+        assertEquals(true, base.contains("A"));
+        assertEquals(true, base.contains("B"));
+        assertEquals(true, base.contains("C"));
+        assertEquals(3, sub.size());
+        assertEquals(true, sub.contains("A"));
+        assertEquals(true, sub.contains("C"));
+        assertEquals(true, sub.contains("X"));
+
+        try {
+            CollectionUtils.removeAll(null, null);
+            fail("expecting NullPointerException");
+        } catch (final NullPointerException npe) {
+        } // this is what we want
+    }
+    
+    // -----------------------------------------------------------------------
+    
+    public void testTransformedCollection() {
         Transformer transformer = TransformerUtils.nopTransformer();
         Collection collection = 
             CollectionUtils.transformedCollection(new ArrayList(), transformer);



Mime
View raw message