commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r738956 [34/34] - in /commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/bidimap/ java/org/apache/commons/collec...
Date Thu, 29 Jan 2009 18:48:47 GMT
Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet.java
Thu Jan 29 18:48:37 2009
@@ -31,7 +31,7 @@
  * 
  * @author Stephen Colebourne
  */
-public class TestMapBackedSet extends AbstractTestSet {
+public class TestMapBackedSet<E> extends AbstractTestSet<E> {
 
     public TestMapBackedSet(String testName) {
         super(testName);
@@ -46,8 +46,8 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Set makeEmptySet() {
-        return MapBackedSet.decorate(new HashedMap());
+    public Set<E> makeObject() {
+        return MapBackedSet.decorate(new HashedMap<E, Object>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestMapBackedSet2.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -29,10 +29,10 @@
  *
  * @since Commons Collections 3.1
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestMapBackedSet2 extends AbstractTestSet {
+public class TestMapBackedSet2<E> extends AbstractTestSet<E> {
 
     public TestMapBackedSet2(String testName) {
         super(testName);
@@ -47,22 +47,24 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Set makeEmptySet() {
-        return MapBackedSet.decorate(new LinkedMap());
+    public Set<E> makeObject() {
+        return MapBackedSet.decorate(new LinkedMap<E, Object>());
     }
 
-    protected Set setupSet() {
-        Set set = makeEmptySet();
+    @SuppressWarnings("unchecked")
+    protected Set<E> setupSet() {
+        Set<E> set = makeObject();
 
         for (int i = 0; i < 10; i++) {
-            set.add(Integer.toString(i));
+            set.add((E) Integer.toString(i));
         }
         return set;
     }
 
+    @SuppressWarnings("unchecked")
     public void testOrdering() {
-        Set set = setupSet();
-        Iterator it = set.iterator();
+        Set<E> set = setupSet();
+        Iterator<E> it = set.iterator();
 
         for (int i = 0; i < 10; i++) {
             assertEquals("Sequence is wrong", Integer.toString(i), it.next());
@@ -78,7 +80,7 @@
         }
 
         for (int i = 0; i < 10; i++) {
-            set.add(Integer.toString(i));
+            set.add((E) Integer.toString(i));
         }
 
         assertEquals("Size of set is wrong!", 10, set.size());

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -23,101 +23,103 @@
 import junit.framework.TestSuite;
 
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.collections.functors.TruePredicate;
 
 /**
- * Extension of {@link TestSet} for exercising the 
+ * Extension of {@link TestSet} for exercising the
  * {@link PredicatedSet} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestPredicatedSet extends AbstractTestSet{
-    
+public class TestPredicatedSet<E> extends AbstractTestSet<E> {
+
     public TestPredicatedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return new TestSuite(TestPredicatedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestPredicatedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
+
  //-------------------------------------------------------------------
-    
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    
-    protected Set decorateSet(Set set, Predicate predicate) {
-        return PredicatedSet.decorate(set, predicate);
-    }
-    
-    public Set makeEmptySet() {
-        return decorateSet(new HashSet(), truePredicate);
-    }
-    
-    public Object[] getFullElements() {
-        return new Object[] {"1", "3", "5", "7", "2", "4", "6"};
-    }
-    
-//--------------------------------------------------------------------   
-    
-    protected Predicate testPredicate =  
-        new Predicate() {
-            public boolean evaluate(Object o) {
+
+    protected Predicate<E> truePredicate = TruePredicate.<E>truePredicate();
+
+    protected PredicatedSet<E> decorateSet(Set<E> set, Predicate<? super E>
predicate) {
+        return (PredicatedSet<E>) PredicatedSet.decorate(set, predicate);
+    }
+
+    public PredicatedSet<E> makeObject() {
+        return decorateSet(new HashSet<E>(), truePredicate);
+    }
+
+    @SuppressWarnings("unchecked")
+    public E[] getFullElements() {
+        return (E[]) new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+    }
+
+//--------------------------------------------------------------------
+
+    protected Predicate<E> testPredicate =
+        new Predicate<E>() {
+            public boolean evaluate(E o) {
                 return o instanceof String;
             }
-        };      
-    
-    protected Set makeTestSet() {
-        return decorateSet(new HashSet(), testPredicate);
+        };
+
+    protected PredicatedSet<E> makeTestSet() {
+        return decorateSet(new HashSet<E>(), testPredicate);
     }
-    
+
     public void testGetSet() {
-         Set set = makeTestSet();
-        assertTrue("returned set should not be null",
-            ((PredicatedSet) set).decorated() != null);
+        PredicatedSet<E> set = makeTestSet();
+        assertTrue("returned set should not be null", set.decorated() != null);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        Set set = makeTestSet();
+        Set<E> set = makeTestSet();
         Integer i = new Integer(3);
         try {
-            set.add(i);
+            set.add((E) i);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !set.contains(i));   
+        assertTrue("Collection shouldn't contain illegal element",
+         !set.contains(i));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIllegalAddAll() {
-        Set set = makeTestSet();
-        Set elements = new HashSet();
-        elements.add("one");
-        elements.add("two");
-        elements.add(new Integer(3));
-        elements.add("four");
+        Set<E> set = makeTestSet();
+        Set<E> elements = new HashSet<E>();
+        elements.add((E) "one");
+        elements.add((E) "two");
+        elements.add((E) new Integer(3));
+        elements.add((E) "four");
         try {
             set.addAll(elements);
             fail("Integer should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("one"));   
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("two"));   
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains(new Integer(3)));   
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("four"));   
+        assertTrue("Set shouldn't contain illegal element",
+         !set.contains("one"));
+        assertTrue("Set shouldn't contain illegal element",
+         !set.contains("two"));
+        assertTrue("Set shouldn't contain illegal element",
+         !set.contains(new Integer(3)));
+        assertTrue("Set shouldn't contain illegal element",
+         !set.contains("four"));
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestPredicatedSortedSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -26,106 +26,101 @@
 
 import org.apache.commons.collections.BulkTest;
 import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.PredicateUtils;
+import org.apache.commons.collections.functors.TruePredicate;
 import org.apache.commons.collections.map.TestPredicatedSortedMap;
 
 /**
- * Extension of {@link AbstractTestSortedSet} for exercising the 
+ * Extension of {@link AbstractTestSortedSet} for exercising the
  * {@link PredicatedSortedSet} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestPredicatedSortedSet extends AbstractTestSortedSet{
-    
+public class TestPredicatedSortedSet<E> extends AbstractTestSortedSet<E> {
+
     public TestPredicatedSortedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestPredicatedSortedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestPredicatedSortedMap.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
- //-------------------------------------------------------------------    
-    
-    protected Predicate truePredicate = PredicateUtils.truePredicate();
-    
-    public Set makeEmptySet() {
-        return PredicatedSortedSet.decorate(new TreeSet(), truePredicate);
-    }
-    
-    public Set makeFullSet() {
-        TreeSet set = new TreeSet();
+
+ //-------------------------------------------------------------------
+
+    protected Predicate<E> truePredicate = TruePredicate.<E>truePredicate();
+
+    public SortedSet<E> makeObject() {
+        return PredicatedSortedSet.decorate(new TreeSet<E>(), truePredicate);
+    }
+
+    public SortedSet<E> makeFullCollection() {
+        TreeSet<E> set = new TreeSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
         return PredicatedSortedSet.decorate(set, truePredicate);
     }
-   
-    
-//--------------------------------------------------------------------   
-    protected Predicate testPredicate =  
-        new Predicate() {
-            public boolean evaluate(Object o) {
+
+//--------------------------------------------------------------------
+    protected Predicate<E> testPredicate =
+        new Predicate<E>() {
+            public boolean evaluate(E o) {
                 return (o instanceof String) && (((String) o).startsWith("A"));
             }
-        };      
-     
-    
-    protected SortedSet makeTestSet() {
-        return PredicatedSortedSet.decorate(new TreeSet(), testPredicate);
+        };
+
+    protected PredicatedSortedSet<E> makeTestSet() {
+        return (PredicatedSortedSet<E>) PredicatedSortedSet.decorate(new TreeSet<E>(),
testPredicate);
     }
-    
+
     public void testGetSet() {
-        SortedSet set = makeTestSet();
-        assertTrue("returned set should not be null",
-            ((PredicatedSortedSet) set).decorated() != null);
+        PredicatedSortedSet<E> set = makeTestSet();
+        assertTrue("returned set should not be null", set.decorated() != null);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testIllegalAdd() {
-        SortedSet set = makeTestSet();
+        SortedSet<E> set = makeTestSet();
         String testString = "B";
         try {
-            set.add(testString);
+            set.add((E) testString);
             fail("Should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Collection shouldn't contain illegal element", 
-         !set.contains(testString));   
+        assertTrue("Collection shouldn't contain illegal element",
+         !set.contains(testString));
     }
 
+    @SuppressWarnings("unchecked")
     public void testIllegalAddAll() {
-        SortedSet set = makeTestSet();
-        Set elements = new TreeSet();
-        elements.add("Aone");
-        elements.add("Atwo");
-        elements.add("Bthree");
-        elements.add("Afour");
+        SortedSet<E> set = makeTestSet();
+        Set<E> elements = new TreeSet<E>();
+        elements.add((E) "Aone");
+        elements.add((E) "Atwo");
+        elements.add((E) "Bthree");
+        elements.add((E) "Afour");
         try {
             set.addAll(elements);
             fail("Should fail string predicate.");
         } catch (IllegalArgumentException e) {
             // expected
         }
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("Aone"));   
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("Atwo"));   
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("Bthree"));   
-        assertTrue("Set shouldn't contain illegal element", 
-         !set.contains("Afour"));   
+        assertTrue("Set shouldn't contain illegal element", !set.contains("Aone"));
+        assertTrue("Set shouldn't contain illegal element", !set.contains("Atwo"));
+        assertTrue("Set shouldn't contain illegal element", !set.contains("Bthree"));
+        assertTrue("Set shouldn't contain illegal element", !set.contains("Afour"));
     }
-    
+
     public void testComparator() {
-        SortedSet set = makeTestSet();
-        Comparator c = set.comparator();
+        SortedSet<E> set = makeTestSet();
+        Comparator<? super E> c = set.comparator();
         assertTrue("natural order, so comparator should be null", c == null);
     }
 

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -24,32 +24,32 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSet} for exercising the 
+ * Extension of {@link AbstractTestSet} for exercising the
  * {@link SynchronizedSet} implementation.
  *
  * @since Commons Collections 3.1
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestSynchronizedSet extends AbstractTestSet{
-    
+public class TestSynchronizedSet<E> extends AbstractTestSet<E> {
+
     public TestSynchronizedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestSynchronizedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestSynchronizedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-   //-------------------------------------------------------------------      
-    public Set makeEmptySet() {
-        return SynchronizedSet.decorate(new HashSet());
+
+   //-------------------------------------------------------------------
+    public Set<E> makeObject() {
+        return SynchronizedSet.decorate(new HashSet<E>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestSynchronizedSortedSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -16,7 +16,7 @@
  */
 package org.apache.commons.collections.set;
 
-import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 import junit.framework.Test;
@@ -24,32 +24,32 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSet} for exercising the 
+ * Extension of {@link AbstractTestSet} for exercising the
  * {@link SynchronizedSortedSet} implementation.
  *
  * @since Commons Collections 3.1
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestSynchronizedSortedSet extends AbstractTestSortedSet{
-    
+public class TestSynchronizedSortedSet<E> extends AbstractTestSortedSet<E> {
+
     public TestSynchronizedSortedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestSynchronizedSortedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestSynchronizedSortedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-   //-------------------------------------------------------------------      
-    public Set makeEmptySet() {
-        return SynchronizedSortedSet.decorate(new TreeSet());
+
+   //-------------------------------------------------------------------
+    public SortedSet<E> makeObject() {
+        return SynchronizedSortedSet.decorate(new TreeSet<E>());
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -17,13 +17,13 @@
 package org.apache.commons.collections.set;
 
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -32,11 +32,11 @@
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestTransformedSet extends AbstractTestSet {
-    
+public class TestTransformedSet<E> extends AbstractTestSet<E> {
+
     public TestTransformedSet(String testName) {
         super(testName);
     }
@@ -50,40 +50,46 @@
         junit.textui.TestRunner.main(testCaseName);
     }
 
-    public Collection makeConfirmedCollection() {
-        return new HashSet();
+    public Set<E> makeConfirmedCollection() {
+        return new HashSet<E>();
     }
 
-    public Collection makeConfirmedFullCollection() {
-        Set set = new HashSet();
+    public Set<E> makeConfirmedFullCollection() {
+        Set<E> set = new HashSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
         return set;
     }
-    
-    public Set makeEmptySet() {
-        return TransformedSet.decorate(new HashSet(), TestTransformedCollection.NOOP_TRANSFORMER);
+
+    @SuppressWarnings("unchecked")
+    public Set<E> makeObject() {
+        return TransformedSet.decorate(new HashSet<E>(),
+                (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
-    public Set makeFullSet() {
-        Set list = new HashSet();
+    @SuppressWarnings("unchecked")
+    public Set<E> makeFullCollection() {
+        Set<E> list = new HashSet<E>();
         list.addAll(Arrays.asList(getFullElements()));
-        return TransformedSet.decorate(list, TestTransformedCollection.NOOP_TRANSFORMER);
+        return TransformedSet.decorate(list,
+                (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
-    
+
+    @SuppressWarnings("unchecked")
     public void testTransformedSet() {
-        Set set = TransformedSet.decorate(new HashSet(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        Set<E> set = TransformedSet.decorate(new HashSet<E>(),
+                (Transformer<E, E>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, set.size());
-        Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+        E[] els = (E[]) new Object[] { "1", "3", "5", "7", "2", "4", "6" };
         for (int i = 0; i < els.length; i++) {
             set.add(els[i]);
             assertEquals(i + 1, set.size());
             assertEquals(true, set.contains(new Integer((String) els[i])));
             assertEquals(false, set.contains(els[i]));
         }
-        
+
         assertEquals(false, set.remove(els[0]));
         assertEquals(true, set.remove(new Integer((String) els[0])));
-        
+
     }
 
     public String getCompatibilityVersion() {

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestTransformedSortedSet.java
Thu Jan 29 18:48:37 2009
@@ -17,14 +17,13 @@
 package org.apache.commons.collections.set;
 
 import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
 import junit.framework.Test;
 
 import org.apache.commons.collections.BulkTest;
+import org.apache.commons.collections.Transformer;
 import org.apache.commons.collections.collection.TestTransformedCollection;
 
 /**
@@ -33,11 +32,11 @@
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Stephen Colebourne
  */
-public class TestTransformedSortedSet extends AbstractTestSortedSet {
-    
+public class TestTransformedSortedSet<E> extends AbstractTestSortedSet<E> {
+
     public TestTransformedSortedSet(String testName) {
         super(testName);
     }
@@ -52,32 +51,35 @@
     }
 
     //-----------------------------------------------------------------------
-    public Set makeEmptySet() {
-        return TransformedSortedSet.decorate(new TreeSet(), TestTransformedCollection.NOOP_TRANSFORMER);
+    @SuppressWarnings("unchecked")
+    public SortedSet<E> makeObject() {
+        return TransformedSortedSet.decorate(new TreeSet<E>(), (Transformer<E, E>)
TestTransformedCollection.NOOP_TRANSFORMER);
     }
 
-    public Set makeFullSet() {
-        SortedSet set = new TreeSet();
+    @SuppressWarnings("unchecked")
+    public SortedSet<E> makeFullCollection() {
+        SortedSet<E> set = new TreeSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
-        return TransformedSortedSet.decorate(set, TestTransformedCollection.NOOP_TRANSFORMER);
+        return TransformedSortedSet.decorate(set, (Transformer<E, E>) TestTransformedCollection.NOOP_TRANSFORMER);
     }
-    
-    //-----------------------------------------------------------------------   
+
+    //-----------------------------------------------------------------------
+    @SuppressWarnings("unchecked")
     public void testTransformedSet() {
-        Set set = TransformedSortedSet.decorate(new HashSet(), TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
+        SortedSet<E> set = TransformedSortedSet.decorate(new TreeSet<E>(),
+                (Transformer<E, E>) TestTransformedCollection.STRING_TO_INTEGER_TRANSFORMER);
         assertEquals(0, set.size());
-        Object[] els = new Object[] {"1", "3", "5", "7", "2", "4", "6"};
+        E[] els = (E[]) new Object[] { "1", "3", "5", "7", "2", "4", "6" };
         for (int i = 0; i < els.length; i++) {
             set.add(els[i]);
             assertEquals(i + 1, set.size());
             assertEquals(true, set.contains(new Integer((String) els[i])));
-            assertEquals(false, set.contains(els[i]));
+            assertNotCollectionContains(set, els[i]);
         }
-        
-        assertEquals(false, set.remove(els[0]));
+
+        assertNotRemoveFromCollection(set, els[0]);
         assertEquals(true, set.remove(new Integer((String) els[0])));
-        
-    } 
+    }
 
     public String getCompatibilityVersion() {
         return "3.1";

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -25,44 +25,44 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSet} for exercising the 
+ * Extension of {@link AbstractTestSet} for exercising the
  * {@link UnmodifiableSet} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestUnmodifiableSet extends AbstractTestSet{
-    
+public class TestUnmodifiableSet<E> extends AbstractTestSet<E> {
+
     public TestUnmodifiableSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestUnmodifiableSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-    //-------------------------------------------------------------------  
-    public Set makeEmptySet() {
-        return UnmodifiableSet.decorate(new HashSet());
-    }
-    
-    public Set makeFullSet() {
-        HashSet set = new HashSet();
+
+    //-------------------------------------------------------------------
+    public Set<E> makeObject() {
+        return UnmodifiableSet.decorate(new HashSet<E>());
+    }
+
+    public Set<E> makeFullCollection() {
+        HashSet<E> set = new HashSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
         return UnmodifiableSet.decorate(set);
     }
-    
+
     public boolean isAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }

Modified: commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java?rev=738956&r1=738955&r2=738956&view=diff
==============================================================================
--- commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java
(original)
+++ commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/set/TestUnmodifiableSortedSet.java
Thu Jan 29 18:48:37 2009
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You 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.
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 import java.util.Comparator;
 import java.util.Set;
+import java.util.SortedSet;
 import java.util.TreeSet;
 
 import junit.framework.Test;
@@ -27,81 +28,83 @@
 import org.apache.commons.collections.BulkTest;
 
 /**
- * Extension of {@link AbstractTestSortedSet} for exercising the 
+ * Extension of {@link AbstractTestSortedSet} for exercising the
  * {@link UnmodifiableSortedSet} implementation.
  *
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
- * 
+ *
  * @author Phil Steitz
  */
-public class TestUnmodifiableSortedSet extends AbstractTestSortedSet{
-    
+public class TestUnmodifiableSortedSet<E> extends AbstractTestSortedSet<E> {
+    protected UnmodifiableSortedSet<E> set = null;
+    protected ArrayList<E> array = null;
+
     public TestUnmodifiableSortedSet(String testName) {
         super(testName);
     }
-    
+
     public static Test suite() {
         return BulkTest.makeSuite(TestUnmodifiableSortedSet.class);
     }
-    
+
     public static void main(String args[]) {
         String[] testCaseName = { TestUnmodifiableSortedSet.class.getName()};
         junit.textui.TestRunner.main(testCaseName);
     }
-    
-    //-------------------------------------------------------------------  
-    public Set makeEmptySet() {
-        return UnmodifiableSortedSet.decorate(new TreeSet());
-    }
-    
-    public Set makeFullSet() {
-        TreeSet set = new TreeSet();
+
+    //-------------------------------------------------------------------
+    public SortedSet<E> makeObject() {
+        return UnmodifiableSortedSet.decorate(new TreeSet<E>());
+    }
+
+    public UnmodifiableSortedSet<E> makeFullCollection() {
+        TreeSet<E> set = new TreeSet<E>();
         set.addAll(Arrays.asList(getFullElements()));
-        return UnmodifiableSortedSet.decorate(set);
+        return (UnmodifiableSortedSet<E>) UnmodifiableSortedSet.decorate(set);
     }
-    
+
     public boolean isAddSupported() {
         return false;
     }
-    
+
     public boolean isRemoveSupported() {
         return false;
     }
-           
+
     //--------------------------------------------------------------------
-    protected UnmodifiableSortedSet set = null;
-    protected ArrayList array = null;
-    
+    @SuppressWarnings("unchecked")
     protected void setupSet() {
-        set = (UnmodifiableSortedSet) makeFullSet();
-        array = new ArrayList();
-        array.add(new Integer(1));
+        set = makeFullCollection();
+        array = new ArrayList<E>();
+        array.add((E) new Integer(1));
     }
-    
-    /** 
+
+    /**
      * Verify that base set and subsets are not modifiable
      */
+    @SuppressWarnings("unchecked")
     public void testUnmodifiable() {
         setupSet();
         verifyUnmodifiable(set);
-        verifyUnmodifiable(set.headSet(new Integer(1)));
-        verifyUnmodifiable(set.tailSet(new Integer(1)));
-        verifyUnmodifiable(set.subSet(new Integer(1), new Integer(3)));    
+        verifyUnmodifiable(set.headSet((E) new Integer(1)));
+        verifyUnmodifiable(set.tailSet((E) new Integer(1)));
+        verifyUnmodifiable(set.subSet((E) new Integer(1), (E) new Integer(3)));
     }
-    
+
     /**
      * Verifies that a set is not modifiable
      */
-    public void verifyUnmodifiable(Set set) {
+    @SuppressWarnings("unchecked")
+    public void verifyUnmodifiable(Set<E> set) {
         try {
-            set.add("value");
+            set.add((E) "value");
             fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
-            // expected  
+            // expected
         }
         try {
-            set.addAll(new TreeSet());
+            set.addAll(new TreeSet<E>());
             fail("Expecting UnsupportedOperationException.");
         } catch (UnsupportedOperationException e) {
             // expected
@@ -131,10 +134,10 @@
             // expected
         }
     }
-    
+
     public void testComparator() {
         setupSet();
-        Comparator c = set.comparator();
+        Comparator<? super E> c = set.comparator();
         assertTrue("natural order, so comparator should be null", c == null);
     }
 



Mime
View raw message