[Arakhnę-Dev] [207] * Fixing code according to unit tests.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 207
Author:   galland
Date:     2011-02-28 09:20:55 +0100 (Mon, 28 Feb 2011)
Log Message:
-----------
* Fixing code according to unit tests.

Modified Paths:
--------------
    trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java

Modified: trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java
===================================================================
--- trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java	2011-02-15 21:24:18 UTC (rev 206)
+++ trunk/arakhneRefs/src/test/java/org/arakhne/util/ref/WeakArrayListTest.java	2011-02-28 08:20:55 UTC (rev 207)
@@ -19,11 +19,6 @@
  */
 package org.arakhne.util.ref;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Random;
-
 import org.arakhne.junit.AbstractTestCase;
 
 /**
@@ -32,47 +27,58 @@
 */
 public class WeakArrayListTest extends AbstractTestCase {
 
-	private static final int REFERENCE_SIZE = 0; 
+	private String d1;
+	private String d2;
+	private String d3;
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void setUp() throws Exception {
+		super.setUp();
+		this.d1 = Integer.toString(0)+randomString(10);
+		this.d2 = Integer.toString(1)+randomString(10);
+		this.d3 = Integer.toString(2)+randomString(10);
+	}
 	
-	private static void collect(WeakArrayList<String> list) {
-		for(int i=0; i<3; i++) {
-			System.gc();
-		}
-		list.expurge();
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void tearDown() throws Exception {
+		this.d1 = this.d2 = this.d3;
+		super.tearDown();
 	}
+
+	private void clearReferences() {
+		this.d1 = this.d2 = this.d3 = null;
+	}
 	
-	private List<String> spawnReference() {
-		Random rnd = new Random();
-		int count = rnd.nextInt(REFERENCE_SIZE+1)+5;
-		List<String> reference = new ArrayList<String>(count);
-		for(int i=0; i<count; i++) {
-			reference.add(Integer.toString(i)+randomString(10));
+	private WeakArrayList<String> createWeakList() {
+        WeakArrayList<String> test = new WeakArrayList<String>();
+        test.add(this.d1);
+        test.add(this.d2);
+        test.add(this.d3);
+        return test;
+	}
+	
+	private static void collect(WeakArrayList<String> list) {
+		for(int j=0; j<5; j++) {
+			for(int i=0; i<3; i++) {
+				System.gc();
+			}
+			list.expurge();
 		}
-		Collections.sort(reference);
-		return reference;
 	}
-		
+	
 	/**
 	 */
-	public void testWeakArrayListCollection() {
-		List<String> reference = spawnReference();
-        WeakArrayList<String> test = new WeakArrayList<String>(reference);
-        assertEquals(reference, test);
-    }
-
-	/**
-	 */
     public void testSize() {
-		List<String> reference = spawnReference();
-
-		WeakArrayList<String> test = new WeakArrayList<String>();
-        assertEquals(0, test.size());
+        WeakArrayList<String> test = createWeakList();
+        assertEquals(3, test.size());
         
-        test = new WeakArrayList<String>(reference);
-        assertEquals(reference.size(), test.size());
-        
-        reference.clear();
-        reference = null;
+        clearReferences();
 		collect(test);
 		
         assertEquals(0, test.size());		
@@ -81,851 +87,13 @@
 	/**
 	 */
     public void testIsEmpty() {
-		List<String> reference = spawnReference();
-
-		WeakArrayList<String> test = new WeakArrayList<String>();
-        assertEquals(0, test.size());
+        WeakArrayList<String> test = createWeakList();
+        assertEquals(3, test.size());
         
-        test = new WeakArrayList<String>(reference);
-        assertFalse(test.isEmpty());
-        
-        reference.clear();
-        reference = null;
+        clearReferences();
 		collect(test);
 		
         assertTrue(test.isEmpty());		
     }
-
-//    public void testContains() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//
-//        // Test the content
-//		for(String elt : this.reference) {
-//			assertTrue(test.contains(elt));
-//		}
-//        assertEquals(this.reference, test);
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		int originalSize = this.reference.size();
-//		Random rnd = new Random();
-//		int count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			int index = rnd.nextInt(this.reference.size());
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		assertEquals(originalSize, test.size());
-//        assertNotEquals(this.reference, test);
-//		for(String elt : this.reference) {
-//			assertTrue(test.contains(elt));
-//		}
-//
-//        // Test the removed elements
-//		for(String elt : removedElements) {
-//			assertTrue(test.contains(elt));
-//		}
-//		
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		assertEquals(this.reference.size(), test.size());
-//        assertEquals(this.reference, test);
-//		for(String elt : this.reference) {
-//			assertTrue(test.contains(elt));
-//		}
-//    }
-//
-//    public void testEquals() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//
-//        assertTrue(test.equals(this.reference));
-//        assertTrue(this.reference.equals(test));
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		int originalSize = this.reference.size();
-//		Random rnd = new Random();
-//		int count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			int index = rnd.nextInt(this.reference.size());
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		assertEquals(originalSize, test.size());
-//        assertNotEquals(this.reference, test);
-//        assertFalse(test.equals(this.reference));
-//        assertFalse(this.reference.equals(test));
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		assertEquals(this.reference.size(), test.size());
-//        assertEquals(this.reference, test);
-//        assertTrue(test.equals(this.reference));
-//        assertTrue(this.reference.equals(test));
-//    }
-//
-//    public void testIterator() {
-//    	WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//    	assertEquals(this.reference, test);
-//	
-//        // Test the content
-//    	String s;
-//    	int idx=0;
-//    	Iterator<String> iter = test.iterator();
-//    	while (iter.hasNext()) {
-//    		s = iter.next();
-//    		assertEquals(this.reference.get(idx), s);
-//    		idx++;
-//    	}
-//
-//        // Remove elements
-//		ArrayList<String> baseElements = new ArrayList<String>(this.reference);
-//		Random rnd = new Random();
-//		int count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			int index = rnd.nextInt(this.reference.size());
-//			this.reference.remove(index);			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	idx=0;
-//    	iter = test.iterator();
-//    	while (iter.hasNext()) {
-//    		s = iter.next();
-//    		assertEquals(baseElements.get(idx), s);
-//    		idx++;
-//    	}
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		baseElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	idx=0;
-//    	iter = test.iterator();
-//    	while (iter.hasNext()) {
-//    		s = iter.next();
-//    		assertEquals(this.reference.get(idx), s);
-//    		idx++;
-//    	}
-//    }
-//
-//	public void testContainsAll() {
-//    	WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//    	assertEquals(this.reference, test);
-//	
-//        // Test the content
-//    	assertTrue(this.reference.containsAll(test));
-//    	assertTrue(test.containsAll(this.reference));
-//
-//        // Remove elements
-//		ArrayList<String> baseElements = new ArrayList<String>(this.reference);
-//		Random rnd = new Random();
-//		int count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			int index = rnd.nextInt(this.reference.size());
-//			this.reference.remove(index);			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	assertFalse(this.reference.containsAll(test));
-//    	assertTrue(test.containsAll(this.reference));
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		baseElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	assertTrue(this.reference.containsAll(test));
-//    	assertTrue(test.containsAll(this.reference));
-//	}
-//    
-//	public void testToArray() {
-//    	WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//    	assertEquals(this.reference, test);
-//	
-//        // Test the content
-//    	assertEquals(this.reference.toArray(),test.toArray());
-//
-//        // Remove elements
-//		ArrayList<String> baseElements = new ArrayList<String>(this.reference);
-//		Random rnd = new Random();
-//		int count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			int index = rnd.nextInt(this.reference.size());
-//			this.reference.remove(index);			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	assertNotEquals(this.reference.toArray(),test.toArray());
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		baseElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	assertEquals(this.reference.toArray(),test.toArray());
-//	}
-//	public void testToArrayArray() {
-//    	WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//    	assertEquals(this.reference, test);
-//    	
-//    	String[] tab1, tab2;
-//	
-//        // Test the content
-//    	tab1 = new String[this.reference.size()];
-//    	this.reference.toArray(tab1);
-//    	tab2 = new String[test.size()];
-//    	test.toArray(tab2);
-//    	assertEquals(tab1,tab2);
-//    	Arrays.fill(tab1, null);
-//    	Arrays.fill(tab2, null);
-//
-//        // Remove elements
-//		ArrayList<String> baseElements = new ArrayList<String>(this.reference);
-//		Collections.sort(baseElements);
-//		Random rnd = new Random();
-//		int count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			int index = rnd.nextInt(this.reference.size());
-//			this.reference.remove(index);			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	tab1 = new String[this.reference.size()];
-//    	this.reference.toArray(tab1);
-//    	tab2 = new String[test.size()];
-//    	test.toArray(tab2);
-//    	assertNotEquals(tab1,tab2);
-//    	Arrays.fill(tab1, null);
-//    	Arrays.fill(tab2, null);
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		baseElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//    	tab1 = new String[this.reference.size()];
-//    	this.reference.toArray(tab1);
-//    	tab2 = new String[test.size()];
-//    	test.toArray(tab2);
-//    	assertEquals(tab1,tab2);
-//    	Arrays.fill(tab1, null);
-//    	Arrays.fill(tab2, null);
-//	}
-//
-//	public void testClear() {
-//    	WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//    	
-//        // Remove elements
-//    	test.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//    	assertTrue(test.isEmpty());
-//	}
-//
-//	public void testIndexOf() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//
-//        // Test the content
-//		Random rnd = new Random();
-//		int index;
-//		int count = rnd.nextInt(this.reference.size())+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			assertEquals(index, test.indexOf(this.reference.get(index)));
-//		}
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		count = rnd.nextInt(this.reference.size()/4)+1;
-//		int minIndex = Integer.MAX_VALUE;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			if (index<minIndex) minIndex = index;
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		count = rnd.nextInt(this.reference.size())+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			if (index<minIndex)
-//				assertEquals(index, test.indexOf(this.reference.get(index)));
-//			else
-//				assertFalse(index==test.indexOf(this.reference.get(index)));
-//		}
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		count = rnd.nextInt(this.reference.size());
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			assertEquals(index, test.indexOf(this.reference.get(index)));
-//		}
-//	}
-//	
-//	public void testLastIndexOf() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//
-//        // Test the content
-//		Random rnd = new Random();
-//		int index;
-//		int count = rnd.nextInt(this.reference.size())+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			assertEquals(index, test.lastIndexOf(this.reference.get(index)));
-//		}
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		count = rnd.nextInt(this.reference.size()/4)+1;
-//		int minIndex = Integer.MAX_VALUE;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			if (index<minIndex) minIndex = index;
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		count = rnd.nextInt(this.reference.size())+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			if (index<minIndex)
-//				assertEquals(index, test.lastIndexOf(this.reference.get(index)));
-//			else
-//				assertFalse(index==test.lastIndexOf(this.reference.get(index)));
-//		}
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		count = rnd.nextInt(this.reference.size());
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			assertEquals(index, test.lastIndexOf(this.reference.get(index)));
-//		}
-//	}
-//
-//	public void testGetInt() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//
-//        // Test the content
-//		Random rnd = new Random();
-//		int index;
-//		int count = rnd.nextInt(this.reference.size())+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			assertEquals(this.reference.get(index), test.get(index));
-//		}
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		count = rnd.nextInt(this.reference.size()/4)+1;
-//		int minIndex = Integer.MAX_VALUE;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			if (index<minIndex) minIndex = index;
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		count = rnd.nextInt(this.reference.size())+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			if (index<minIndex)
-//				assertEquals(this.reference.get(index), test.get(index));
-//			else
-//				assertFalse(this.reference.get(index)==test.get(index));
-//		}
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//        // Test the content
-//		count = rnd.nextInt(this.reference.size());
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			assertEquals(this.reference.get(index), test.get(index));
-//		}
-//		
-//		assertException(test, "get", new Class<?>[] {int.class}, new Object[] {test.size()}); //$NON-NLS-1$
-//	}
-//	
-//	public void testAddE() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//        
-//        // Add an element
-//        String newElement = randomString();
-//        this.reference.add(newElement);
-//        test.add(newElement);
-//        assertEquals(this.reference, test);
-//        newElement = null;
-//
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		Random rnd = new Random();
-//		int index, count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//		// Test content
-//        assertNotEquals(this.reference, test);
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//		// Test content
-//        assertEquals(this.reference, test);
-//        
-//        // Add a string without reference
-//        newElement = randomString();
-//        test.add(newElement);
-//        newElement = null;
-//        
-//		// Collects the objects
-//		collect(test);
-//		
-//		// Test content
-//        assertEquals(this.reference, test);        
-//	}
-//
-//	public void testAddIntE() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//        
-//        Random rnd = new Random();
-//        int index, testCount, count;
-//        String newElement, msg;
-//        
-//        testCount = rnd.nextInt(20)+5;
-//        
-//        for(int i=0; i<testCount; i++) {
-//        	msg = "test "+(i+1)+"/"+testCount; //$NON-NLS-1$ //$NON-NLS-2$
-//        	
-//	        // Add an element
-//	        newElement = randomString(10);
-//	        index = rnd.nextInt(this.reference.size());
-//	        this.reference.add(index, newElement);
-//	        test.add(index, newElement);
-//	        newElement = null;
-//
-//	        // Test elements
-//	        assertEquals(msg,this.reference, test);	
-//	
-//	        // Remove elements
-//			ArrayList<String> removedElements = new ArrayList<String>();
-//			count = rnd.nextInt(this.reference.size()/4)+1;
-//			for(int j=0; j<count; j++) {
-//				index = rnd.nextInt(this.reference.size());
-//				removedElements.add(this.reference.remove(index));			
-//			}
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertNotEquals(msg,this.reference, test);
-//	
-//			// Clear the list of removed elements, which will cause collecting
-//			removedElements.clear();
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//	        
-//	        // Add a string without reference
-//	        newElement = randomString(10);
-//	        index = rnd.nextInt(test.size());
-//	        test.add(index, newElement);
-//	        newElement = null;
-//	        
-//			// Collects the objects
-//			collect(test);
-//			
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//	        
-//        }
-//	}
-//
-//	public void testAddAllCollection() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//        
-//        // Add a set of elements
-//        ArrayList<String> newElements = new ArrayList<String>();
-//		Random rnd = new Random();
-//        int count =  rnd.nextInt(20)+5;
-//        for(int i=0; i<count; i++)
-//        	newElements.add(randomString(10));
-//        this.reference.addAll(newElements);
-//        test.addAll(newElements);
-//        assertEquals(this.reference, test);
-//        newElements.clear();
-//        newElements = null;
-//
-//        // Remove elements
-//		ArrayList<String> removedElements = new ArrayList<String>();
-//		int index;
-//		count = rnd.nextInt(this.reference.size()/4)+1;
-//		for(int i=0; i<count; i++) {
-//			index = rnd.nextInt(this.reference.size());
-//			removedElements.add(this.reference.remove(index));			
-//		}
-//
-//		// Collects the objects
-//		collect(test);
-//
-//		// Test content
-//        assertNotEquals(this.reference, test);
-//
-//		// Clear the list of removed elements, which will cause collecting
-//		removedElements.clear();
-//
-//		// Collects the objects
-//		collect(test);
-//
-//		// Test content
-//        assertEquals(this.reference, test);
-//        
-//        // Add a string without reference
-//        count =  rnd.nextInt(20)+5;
-//        for(int i=0; i<count; i++)
-//        	test.add(randomString(10));
-//        
-//		// Collects the objects
-//		collect(test);
-//		
-//		// Test content
-//        assertEquals(this.reference, test);        
-//	}
-//
-//	public void testAddAllIntCollection() {
-//        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//        assertEquals(this.reference, test);
-//
-//        String msg;
-//		Random rnd = new Random();
-//        int testCount = rnd.nextInt(20)+5;
-//        int index, count, insertionIndex;
-//        ArrayList<String> newElements;
-//        
-//        for(int i=0; i<testCount; i++) {
-//        	msg = "test "+(i+1)+"/"+testCount; //$NON-NLS-1$ //$NON-NLS-2$
-//	        insertionIndex = rnd.nextInt(this.reference.size());
-//
-//	        // Add a set of elements
-//	        newElements = new ArrayList<String>();
-//	        count =  rnd.nextInt(20)+5;
-//	        for(int j=0; j<count; j++) {
-//	        	newElements.add(randomString(10));
-//	        }
-//	        this.reference.addAll(insertionIndex,newElements);
-//	        test.addAll(insertionIndex,newElements);
-//	        newElements.clear();
-//	        newElements = null;
-//	        assertEquals(msg,this.reference, test);
-//	
-//	        // Remove elements
-//			ArrayList<String> removedElements = new ArrayList<String>();
-//			count = rnd.nextInt(this.reference.size()/4)+1;
-//			for(int j=0; j<count; j++) {
-//				index = rnd.nextInt(this.reference.size());
-//				removedElements.add(this.reference.remove(index));			
-//			}
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertNotEquals(msg,this.reference, test);
-//	
-//			// Clear the list of removed elements, which will cause collecting
-//			removedElements.clear();
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//	        
-//	        // Add a string without reference
-//	        count =  rnd.nextInt(20)+5;
-//	        for(int j=0; j<count; j++)
-//	        	test.add(randomString(10));
-//	        
-//			// Collects the objects
-//			collect(test);
-//			
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//        }
-//	}
-//
-//	public void testSetIntE() {
-//        String msg;
-//		Random rnd = new Random();
-//        int testCount = rnd.nextInt(20)+5;
-//        int index, count, insertionIndex;
-//        
-//        for(int i=0; i<testCount; i++) {
-//        	msg = "test "+(i+1)+"/"+testCount; //$NON-NLS-1$ //$NON-NLS-2$
-//        	spawnReference();
-//        	insertionIndex = rnd.nextInt(this.reference.size());
-//
-//	        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//	        assertEquals(this.reference, test);
-//        	
-//	        // Add an element
-//	        String newElement = randomString();
-//	        this.reference.set(insertionIndex,newElement);
-//	        test.set(insertionIndex,newElement);
-//	        newElement = null;
-//	        assertEquals(msg,this.reference, test);
-//	
-//	
-//	        // Remove elements
-//			ArrayList<String> removedElements = new ArrayList<String>();
-//			rnd = new Random();
-//			count = rnd.nextInt(this.reference.size()/4+1)+1;
-//			for(int j=0; j<count; j++) {
-//				index = rnd.nextInt(this.reference.size());
-//				removedElements.add(this.reference.remove(index));			
-//			}
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertNotEquals(msg,this.reference, test);
-//	
-//			// Clear the list of removed elements, which will cause collecting
-//			removedElements.clear();
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//	        
-//	        // Add a string without reference
-//	        if (!test.isEmpty()) {
-//		        newElement = randomString();
-//		        insertionIndex = rnd.nextInt(test.size());
-//		        test.set(insertionIndex,newElement);
-//		        newElement = null;
-//	        }
-//	        
-//			// Collects the objects
-//			collect(test);
-//			
-//			// Test content
-//	        assertNotEquals(msg,this.reference, test);
-//        }
-//	}
-//
-//	public void testRemoveObject() {
-//        String msg;
-//		Random rnd = new Random();
-//        int testCount = rnd.nextInt(20)+5;
-//        int removalIndex;
-//        
-//        for(int i=0; i<testCount; i++) {
-//        	msg = "test "+(i+1)+"/"+testCount; //$NON-NLS-1$ //$NON-NLS-2$
-//        	spawnReference();
-//        	removalIndex = rnd.nextInt(this.reference.size());
-//
-//	        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//	        assertEquals(this.reference, test);
-//        	
-//	        // Remove elements
-//	        test.remove(this.reference.get(removalIndex));
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertNotEquals(msg,this.reference, test);
-//	
-//			// Clear the list of removed elements, which will cause collecting
-//			this.reference.remove(removalIndex);
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//        }
-//	}
-//
-//	public void testRemoveInt() {
-//        String msg;
-//		Random rnd = new Random();
-//        int testCount = rnd.nextInt(20)+5;
-//        int removalIndex;
-//        
-//        for(int i=0; i<testCount; i++) {
-//        	msg = "test "+(i+1)+"/"+testCount; //$NON-NLS-1$ //$NON-NLS-2$
-//        	spawnReference();
-//        	removalIndex = rnd.nextInt(this.reference.size());
-//
-//	        WeakArrayList<String> test = new WeakArrayList<String>(this.reference);
-//	        assertEquals(this.reference, test);
-//        	
-//	        // Remove elements
-//	        test.remove(removalIndex);
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertNotEquals(msg,this.reference, test);
-//	
-//			// Clear the list of removed elements, which will cause collecting
-//			this.reference.remove(removalIndex);
-//	
-//			// Collects the objects
-//			collect(test);
-//	
-//			// Test content
-//	        assertEquals(msg,this.reference, test);
-//        }
-//	}
-//
-	/**
-	 */
-	public void testHashCode() {
-		List<String> reference = spawnReference();
-        WeakArrayList<String> test = new WeakArrayList<String>(reference);
-        assertEquals(reference, test);
-
-        assertEquals(reference.hashCode(),test.hashCode());
-
-        // Remove elements
-		reference.clear();
-
-		// Collects the objects
-		collect(test);
-
-        // Test the content
-        assertNotEquals(hashCode(), test.hashCode());
-    }
-	
-	/**
-	 */
-	public void testListener() {
-		Listener listener = new Listener();
-		WeakArrayList<String> list = new WeakArrayList<String>();
-		list.addReferenceListener(listener);
-		
-		Random rnd = new Random();
-		int count = rnd.nextInt(REFERENCE_SIZE+1)+5;
-		for(int i=0; i<count; i++) {
-			list.add(randomString());
-		}
-		
-		assertFalse(list.isEmpty());
-
-		collect(list);
-		
-		assertTrue(list.isEmpty());
-		assertEquals(count, listener.count);
-		
-	}
-	
-	private class Listener implements ReferenceListener {
-		
-		public int count = 0;
-		
-		public Listener() {
-			//
-		}
-
-		@Override
-		public void referenceReleased(int released) {
-			this.count += released;
-		}
-		
-	}
     
 }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/