You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@apache.org on 2006/07/19 00:03:01 UTC
svn commit: r423264 - in /jakarta/commons/proper/collections/trunk:
RELEASE-NOTES.html src/java/org/apache/commons/collections/map/Flat3Map.java
src/test/org/apache/commons/collections/map/TestFlat3Map.java
Author: scolebourne
Date: Tue Jul 18 15:03:00 2006
New Revision: 423264
URL: http://svn.apache.org/viewvc?rev=423264&view=rev
Log:
COLLECTIONS-217 - Flat3Map - Fix setValue in MapIterator and EntrySetIterator to work correctly
Modified:
jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html
jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/Flat3Map.java
jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFlat3Map.java
Modified: jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html?rev=423264&r1=423263&r2=423264&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html (original)
+++ jakarta/commons/proper/collections/trunk/RELEASE-NOTES.html Tue Jul 18 15:03:00 2006
@@ -54,7 +54,7 @@
<center><h3>BUG FIXES</h3></center>
<ul>
-<li>xxxxxxxxxxxxxx</li>
+<li>Flat3Map - Fix setValue in MapIterator and EntrySetIterator to work correctly [COLLECTIONS-217]</li>
</ul>
<center><h3>JAVADOC</h3></center>
Modified: jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/Flat3Map.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/Flat3Map.java?rev=423264&r1=423263&r2=423264&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/Flat3Map.java (original)
+++ jakarta/commons/proper/collections/trunk/src/java/org/apache/commons/collections/map/Flat3Map.java Tue Jul 18 15:03:00 2006
@@ -651,10 +651,13 @@
switch (nextIndex) {
case 3:
parent.value3 = value;
+ break;
case 2:
parent.value2 = value;
+ break;
case 1:
parent.value1 = value;
+ break;
}
return old;
}
@@ -803,10 +806,13 @@
switch (nextIndex) {
case 3:
parent.value3 = value;
+ break;
case 2:
parent.value2 = value;
+ break;
case 1:
parent.value1 = value;
+ break;
}
return old;
}
Modified: jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFlat3Map.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFlat3Map.java?rev=423264&r1=423263&r2=423264&view=diff
==============================================================================
--- jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFlat3Map.java (original)
+++ jakarta/commons/proper/collections/trunk/src/test/org/apache/commons/collections/map/TestFlat3Map.java Tue Jul 18 15:03:00 2006
@@ -19,6 +19,7 @@
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
+import java.util.Iterator;
import java.util.Map;
import junit.framework.Test;
@@ -39,8 +40,10 @@
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);
@@ -207,7 +210,123 @@
assertEquals(ONE, ser.get(TEN));
assertEquals(TWO, ser.get(TWENTY));
}
-
+
+ //-----------------------------------------------------------------------
+ public void testEntryIteratorSetValue1() throws Exception {
+ Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ Iterator it = map.entrySet().iterator();
+ 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 {
+ Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ Iterator it = map.entrySet().iterator();
+ it.next();
+ 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 {
+ Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ Iterator it = map.entrySet().iterator();
+ it.next();
+ it.next();
+ 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 testMapIteratorSetValue1() throws Exception {
+ Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ MapIterator it = map.mapIterator();
+ it.next();
+ it.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 testMapIteratorSetValue2() throws Exception {
+ Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ MapIterator it = map.mapIterator();
+ it.next();
+ it.next();
+ it.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 testMapIteratorSetValue3() throws Exception {
+ Flat3Map map = new Flat3Map();
+ map.put(ONE, TEN);
+ map.put(TWO, TWENTY);
+ map.put(THREE, THIRTY);
+
+ MapIterator it = map.mapIterator();
+ it.next();
+ it.next();
+ it.next();
+ it.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 BulkTest bulkTestMapIterator() {
return new TestFlatMapIterator();
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org