You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by pe...@apache.org on 2015/09/10 08:59:30 UTC

svn commit: r1702174 [5/5] - in /river/jtsk/skunk/qa-refactor-namespace/trunk: ./ qa/src/org/apache/river/test/impl/outrigger/javaspace05/ src/manifest/ src/net/jini/core/entry/ src/net/jini/core/lookup/ src/net/jini/entry/ src/net/jini/loader/ src/net...

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceDequeTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceDequeTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceDequeTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceDequeTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,310 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.IOException;
+import java.util.LinkedList;
+import java.lang.ref.Reference;
+import java.util.Deque;
+import java.util.Iterator;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceDequeTest {
+    private Deque<String> instance;
+    public ReferenceDequeTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        instance = RC.deque(new LinkedList<Referrer<String>>(), Ref.WEAK, 10000L);
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of addFirst method, of class ReferenceDeque.
+     */
+    @Test
+    public void testAddFirst() {
+        System.out.println("addFirst");
+        String e = "addFirst";
+        instance.addFirst(e);
+        String result = instance.peekFirst();
+        assertEquals(e, result);
+    }
+
+    /**
+     * Test of addLast method, of class ReferenceDeque.
+     */
+    @Test
+    public void testAddLast() {
+        System.out.println("addLast");
+        String e = "addLast";
+        instance.addLast(e);
+        String result = instance.peekLast();
+        assertEquals(e, result);
+    }
+
+    /**
+     * Test of offerFirst method, of class ReferenceDeque.
+     */
+    @Test
+    public void testOfferFirst() {
+        System.out.println("offerFirst");
+        String e = "offerFirst";
+        boolean expResult = true;
+        boolean result = instance.offerFirst(e);
+        assertEquals(expResult, result);
+        String r = instance.pollFirst();
+        assertEquals(e, r);
+    }
+
+    /**
+     * Test of offerLast method, of class ReferenceDeque.
+     */
+    @Test
+    public void testOfferLast() {
+        System.out.println("offerLast");
+        String e = "offerLast";
+        boolean expResult = true;
+        boolean result = instance.offerLast(e);
+        assertEquals(expResult, result);
+        String r = instance.peekLast();
+        assertEquals(e, r);
+    }
+
+    /**
+     * Test of removeFirst method, of class ReferenceDeque.
+     */
+    @Test
+    public void testRemoveFirst() {
+        System.out.println("removeFirst");
+        String expResult = "removeFirst";
+        instance.offerFirst(expResult);
+        Object result = instance.removeFirst();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of removeLast method, of class ReferenceDeque.
+     */
+    @Test
+    public void testRemoveLast() {
+        System.out.println("removeLast");
+        String expResult = "removeLast";
+        instance.offerLast(expResult);
+        Object result = instance.removeLast();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of pollFirst method, of class ReferenceDeque.
+     */
+    @Test
+    public void testPollFirst() {
+        System.out.println("pollFirst");
+        String expResult = "pollFirst";
+        instance.offerFirst(expResult);
+        Object result = instance.pollFirst();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of pollLast method, of class ReferenceDeque.
+     */
+    @Test
+    public void testPollLast() {
+        System.out.println("pollLast");
+        String expResult = "pollLast";
+        instance.offerLast(expResult);
+        Object result = instance.pollLast();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of getFirst method, of class ReferenceDeque.
+     */
+    @Test
+    public void testGetFirst() {
+        System.out.println("getFirst");
+        String expResult = "getFirst";
+        instance.offerFirst(expResult);
+        Object result = instance.getFirst();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of getLast method, of class ReferenceDeque.
+     */
+    @Test
+    public void testGetLast() {
+        System.out.println("getLast");
+        String expResult = "getLast";
+        instance.offerLast(expResult);
+        Object result = instance.getLast();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of peekFirst method, of class ReferenceDeque.
+     */
+    @Test
+    public void testPeekFirst() {
+        System.out.println("peekFirst");
+        String expResult = "peekFirst";
+        instance.offerFirst(expResult);
+        Object result = instance.peekFirst();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of peekLast method, of class ReferenceDeque.
+     */
+    @Test
+    public void testPeekLast() {
+        System.out.println("peekLast");
+        String expResult = "peekLast";
+        instance.offerLast(expResult);
+        Object result = instance.peekLast();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of removeFirstOccurrence method, of class ReferenceDeque.
+     */
+    @Test
+    public void testRemoveFirstOccurrence() {
+        System.out.println("removeFirstOccurrence");
+        String o = "removeFirstOccurrence";
+        instance.offerLast(o);
+        boolean expResult = true;
+        boolean result = instance.removeFirstOccurrence(o);
+        assertEquals(expResult, result);
+        expResult = false;
+        result = instance.removeFirstOccurrence(o);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of removeLastOccurrence method, of class ReferenceDeque.
+     */
+    @Test
+    public void testRemoveLastOccurrence() {
+        System.out.println("removeLastOccurrence");
+        String o = "removeLastOccurrence";
+        instance.offerFirst(o);
+        boolean expResult = true;
+        boolean result = instance.removeLastOccurrence(o);
+        assertEquals(expResult, result);
+        expResult = false;
+        result = instance.removeLastOccurrence(o);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of push method, of class ReferenceDeque.
+     */
+    @Test
+    public void testPush() {
+        System.out.println("push");
+        String e = "push";
+        instance.push(e);
+        String result = instance.poll();
+        assertEquals(e, result);
+    }
+
+    /**
+     * Test of pop method, of class ReferenceDeque.
+     */
+    @Test
+    public void testPop() {
+        System.out.println("pop");
+        String expResult = "pop";
+        instance.push(expResult);
+        Object result = instance.pop();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of descendingIterator method, of class ReferenceDeque.
+     */
+    @Test
+    public void testDescendingIterator() {
+        System.out.println("descendingIterator");
+        String [] e = {"1", "2", "3", "4"};
+        for ( int i = 0; i < e.length; i++){
+            instance.offer(e[i]);
+        }
+        Iterator<String> it = instance.descendingIterator();
+        int i = 3;
+        while (it.hasNext()){
+            String r = it.next();
+            assertEquals(e[i], r);
+            if (i == 0) break;
+            i--;
+        }
+    }
+    
+      
+    /**
+     * Test serialization
+     */
+    @Test
+    @SuppressWarnings("unchecked")
+    public void serialization() {
+        System.out.println("Serialization Test");
+        Object result = null;
+        ObjectOutputStream out = null;
+        ObjectInputStream in = null;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            out = new ObjectOutputStream(baos);
+            out.writeObject(instance);
+            // Unmarshall it
+            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+            result = in.readObject();
+        } catch (IOException ex) {
+            ex.printStackTrace(System.out);
+        } catch (ClassNotFoundException ex){
+            ex.printStackTrace(System.out);
+        }
+        assertTrue(result instanceof Deque);
+        assertTrue(instance.containsAll((Deque<String>)result));
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceListTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceListTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceListTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceListTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,266 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.LinkedList;
+import java.lang.ref.Reference;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.ListIterator;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceListTest {
+    private List<String> instance;
+    private String truck = "truck";
+    private String shovel = "shovel";
+    private String grader = "grader";
+    private String waterTruck = "water truck";
+    private String roller = "roller";
+    
+    public ReferenceListTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        instance = RC.list(new ArrayList<Referrer<String>>(), Ref.WEAK, 10000L);
+        instance.add(truck);
+        instance.add(shovel);
+        instance.add(grader);
+        instance.add(waterTruck);
+        instance.add(roller);
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of equals method, of class ReferenceList.
+     */
+     @Test
+    public void testEquals() {
+        System.out.println("testEquals");
+        List<String> set1 = new ArrayList<String>(3);
+        List<String> set2 = RC.list(new ArrayList<Referrer<String>>(), Ref.SOFT, 10000L);
+        String s1 = "1", s2 = "2", s3 = "3";
+        set1.add(s1);
+        set1.add(s2);
+        set1.add(s3);
+        set2.add(s1);
+        set2.add(s2);
+        set2.add(s3);
+        assertTrue(set1.equals(set2));
+        assertTrue(set2.equals(set1));
+        assertTrue(set1.hashCode() == set2.hashCode());
+    }
+
+    /**
+     * Test of addAll method, of class ReferenceList.
+     */
+    @Test
+    public void testAddAll() {
+        System.out.println("addAll");
+        int index = 5;
+        String [] list = {"Bucyrus", "Marion", "Page"};
+        Collection<String> c = Arrays.asList(list);
+        boolean expResult = true;
+        boolean result = instance.addAll(index, c);
+        System.out.println(instance);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of get method, of class ReferenceList.
+     */
+    @Test
+    public void testGet() {
+        System.out.println("get");
+        int index = 2;
+        String expResult = grader;
+        Object result = instance.get(index);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of set method, of class ReferenceList.
+     */
+    @Test
+    public void testSet() {
+        System.out.println("set");
+        int index = 2;
+        String element = "dozer";
+        String expResult = grader;
+        String result = instance.set(index, element);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of add method, of class ReferenceList.
+     */
+    @Test
+    public void testAdd() {
+        System.out.println("add");
+        int index = 4;
+        String element = "drill";
+        instance.add(index, element);
+        String result = instance.get(index);
+        assertEquals(element , result);
+    }
+
+    /**
+     * Test of remove method, of class ReferenceList.
+     */
+    @Test
+    public void testRemove() {
+        System.out.println("remove");
+        int index = 3;
+        String expResult = waterTruck;
+        String result = instance.remove(index);
+        assertEquals(expResult, result);
+    }
+
+       /**
+     * Test of indexOf method, of class ReferenceList.
+     */
+    @Test
+    public void testGC() {
+        System.out.println("test Garbage collection");
+        String o = "drill";
+        int expResult = -1;
+        int result = instance.indexOf(o);
+        System.out.println(instance);
+        assertEquals(expResult, result);
+    }
+    
+    /**
+     * Test of indexOf method, of class ReferenceList.
+     */
+    @Test
+    public void testIndexOf() {
+        System.out.println("indexOf");
+        String o = "shovel";
+        int expResult = 1;
+        int result = instance.indexOf(o);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of lastIndexOf method, of class ReferenceList.
+     */
+    @Test
+    public void testLastIndexOf() {
+        System.out.println("lastIndexOf");
+        String o = roller;
+        int expResult = 4;
+        int result = instance.lastIndexOf(o);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of listIterator method, of class ReferenceList.
+     */
+    @Test
+    public void testListIterator_0args() {
+        System.out.println("listIterator");
+        List<String> expResult = new ArrayList<String>();
+        ListIterator<String> i = instance.listIterator();
+        while( i.hasNext()){
+            expResult.add(i.next());
+        }
+        assertTrue(expResult.containsAll(instance));
+    }
+
+    /**
+     * Test of listIterator method, of class ReferenceList.
+     */
+    @Test
+    public void testListIterator_int() {
+        System.out.println("listIterator");
+        int index = 3;
+        Collection<String> expResult = new ArrayList<String>(3);
+        expResult.add(waterTruck);
+        expResult.add(roller);
+        Collection<String> result = new ArrayList<String>();
+        ListIterator<String> i = instance.listIterator(index);
+        while (i.hasNext()){
+            result.add(i.next());
+        }
+        System.out.println(result);
+        assertTrue(expResult.containsAll(result));
+    }
+
+    /**
+     * Test of subList method, of class ReferenceList.
+     */
+    @Test
+    public void testSubList() {
+        System.out.println("subList");
+        int fromIndex = 0;
+        int toIndex = 1;
+        List<String> expResult = new ArrayList<String>();
+        expResult.add(truck);
+        List<String> result = instance.subList(fromIndex, toIndex);
+        assertTrue(result.containsAll(expResult));
+    }
+    
+     /**
+     * Test serialization
+     */
+    @Test
+    public void serialization() {
+        System.out.println("Serialization Test");
+        Object result = null;
+        ObjectOutputStream out = null;
+        ObjectInputStream in = null;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            out = new ObjectOutputStream(baos);
+            out.writeObject(instance);
+            // Unmarshall it
+            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+            result = in.readObject();
+        } catch (IOException ex) {
+            ex.printStackTrace(System.out);
+        } catch (ClassNotFoundException ex){
+            ex.printStackTrace(System.out);
+        }
+        assertEquals(instance, result);
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceMapTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceMapTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceMapTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceMapTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,402 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.TreeMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Peter Firmstone.
+ */
+public class ReferenceMapTest {
+    private Map<Integer, String> instance;
+    // strong references
+    private Integer i1, i2, i3, i4, i5;
+    private String s1, s2, s3, s4, s5;
+    
+    public ReferenceMapTest() {
+    }
+
+    @Before
+    public void setUp() {
+        Map<Referrer<Integer>, Referrer<String>> internal 
+                = new HashMap<Referrer<Integer>, Referrer<String>>(5);
+        instance = RC.map(internal, Ref.WEAK, Ref.STRONG, 10000L, 10000L);
+        i1 = 1;
+        i2 = 2;
+        i3 = 3;
+        i4 = 4;
+        i5 = 5;
+        s1 = "One";
+        s2 = "Two";
+        s3 = "Three";
+        s4 = "Four";
+        s5 = "Five";
+        instance.put(i1, s1);
+        instance.put(i2, s2);
+        instance.put(i3, s3);
+        instance.put(i4, s4);
+        instance.put(i5, s5);
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testEquals(){
+        Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new TreeMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        m2.put(i1, s1);
+        m2.put(i2, s2);
+        m2.put(i3, s3);
+        assertTrue(m1.equals(m2));
+        assertTrue(m2.equals(m1));
+        assertEquals( m1.hashCode(), m2.hashCode());
+    }
+    
+    @Test
+    public void testEntrySetEquals(){
+        Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new TreeMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        m2.put(i1, s1);
+        m2.put(i2, s2);
+        m2.put(i3, s3);
+        Set<Entry<Integer, String>> set1 = m1.entrySet();
+        Set<Entry<Integer, String>> set2 = m2.entrySet();
+        assertTrue(set1.equals(set2));
+        assertTrue(set2.equals(set1));
+        assertEquals(set1.hashCode(), set2.hashCode());
+    }
+    
+    @Test 
+    public void testEntrySetRemoveAll(){
+        Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new TreeMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        m2.put(i1, s1);
+        m2.put(i2, s2);
+        m2.put(i3, s3);
+        Set<Entry<Integer, String>> set1 = m1.entrySet();
+        Set<Entry<Integer, String>> set2 = m2.entrySet();
+        set2.removeAll(set1);
+        assertTrue(set2.isEmpty());
+    }
+    
+    @Test
+    public void testEntrySetRetainAll(){
+        Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new TreeMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        m2.put(i1, s1);
+        m2.put(i2, s2);
+        m2.put(i3, s3);
+        Set<Entry<Integer, String>> set1 = m1.entrySet();
+        Set<Entry<Integer, String>> set2 = m2.entrySet();
+        set2.retainAll(set1);
+        assertFalse(set2.isEmpty());
+    }
+    
+    @Test
+    public void testEntryContainsAll(){
+        Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new TreeMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        m2.put(i1, s1);
+        m2.put(i2, s2);
+        m2.put(i3, s3);
+        Map<Integer, String> m3 = new HashMap<Integer, String>();
+        m3.put(i1, s1);
+        m3.put(10, "Ten");
+        Set<Entry<Integer, String>> set1 = m1.entrySet();
+        Set<Entry<Integer, String>> set2 = m2.entrySet();
+        Set<Entry<Integer, String>> set3 = m3.entrySet();
+        assertTrue(set2.containsAll(set1));
+        assertFalse(set2.containsAll(set3));
+    }
+
+   @Test
+    public void testEntrySetRemoveContains(){
+        Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new TreeMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        m2.put(i1, s1);
+        m2.put(i2, s2);
+        m2.put(i3, s3);
+        Set<Entry<Integer, String>> set1 = m1.entrySet();
+        Set<Entry<Integer, String>> set2 = m2.entrySet();
+        assertTrue(set2.containsAll(set1));
+        Iterator<Entry<Integer, String>> it1 = set1.iterator();
+        while (it1.hasNext()){
+            Entry<Integer, String> e = it1.next();
+            set2.remove(e);
+            assertFalse(set2.contains(e));
+        }
+        assertTrue(set2.isEmpty());
+    }
+    
+   @Test
+   public void testEntrySetAdd(){
+       Map<Integer, String> m1 = new HashMap<Integer, String>();
+        m1.put(i1, s1);
+        m1.put(i2, s2);
+        m1.put(i3, s3);
+        Map<Integer, String> m2 = RC.map(
+            new MutableMap<Referrer<Integer>, Referrer<String>>(),
+            Ref.SOFT, Ref.SOFT, 10000L, 10000L
+        );
+        Set<Entry<Integer, String>> set1 = m1.entrySet();
+        Set<Entry<Integer, String>> set2 = m2.entrySet();
+        assertTrue(set2.isEmpty());
+        Iterator<Entry<Integer, String>> it1 = set1.iterator();
+        while (it1.hasNext()){
+            Entry<Integer, String> e = it1.next();
+            set2.add(e);
+        }
+        assertTrue(set2.containsAll(set1));
+   }
+   
+    /**
+     * Test of containsKey method, of class ReferenceMap.
+     */
+    @Test
+    public void testContainsKey() {
+        System.out.println("containsKey");
+        instance.put(i1, s1);
+        Integer key = i1;
+        boolean expResult = true;
+        boolean result = instance.containsKey(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of containsValue method, of class ReferenceMap.
+     */
+    @Test
+    public void testContainsValue() {
+        System.out.println("containsValue");
+        Object value = "One";
+        boolean expResult = true;
+        boolean result = instance.containsValue(value);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of entrySet method, of class ReferenceMap.
+     * Tests the entry set iterator and the keySet and values methods too.
+     */
+    @Test
+    public void testEntrySet() {
+        System.out.println("entrySet");
+        List<Integer> keys = new ArrayList<Integer>(5);
+        List<String> values = new ArrayList<String>(5);
+        Set<Entry<Integer, String>> result = instance.entrySet();
+        Iterator<Entry<Integer, String>> i = result.iterator();
+        while (i.hasNext()){
+            Entry<Integer, String> e = i.next();
+            keys.add(e.getKey());
+            values.add(e.getValue());
+        }
+        Collection<Integer> k = instance.keySet();
+        Collection<String> v = instance.values();
+        System.out.println(k);
+        System.out.println(v);
+        assertTrue(k.containsAll(keys));
+        assertTrue(v.containsAll(values));
+    }
+    
+    @Test
+    public void testEntrySetMutation(){
+        instance.put(i1, s1);
+        instance.put(i2, s2);
+        instance.put(i3, s3);
+        instance.put(i4, s4);
+        instance.put(i5, s5);
+        Set<Entry<Integer, String>> result = instance.entrySet();
+        Iterator<Entry<Integer, String>> i = result.iterator();
+        while (i.hasNext()){
+            Entry<Integer, String> e = i.next();
+            if (e.getKey().equals(i1)){
+                e.setValue("Big One");
+            }
+        }
+        assertTrue( instance.get(i1).equals("Big One"));
+    }
+
+    /**
+     * Test of get method, of class ReferenceMap.
+     */
+    @Test
+    public void testGet() {
+        System.out.println("get");
+        Object key = 1;
+        Object expResult = "One";
+        Object result = instance.get(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of isEmpty method, of class ReferenceMap.
+     */
+    @Test
+    public void testIsEmpty() {
+        System.out.println("isEmpty");
+        boolean expResult = false;
+        boolean result = instance.isEmpty();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of put method, of class ReferenceMap.
+     */
+    @Test
+    public void testPut() {
+        System.out.println("put");
+        Integer key = 5;
+        String value = "5";
+        Object expResult = "Five";
+        Object result = instance.put(key, value);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of putAll method, of class ReferenceMap.
+     */
+    @Test
+    public void testPutAll() {
+        System.out.println("putAll");
+        Map<Integer,String> m = new HashMap<Integer, String>();
+        Integer i6 = 6, i7 = 7, i8 = 8;
+        m.put(6,"Six");
+        m.put(7, "Seven");
+        m.put(8, "Eight");
+        instance.putAll(m);
+        assertTrue( instance.containsKey(8));
+        assertTrue( instance.containsValue("Seven"));
+    }
+
+    /**
+     * Test of remove method, of class ReferenceMap.
+     */
+    @Test
+    public void testRemove() {
+        System.out.println("remove");
+        Integer key = 4;
+        Object expResult = "Four";
+        String result = instance.remove(key);
+        assertEquals(expResult, result);
+        assertFalse(instance.containsKey(4));
+        assertFalse(instance.containsValue("Four"));
+    }
+
+    /**
+     * Test of size method, of class ReferenceMap.
+     */
+    @Test
+    public void testSize() {
+        System.out.println("size");
+        Collection<Integer> keys = instance.keySet();
+        int expResult = keys.size();
+        int result = instance.size();
+        System.out.println(instance);
+        assertEquals(expResult, result);
+    }
+
+
+
+     /**
+     * Test of clear method, of class ReferenceMap.
+     */
+    @Test
+    public void testClear() {
+        System.out.println("clear");
+        instance.clear();
+        assertTrue(instance.size() == 0);
+        instance.put(i1, s1);
+    }
+    
+//    /**
+//     * Test serialization - not implemented yet
+//     */
+//    @Test
+//    public void serialization() {
+//        Object result = null;
+//        ObjectOutputStream out = null;
+//        ObjectInputStream in = null;
+//        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+//        try {
+//            out = new ObjectOutputStream(baos);
+//            out.writeObject(instance);
+//            // Unmarshall it
+//            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+//            result = in.readObject();
+//        } catch (IOException ex) {
+//            ex.printStackTrace(System.out);
+//        } catch (ClassNotFoundException ex){
+//            ex.printStackTrace(System.out);
+//        }
+//        assertEquals(instance, result);
+//    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableMapTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableMapTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableMapTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableMapTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,314 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.TreeSet;
+import java.util.TreeMap;
+import java.lang.ref.Reference;
+import java.util.Map.Entry;
+import java.util.NavigableMap;
+import java.util.NavigableSet;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceNavigableMapTest {
+    private NavigableMap<Integer, String> instance;
+    // strong references
+    private Integer i1, i2, i3, i4, i5;
+    
+    public ReferenceNavigableMapTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+                 NavigableMap<Referrer<Integer>, Referrer<String>> internal 
+                = new TreeMap<Referrer<Integer>, Referrer<String>>();
+        instance = RC.navigableMap(internal, Ref.WEAK, Ref.STRONG, 10000L, 10000L);
+        i1 = 1;
+        i2 = 2;
+        i3 = 3;
+        i4 = 4;
+        i5 = 5;
+        instance.put(i1, "1");
+        instance.put(i2, "2");
+        instance.put(i3, "3");
+        instance.put(i4, "4");
+        instance.put(i5, "5");
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of lowerEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testLowerEntry() {
+        System.out.println("lowerEntry");
+        Integer key = 2;
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(1, "1");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.lowerEntry(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of lowerKey method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testLowerKey() {
+        System.out.println("lowerKey");
+        Integer key = 3;
+        Object expResult = 2;
+        Object result = instance.lowerKey(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of floorEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testFloorEntry() {
+        System.out.println("floorEntry");
+        Integer key = 4;
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(4, "4");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.floorEntry(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of floorKey method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testFloorKey() {
+        System.out.println("floorKey");
+        Integer key = 3;
+        Object expResult = 3;
+        Object result = instance.floorKey(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of ceilingEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testCeilingEntry() {
+        System.out.println("ceilingEntry");
+        Integer key = 3;
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(3, "3");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.ceilingEntry(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of ceilingKey method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testCeilingKey() {
+        System.out.println("ceilingKey");
+        Integer key = 2;
+        Object expResult = 2;
+        Object result = instance.ceilingKey(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of higherEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testHigherEntry() {
+        System.out.println("higherEntry");
+        Integer key = 4;
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(5, "5");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.higherEntry(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of higherKey method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testHigherKey() {
+        System.out.println("higherKey");
+        Integer key = 3;
+        Object expResult = 4;
+        Object result = instance.higherKey(key);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of firstEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testFirstEntry() {
+        System.out.println("firstEntry");
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(1, "1");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.firstEntry();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of lastEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testLastEntry() {
+        System.out.println("lastEntry");
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(5, "5");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.lastEntry();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of pollFirstEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testPollFirstEntry() {
+        System.out.println("pollFirstEntry");
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(1, "1");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.pollFirstEntry();
+        instance.put(1, "1"); // For other tests.
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of pollLastEntry method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testPollLastEntry() {
+        System.out.println("pollLastEntry");
+        NavigableMap<Integer, String> r = new TreeMap<Integer, String>();
+        r.put(5, "5");
+        Entry<Integer, String> expResult = r.pollFirstEntry();
+        Entry<Integer, String> result = instance.pollLastEntry();
+        instance.put(5, "5"); // For other tests.
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of descendingMap method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testDescendingMap() {
+        System.out.println("descendingMap");
+        NavigableMap<Integer, String> result = instance.descendingMap();
+        assertTrue(result.firstKey().equals(5));
+        assertTrue(result.lastKey().equals(1));
+    }
+
+    /**
+     * Test of navigableKeySet method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testNavigableKeySet() {
+        System.out.println("navigableKeySet");
+        NavigableSet<Integer> expResult = new TreeSet<Integer>();
+        expResult.add(1);
+        expResult.add(2);
+        expResult.add(3);
+        expResult.add(4);
+        expResult.add(5);
+        NavigableSet<Integer> result = instance.navigableKeySet();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of descendingKeySet method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testDescendingKeySet() {
+        System.out.println("descendingKeySet");
+        NavigableSet<Integer> result = instance.descendingKeySet();
+        assertTrue(result.first().equals(5));
+        assertTrue(result.last().equals(1));
+    }
+
+    /**
+     * Test of subMap method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testSubMap() {
+        System.out.println("subMap");
+        Integer fromKey = 2;
+        boolean fromInclusive = false;
+        Integer toKey = 5;
+        boolean toInclusive = false;
+        NavigableMap<Integer, String> expResult = new TreeMap<Integer, String>();
+        expResult.put(3, "3");
+        expResult.put(4, "4");
+        NavigableMap<Integer, String> result = instance.subMap(fromKey, fromInclusive, toKey, toInclusive);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of headMap method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testHeadMap() {
+        System.out.println("headMap");
+        Integer toKey = 3;
+        boolean inclusive = false;
+        NavigableMap<Integer, String> expResult = new TreeMap<Integer, String>();
+        expResult.put(1, "1");
+        expResult.put(2, "2");
+        NavigableMap<Integer, String> result = instance.headMap(toKey, inclusive);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of tailMap method, of class ReferenceNavigableMap.
+     */
+    @Test
+    public void testTailMap() {
+        System.out.println("tailMap");
+        Integer fromKey = 3;
+        boolean inclusive = false;
+        NavigableMap<Integer, String> expResult = new TreeMap<Integer, String>();
+        expResult.put(4, "4");
+        expResult.put(5, "5");
+        NavigableMap<Integer, String> result = instance.tailMap(fromKey, inclusive);
+        assertEquals(expResult, result);
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableSetTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableSetTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableSetTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceNavigableSetTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,235 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.lang.ref.Reference;
+import java.util.TreeSet;
+import java.util.Iterator;
+import java.util.NavigableSet;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceNavigableSetTest {
+    private NavigableSet<String> instance;
+    public ReferenceNavigableSetTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        instance = RC.navigableSet(new TreeSet<Referrer<String>>(), Ref.STRONG, 10000L);
+        instance.add("eee");
+        instance.add("bbb");
+        instance.add("aaa");
+        instance.add("ccc");
+        instance.add("ddd");
+        instance.add("fff");
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of lower method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testLower() {
+        System.out.println("lower");
+        String e = "ccc";
+        String expResult = "bbb";
+        String result = instance.lower(e);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of floor method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testFloor() {
+        System.out.println("floor");
+        String e = "ccc";
+        Object expResult = "ccc";
+        Object result = instance.floor(e);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of ceiling method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testCeiling() {
+        System.out.println("ceiling");
+        String e = "ddd";
+        Object expResult = "ddd";
+        Object result = instance.ceiling(e);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of higher method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testHigher() {
+        System.out.println("higher");
+        String e = "bbb";
+        Object expResult = "ccc";
+        Object result = instance.higher(e);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of pollFirst method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testPollFirst() {
+        System.out.println("pollFirst");
+        Object expResult = "aaa";
+        String result = instance.pollFirst();
+        instance.add(result);// put it back for other tests.
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of pollLast method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testPollLast() {
+        System.out.println("pollLast");
+        Object expResult = "fff";
+        String result = instance.pollLast();
+        instance.add(result);// Put it back for other tests.
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of descendingSet method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testDescendingSet() {
+        System.out.println("descendingSet");
+        NavigableSet<String> result = instance.descendingSet();
+        assertTrue(!result.isEmpty()); // We only want to check the method works.
+        assertTrue(result.first() instanceof String); // And the Set contains Strings, not references.
+    }
+
+    /**
+     * Test of descendingIterator method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testDescendingIterator() {
+        System.out.println("descendingIterator");
+        NavigableSet<String> e = new TreeSet<String>();
+        Iterator<String> i = instance.descendingIterator();
+        while (i.hasNext()){
+            e.add(i.next());
+        }
+        assertTrue(!e.isEmpty()); // Make sure we received strings.
+        assertTrue(e.contains("ccc")); 
+    }
+
+    /**
+     * Test of subSet method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testSubSet() {
+        System.out.println("subSet");
+        String fromElement = "bbb";
+        boolean fromInclusive = false;
+        String toElement = "eee";
+        boolean toInclusive = false;
+        NavigableSet<String> expResult = new TreeSet<String>();
+        expResult.add("ccc");
+        expResult.add("ddd");
+        NavigableSet<String> result = instance.subSet(fromElement, fromInclusive, toElement, toInclusive);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of headSet method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testHeadSet() {
+        System.out.println("headSet");
+        String toElement = "ccc";
+        boolean inclusive = false;
+        NavigableSet<String> expResult = new TreeSet<String>();
+        expResult.add("aaa");
+        expResult.add("bbb");
+        NavigableSet<String> result = instance.headSet(toElement, inclusive);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of tailSet method, of class ReferenceNavigableSet.
+     */
+    @Test
+    public void testTailSet() {
+        System.out.println("tailSet");
+        String fromElement = "ccc";
+        boolean inclusive = false;
+        NavigableSet<String> expResult = new TreeSet<String>();
+        expResult.add("ddd");
+        expResult.add("eee");
+        expResult.add("fff");
+        NavigableSet<String> result = instance.tailSet(fromElement, inclusive);
+        assertEquals(expResult, result);
+    }
+    
+       /**
+     * Test serialization
+     */
+    @Test
+    public void serialization() {
+        System.out.println("Serialization Test");
+        Object result = null;
+        ObjectOutputStream out = null;
+        ObjectInputStream in = null;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            out = new ObjectOutputStream(baos);
+            out.writeObject(instance);
+            // Unmarshall it
+            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+            result = in.readObject();
+        } catch (IOException ex) {
+            ex.printStackTrace(System.out);
+        } catch (ClassNotFoundException ex){
+            ex.printStackTrace(System.out);
+        }
+        assertEquals(instance, result);
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSetTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSetTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSetTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSetTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,70 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.util.TreeSet;
+import java.lang.ref.Reference;
+import java.util.Set;
+import java.util.HashSet;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceSetTest {
+    
+    public ReferenceSetTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    @Test
+    public void testEquals() {
+        System.out.println("testEquals");
+        Set<String> set1 = new HashSet<String>(3);
+        Set<String> set2 = RC.set(new TreeSet<Referrer<String>>(), Ref.SOFT, 10000L);
+        String s1 = "1", s2 = "2", s3 = "3";
+        set1.add(s1);
+        set1.add(s2);
+        set1.add(s3);
+        set2.add(s1);
+        set2.add(s2);
+        set2.add(s3);
+        assertTrue(set1.equals(set2));
+        assertTrue(set2.equals(set1));
+        assertTrue(set1.hashCode() == set2.hashCode());
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedMapTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedMapTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedMapTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedMapTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,186 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.TreeMap;
+import java.lang.ref.Reference;
+import java.util.Comparator;
+import java.util.SortedMap;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceSortedMapTest {
+    private SortedMap<Integer, String> instance;
+    // strong references
+    private Integer i1, i2, i3, i4, i5;
+    private Comparator<Integer> comparator;
+    
+    public ReferenceSortedMapTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        comparator = new Comparator<Integer>(){
+
+            @Override
+            public int compare(Integer o1, Integer o2) {
+                return o1.compareTo(o2);
+            }
+            
+        };
+        Comparator<Referrer<Integer>> ci = RC.comparator(comparator);
+         SortedMap<Referrer<Integer>, Referrer<String>> internal 
+                = new TreeMap<Referrer<Integer>, Referrer<String>>(ci);
+        instance = RC.sortedMap(internal, Ref.WEAK, Ref.STRONG, 10000L, 10000L);
+        i1 = 1;
+        i2 = 2;
+        i3 = 3;
+        i4 = 4;
+        i5 = 5;
+        instance.put(i1, "1");
+        instance.put(i2, "2");
+        instance.put(i3, "3");
+        instance.put(i4, "4");
+        instance.put(i5, "5");
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of comparator method, of class ReferenceSortedMap.
+     */
+    @Test
+    public void testComparator() {
+        System.out.println("comparator");
+        Comparator<Integer> expResult = comparator;
+        Comparator<? super Integer> result = instance.comparator();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of subMap method, of class ReferenceSortedMap.
+     */
+    @Test
+    public void testSubMap() {
+        System.out.println("subMap");
+        Integer fromKey = 2;
+        Integer toKey = 4;
+        SortedMap<Integer, String> expResult = new TreeMap<Integer, String>();
+        expResult.put(2, "2");
+        expResult.put(3, "3");
+        SortedMap<Integer, String> result = instance.subMap(fromKey, toKey);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of headMap method, of class ReferenceSortedMap.
+     */
+    @Test
+    public void testHeadMap() {
+        System.out.println("headMap");
+        Integer toKey = 3;
+        SortedMap<Integer, String> expResult = new TreeMap<Integer, String>();
+        expResult.put(1, "1");
+        expResult.put(2, "2");
+        SortedMap<Integer, String> result = instance.headMap(toKey);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of tailMap method, of class ReferenceSortedMap.
+     */
+    @Test
+    public void testTailMap() {
+        System.out.println("tailMap");
+        Integer fromKey = 3;
+        SortedMap<Integer, String> expResult = new TreeMap<Integer, String>();
+        expResult.put(3, "3");
+        expResult.put(4, "4");
+        expResult.put(5, "5");
+        SortedMap<Integer, String> result = instance.tailMap(fromKey);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of firstKey method, of class ReferenceSortedMap.
+     */
+    @Test
+    public void testFirstKey() {
+        System.out.println("firstKey");
+        Object expResult = 1;
+        Object result = instance.firstKey();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of lastKey method, of class ReferenceSortedMap.
+     */
+    @Test
+    public void testLastKey() {
+        System.out.println("lastKey");
+        Object expResult = 5;
+        Object result = instance.lastKey();
+        assertEquals(expResult, result);
+    }
+      
+//    /**
+//     * Test serialization - not implemented yet
+//     */
+//    @Test
+//    public void serialization() {
+//        System.out.println("Serialization Test");
+//        Object result = null;
+//        ObjectOutputStream out = null;
+//        ObjectInputStream in = null;
+//        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+//        try {
+//            out = new ObjectOutputStream(baos);
+//            out.writeObject(instance);
+//            // Unmarshall it
+//            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+//            result = in.readObject();
+//        } catch (IOException ex) {
+//            ex.printStackTrace(System.out);
+//        } catch (ClassNotFoundException ex){
+//            ex.printStackTrace(System.out);
+//        }
+//        assertEquals(instance, result);
+//    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedSetTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedSetTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedSetTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferenceSortedSetTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,169 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.TreeSet;
+import java.util.Comparator;
+import java.util.SortedSet;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferenceSortedSetTest {
+    private SortedSet<String> instance;
+    private Comparator<String> comparator;
+    public ReferenceSortedSetTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        
+        comparator = new StringComparator();
+        Comparator<Referrer<String>> rc = RC.comparator(comparator);
+        instance = RC.sortedSet(new TreeSet<Referrer<String>>(rc), Ref.STRONG, 10000L);
+        instance.add("eee");
+        instance.add("bbb");
+        instance.add("aaa");
+        instance.add("ccc");
+        instance.add("ddd");
+        instance.add("fff");
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of comparator method, of class ReferenceSortedSet.
+     */
+    @Test
+    public void testComparator() {
+        System.out.println("comparator");
+        Comparator<String> expResult = comparator;
+        Comparator<String> result = (Comparator<String>) instance.comparator();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of subSet method, of class ReferenceSortedSet.
+     */
+    @Test
+    public void testSubSet() {
+        System.out.println("subSet");
+        String fromElement = "ccc";
+        String toElement = "eee";
+        SortedSet<String> expResult = new TreeSet<String>();
+        expResult.add("ccc");
+        expResult.add("ddd");
+        SortedSet<String> result = instance.subSet(fromElement, toElement);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of headSet method, of class ReferenceSortedSet.
+     */
+    @Test
+    public void testHeadSet() {
+        System.out.println("headSet");
+        String toElement = "ccc";
+        SortedSet<String> expResult = new TreeSet<String>();
+        expResult.add("aaa");
+        expResult.add("bbb");
+        SortedSet<String> result = instance.headSet(toElement);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of tailSet method, of class ReferenceSortedSet.
+     */
+    @Test
+    public void testTailSet() {
+        System.out.println("tailSet");
+        String fromElement = "eee";
+        SortedSet<String> expResult = new TreeSet<String>();
+        expResult.add("eee");
+        expResult.add("fff");
+        SortedSet<String> result = instance.tailSet(fromElement);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of first method, of class ReferenceSortedSet.
+     */
+    @Test
+    public void testFirst() {
+        System.out.println("first");
+        String expResult = "aaa";
+        Object result = instance.first();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of last method, of class ReferenceSortedSet.
+     */
+    @Test
+    public void testLast() {
+        System.out.println("last");
+        Object expResult = "fff";
+        Object result = instance.last();
+        assertEquals(expResult, result);
+    }
+    
+      
+    /**
+     * Test serialization
+     */
+    @Test
+    public void serialization() {
+        System.out.println("Serialization Test");
+        Object result = null;
+        ObjectOutputStream out = null;
+        ObjectInputStream in = null;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            out = new ObjectOutputStream(baos);
+            out.writeObject(instance);
+            // Unmarshall it
+            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+            result = in.readObject();
+        } catch (IOException ex) {
+            ex.printStackTrace(System.out);
+        } catch (ClassNotFoundException ex){
+            ex.printStackTrace(System.out);
+        }
+        assertEquals(instance, result);
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferencedQueueTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferencedQueueTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferencedQueueTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferencedQueueTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,145 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.LinkedList;
+import java.util.Queue;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class ReferencedQueueTest {
+    Queue<String> instance;
+    public ReferencedQueueTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        instance = RC.queue(new LinkedList<Referrer<String>>(), Ref.SOFT, 10000L);
+    }
+    
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of offer method, of class ReferencedQueue.
+     */
+    @Test
+    public void testOffer() {
+        System.out.println("offer");
+        String e = "offer";
+        boolean expResult = true;
+        boolean result = instance.offer(e);
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of remove method, of class ReferencedQueue.
+     */
+    @Test
+    public void testRemove() {
+        String expResult = "remove";
+        System.out.println(expResult);
+        instance.add(expResult);
+        Object result = instance.remove();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of poll method, of class ReferencedQueue.
+     */
+    @Test
+    public void testPoll() {
+        String expResult = "poll";
+        System.out.println(expResult);
+        instance.add(expResult);
+        String result = instance.poll();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of element method, of class ReferencedQueue.
+     */
+    @Test
+    public void testElement() {
+        String expResult = "element";
+        System.out.println(expResult);
+        instance.add(expResult);
+        Object result = instance.element();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of peek method, of class ReferencedQueue.
+     */
+    @Test
+    public void testPeek() {
+        String expResult = "peek";
+        System.out.println(expResult);
+        instance.add(expResult);
+        Object result = instance.peek();
+        assertEquals(expResult, result);
+    }
+    
+      
+       /**
+     * Test serialization
+     */
+    @Test
+    @SuppressWarnings("unchecked")
+    public void serialization() {
+        System.out.println("Serialization Test");
+        Object result = null;
+        ObjectOutputStream out = null;
+        ObjectInputStream in = null;
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        try {
+            out = new ObjectOutputStream(baos);
+            out.writeObject(instance);
+            // Unmarshall it
+            in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+            result = in.readObject();
+        } catch (IOException ex) {
+            ex.printStackTrace(System.out);
+        } catch (ClassNotFoundException ex){
+            ex.printStackTrace(System.out);
+        }
+        assertTrue(result instanceof Queue);
+        assertTrue(instance.containsAll((Queue<String>)result));
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferrerTimeTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferrerTimeTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferrerTimeTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/ReferrerTimeTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2012 Zeus Project Services Pty Ltd
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.river.concurrent;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.Queue;
+import java.util.concurrent.ConcurrentLinkedQueue;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.concurrent.ConcurrentNavigableMap;
+import java.util.concurrent.ConcurrentSkipListMap;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Peter Firmstone.
+ */
+public class ReferrerTimeTest {
+    private ConcurrentNavigableMap<Integer, String> instance;
+    // strong references
+    private Integer [] ints;
+    private Comparator<Integer> comparator;
+    public ReferrerTimeTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+        comparator = new Comparator<Integer>(){
+
+            @Override
+            public int compare(Integer o1, Integer o2) {
+                return o1.compareTo(o2);
+            }
+            
+        };
+        Comparator<Referrer<Integer>> ci = RC.comparator(comparator);
+         ConcurrentNavigableMap<Referrer<Integer>, Referrer<String>> internal 
+                = new ConcurrentSkipListMap<Referrer<Integer>, Referrer<String>>(ci);
+        instance = RC.concurrentNavigableMap(internal, Ref.TIME, Ref.STRONG, 60L, 60L);
+        ints = new Integer[5];
+        ints[0] = 0;
+        ints[1] = 1;
+        ints[2] = 2;
+        ints[3] = 3;
+        ints[4] = 4;
+        instance.put(ints[0], "0");
+        instance.put(ints[1], "1");
+        instance.put(ints[2], "2");
+        instance.put(ints[3], "3");
+        instance.put(ints[4], "4");
+    }
+    
+    @Test
+    public void testCleanerIteration() throws InterruptedException{
+        System.out.println("testCleanerIteration");
+        long start = System.nanoTime();
+        Thread.sleep(180L);
+        long finish = System.nanoTime();
+        System.out.println(finish - start);
+        assertTrue(instance.keySet().isEmpty());
+        assertTrue(instance.values().isEmpty());
+        assertFalse(instance.containsKey(ints[0]));
+        assertFalse(instance.containsValue("1"));
+    }
+    
+    @Test
+    public void testKeyRemove(){
+        System.out.println("testKeyRemove");
+        Collection keys = instance.keySet();
+        keys.remove(ints[1]);
+        assertFalse(instance.containsKey(ints[1]));
+    }
+    
+    @Test
+    public void testCleanerRetains() throws InterruptedException{
+        System.out.println("testCleanerRetains");
+        instance.putIfAbsent(ints[0], "Zero");
+        instance.putIfAbsent(ints[1], "One");
+        instance.putIfAbsent(ints[2], "Two");
+        instance.putIfAbsent(ints[3], "Three");
+        instance.putIfAbsent(ints[4], "Four");
+        for (int i=0; i<6; i++){
+            Thread.sleep(20L);
+            for( int j=0; j<5 ; j++){
+                System.out.println(instance.get(ints[j]));
+            }
+        }
+        for (int k = 0; k<5; k++){
+            assertTrue(instance.containsKey(ints[k]));
+        }
+    }
+    
+    @Test
+    public void testCleanerRetainsOnlyOne() throws InterruptedException{
+        System.out.println("testCleanerRetainsOnlyOne");
+        instance.putIfAbsent(ints[0], "Zero");
+        instance.putIfAbsent(ints[1], "One");
+        instance.putIfAbsent(ints[2], "Two");
+        instance.putIfAbsent(ints[3], "Three");
+        instance.putIfAbsent(ints[4], "Four");
+        for (int i=0; i<6; i++){
+            Thread.sleep(30L);
+            System.out.println(instance.get(ints[1]));
+        }
+        assertTrue(instance.containsKey(ints[1]));
+        assertFalse(instance.containsKey(ints[0]));
+        assertFalse(instance.containsKey(ints[2]));
+        assertFalse(instance.containsKey(ints[3]));
+        assertFalse(instance.containsKey(ints[4]));
+    }
+    
+    @Test
+    public void TestQueueFuture() throws InterruptedException 
+    {
+        System.out.println("testQueueFuture");
+        Queue<Future> que = RC.queue(
+                new ConcurrentLinkedQueue<Referrer<Future>>(), 
+                Ref.TIME, 20L);
+        Future f = new F();
+        que.offer(f);
+        Thread.sleep(60L);
+        assertTrue(f.isCancelled());
+    }
+    
+    private static class F implements Future{
+        private volatile boolean cancelled = false;
+        
+        public boolean cancel(boolean mayInterruptIfRunning) {
+            cancelled = true;
+            System.out.println("cancelled");
+            return true;
+        }
+
+        public boolean isCancelled() {
+            return cancelled;
+        }
+
+        public boolean isDone() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Object get() throws InterruptedException, ExecutionException {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+        
+    }
+    
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/StringComparator.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/StringComparator.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/StringComparator.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/StringComparator.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,31 @@
+/* Copyright (c) 2010-2012 Zeus Project Services Pty Ltd.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.concurrent;
+
+import java.io.Serializable;
+import java.util.Comparator;
+
+/**
+ *
+ * @author peter
+ */
+public class StringComparator implements Comparator<String>, Serializable {
+    private static final long serialVersionUID = 1L;
+    
+    public int compare(String o1, String o2) {
+        return o1.compareTo(o2);
+    }
+}

Added: river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/TimedReferrerTest.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/TimedReferrerTest.java?rev=1702174&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/TimedReferrerTest.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/test/src/org/apache/river/concurrent/TimedReferrerTest.java Thu Sep 10 06:59:28 2015
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2012 peter.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.river.concurrent;
+
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author peter
+ */
+public class TimedReferrerTest {
+    String t = "test";
+    TimedRefQueue que = new TimedRefQueue();
+    public TimedReferrerTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+    
+    @Before
+    public void setUp() {
+    }
+
+    /**
+     * Test of get method, of class TimedReferrer.
+     */
+    @Test
+    public void testGet() {
+        System.out.println("get");
+        TimedReferrer instance = new TimedReferrer(t, que);
+        Object expResult = t;
+        Object result = instance.get();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of clear method, of class TimedReferrer, it should ignore the
+     * clear call.
+     */
+    @Test
+    public void testClear() {
+        System.out.println("clear");
+        TimedReferrer instance = new TimedReferrer<String>(t, que);
+        Object expResult = t;
+        Object result = instance.get();
+        assertEquals(expResult, result);
+        instance.clear();
+        result = instance.get();
+        assertEquals(expResult, result);
+    }
+
+    /**
+     * Test of isEnqueued method, of class TimedReferrer.
+     */
+    @Test
+    public void testIsEnqueued() {
+        System.out.println("isEnqueued");
+        TimedReferrer instance = new TimedReferrer(t, que);
+        boolean expResult = false;
+        boolean result = instance.isEnqueued();
+        assertEquals(expResult, result);
+        instance.enqueue();
+        assertEquals(instance.isEnqueued(), true);
+    }
+
+    /**
+     * Test of updateClock method, of class TimedReferrer.
+     */
+    @Test
+    public void testUpdateClock() {
+        System.out.println("updateClock");
+        long time = System.nanoTime();
+        TimedReferrer instance = new TimedReferrer(t, que);
+        instance.updateClock(time);
+        assertFalse(instance.isEnqueued());
+        instance.updateClock(time + 6000000000L);
+        instance.updateClock(time + 9000000000L);
+        assertTrue(instance.isEnqueued());
+        Object result = que.poll();
+        assertTrue(result instanceof Referrer);
+        assertTrue(instance.get() != null);
+    }
+
+}