Backport COLLECTIONS-217 to 3.2.2
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/branches/COLLECTIONS_3_2_X@1713290 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c0da312f34
commit
46e5a83207
|
@ -53,6 +53,10 @@
|
|||
<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.
|
||||
</action>
|
||||
|
||||
<!-- Bugfixes planned to backport from 4.0
|
||||
|
||||
|
@ -85,10 +89,6 @@
|
|||
"Flat3Map#remove(Object)" will now return the correct value mapped to the removed key
|
||||
if the size of the map is less or equal 3.
|
||||
</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.
|
||||
</action>
|
||||
-->
|
||||
</release>
|
||||
</body>
|
||||
|
|
|
@ -804,10 +804,13 @@ public class Flat3Map implements IterableMap, Serializable, Cloneable {
|
|||
switch (nextIndex) {
|
||||
case 3:
|
||||
parent.value3 = value;
|
||||
break;
|
||||
case 2:
|
||||
parent.value2 = value;
|
||||
break;
|
||||
case 1:
|
||||
parent.value1 = value;
|
||||
break;
|
||||
}
|
||||
return old;
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import junit.framework.Test;
|
||||
|
@ -40,8 +41,10 @@ public class TestFlat3Map extends AbstractTestIterableMap {
|
|||
|
||||
private static final Integer ONE = new Integer(1);
|
||||
private static final Integer TWO = new Integer(2);
|
||||
private static final Integer THREE = new Integer(3);
|
||||
private static final String TEN = "10";
|
||||
private static final String TWENTY = "20";
|
||||
private static final String THIRTY = "30";
|
||||
|
||||
public TestFlat3Map(String testName) {
|
||||
super(testName);
|
||||
|
@ -59,6 +62,64 @@ public class TestFlat3Map extends AbstractTestIterableMap {
|
|||
return new Flat3Map();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public void testEntryIteratorSetValue1() throws Exception {
|
||||
final Flat3Map map = new Flat3Map();
|
||||
map.put(ONE, TEN);
|
||||
map.put(TWO, TWENTY);
|
||||
map.put(THREE, THIRTY);
|
||||
|
||||
final Iterator it = map.entrySet().iterator();
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
entry.setValue("NewValue");
|
||||
assertEquals(3, map.size());
|
||||
assertEquals(true, map.containsKey(ONE));
|
||||
assertEquals(true, map.containsKey(TWO));
|
||||
assertEquals(true, map.containsKey(THREE));
|
||||
assertEquals("NewValue", map.get(ONE));
|
||||
assertEquals(TWENTY, map.get(TWO));
|
||||
assertEquals(THIRTY, map.get(THREE));
|
||||
}
|
||||
|
||||
public void testEntryIteratorSetValue2() throws Exception {
|
||||
final Flat3Map map = new Flat3Map();
|
||||
map.put(ONE, TEN);
|
||||
map.put(TWO, TWENTY);
|
||||
map.put(THREE, THIRTY);
|
||||
|
||||
final Iterator it = map.entrySet().iterator();
|
||||
it.next();
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
entry.setValue("NewValue");
|
||||
assertEquals(3, map.size());
|
||||
assertEquals(true, map.containsKey(ONE));
|
||||
assertEquals(true, map.containsKey(TWO));
|
||||
assertEquals(true, map.containsKey(THREE));
|
||||
assertEquals(TEN, map.get(ONE));
|
||||
assertEquals("NewValue", map.get(TWO));
|
||||
assertEquals(THIRTY, map.get(THREE));
|
||||
}
|
||||
|
||||
public void testEntryIteratorSetValue3() throws Exception {
|
||||
final Flat3Map map = new Flat3Map();
|
||||
map.put(ONE, TEN);
|
||||
map.put(TWO, TWENTY);
|
||||
map.put(THREE, THIRTY);
|
||||
|
||||
final Iterator it = map.entrySet().iterator();
|
||||
it.next();
|
||||
it.next();
|
||||
final Map.Entry entry = (Map.Entry) it.next();
|
||||
entry.setValue("NewValue");
|
||||
assertEquals(3, map.size());
|
||||
assertEquals(true, map.containsKey(ONE));
|
||||
assertEquals(true, map.containsKey(TWO));
|
||||
assertEquals(true, map.containsKey(THREE));
|
||||
assertEquals(TEN, map.get(ONE));
|
||||
assertEquals(TWENTY, map.get(TWO));
|
||||
assertEquals("NewValue", map.get(THREE));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
public void testEquals1() {
|
||||
Flat3Map map1 = new Flat3Map();
|
||||
|
|
Loading…
Reference in New Issue