Backport COLLECTIONS-219 to 3.2.2
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_X@1713167 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6e5ae530b3
commit
e709ea82aa
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
|
|
@ -1239,7 +1239,73 @@ public class TestCollectionUtils extends TestCase {
|
|||
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);
|
||||
|
|
Loading…
Reference in New Issue