diff --git a/project.xml b/project.xml index 87c64c5a9..f55199cf7 100644 --- a/project.xml +++ b/project.xml @@ -218,6 +218,9 @@ Olaf Krische + + Guilhem Lavaux + David Leppik diff --git a/src/test/org/apache/commons/collections/TestReferenceMap.java b/src/test/org/apache/commons/collections/TestReferenceMap.java index c4f9572b6..5b0c0ef76 100644 --- a/src/test/org/apache/commons/collections/TestReferenceMap.java +++ b/src/test/org/apache/commons/collections/TestReferenceMap.java @@ -28,6 +28,7 @@ import org.apache.commons.collections.map.AbstractTestMap; * @version $Revision$ $Date$ * * @author Paul Jack + * @author Guilhem Lavaux */ public class TestReferenceMap extends AbstractTestMap { @@ -152,25 +153,30 @@ public class TestReferenceMap extends AbstractTestMap { } */ - /** Tests whether purge values setting works */ - public void testPurgeValues() throws Exception { - // many thanks to Juozas Baliuka for suggesting this method + WeakReference keyReference; + WeakReference valueReference; + + public Map buildRefMap() { Object key = new Object(); Object value = new Object(); - WeakReference keyReference = new WeakReference(key); - WeakReference valueReference = new WeakReference(value); + keyReference = new WeakReference(key); + valueReference = new WeakReference(value); Map testMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true); testMap.put(key, value); - + assertEquals("In map", value, testMap.get(key)); assertNotNull("Weak reference released early (1)", keyReference.get()); assertNotNull("Weak reference released early (2)", valueReference.get()); - - // dereference strong references - key = null; - value = null; + return testMap; + } + + /** Tests whether purge values setting works */ + public void testPurgeValues() throws Exception { + // many thanks to Juozas Baliuka for suggesting this method + + Map testMap = buildRefMap(); int iterations = 0; int bytz = 2; diff --git a/src/test/org/apache/commons/collections/map/TestReferenceIdentityMap.java b/src/test/org/apache/commons/collections/map/TestReferenceIdentityMap.java index f3e4e7994..96616701f 100644 --- a/src/test/org/apache/commons/collections/map/TestReferenceIdentityMap.java +++ b/src/test/org/apache/commons/collections/map/TestReferenceIdentityMap.java @@ -31,6 +31,7 @@ import org.apache.commons.collections.IterableMap; * * @author Paul Jack * @author Stephen Colebourne + * @author Guilhem Lavaux */ public class TestReferenceIdentityMap extends AbstractTestIterableMap { @@ -261,25 +262,29 @@ public class TestReferenceIdentityMap extends AbstractTestIterableMap { } */ - /** Tests whether purge values setting works */ - public void testPurgeValues() throws Exception { - // many thanks to Juozas Baliuka for suggesting this method + WeakReference keyReference; + WeakReference valueReference; + + public Map buildRefMap() { Object key = new Object(); Object value = new Object(); - WeakReference keyReference = new WeakReference(key); - WeakReference valueReference = new WeakReference(value); + keyReference = new WeakReference(key); + valueReference = new WeakReference(value); - Map testMap = new ReferenceIdentityMap(ReferenceIdentityMap.WEAK, ReferenceIdentityMap.HARD, true); + Map testMap = new ReferenceIdentityMap(ReferenceMap.WEAK, ReferenceMap.HARD, true); testMap.put(key, value); - + assertEquals("In map", value, testMap.get(key)); assertNotNull("Weak reference released early (1)", keyReference.get()); assertNotNull("Weak reference released early (2)", valueReference.get()); - - // dereference strong references - key = null; - value = null; + return testMap; + } + + /** Tests whether purge values setting works */ + public void testPurgeValues() throws Exception { + // many thanks to Juozas Baliuka for suggesting this method + Map testMap = buildRefMap(); int iterations = 0; int bytz = 2; diff --git a/src/test/org/apache/commons/collections/map/TestReferenceMap.java b/src/test/org/apache/commons/collections/map/TestReferenceMap.java index 2876fdffe..e5d2bf34e 100644 --- a/src/test/org/apache/commons/collections/map/TestReferenceMap.java +++ b/src/test/org/apache/commons/collections/map/TestReferenceMap.java @@ -28,6 +28,7 @@ import org.apache.commons.collections.BulkTest; * @version $Revision$ $Date$ * * @author Paul Jack + * @author Guilhem Lavaux */ public class TestReferenceMap extends AbstractTestIterableMap { @@ -196,26 +197,30 @@ public class TestReferenceMap extends AbstractTestIterableMap { } */ - /** Tests whether purge values setting works */ - public void testPurgeValues() throws Exception { - // many thanks to Juozas Baliuka for suggesting this method + WeakReference keyReference; + WeakReference valueReference; + + public Map buildRefMap() { Object key = new Object(); Object value = new Object(); - WeakReference keyReference = new WeakReference(key); - WeakReference valueReference = new WeakReference(value); + keyReference = new WeakReference(key); + valueReference = new WeakReference(value); Map testMap = new ReferenceMap(ReferenceMap.WEAK, ReferenceMap.HARD, true); testMap.put(key, value); - + assertEquals("In map", value, testMap.get(key)); assertNotNull("Weak reference released early (1)", keyReference.get()); assertNotNull("Weak reference released early (2)", valueReference.get()); - - // dereference strong references - key = null; - value = null; - + return testMap; + } + + /** Tests whether purge values setting works */ + public void testPurgeValues() throws Exception { + // many thanks to Juozas Baliuka for suggesting this method + Map testMap = buildRefMap(); + int iterations = 0; int bytz = 2; while(true) {