You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by mr...@apache.org on 2011/03/02 23:28:03 UTC

svn commit: r1076439 - /ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java

Author: mrisaliti
Date: Wed Mar  2 22:28:02 2011
New Revision: 1076439

URL: http://svn.apache.org/viewvc?rev=1076439&view=rev
Log:
Remove some warning in GenericTestCaseBase (OFBIZ-4102)

Modified:
    ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java

Modified: ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java?rev=1076439&r1=1076438&r2=1076439&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java (original)
+++ ofbiz/trunk/framework/base/src/org/ofbiz/base/test/GenericTestCaseBase.java Wed Mar  2 22:28:02 2011
@@ -123,9 +123,9 @@ public abstract class GenericTestCaseBas
             assertEqualsListArray(msg, wanted, got);
             return;
         }
-        if (!(got instanceof Collection)) fail(msg + "expected a collection, got a " + got.getClass());
+        if (!(got instanceof Collection<?>)) fail(msg + "expected a collection, got a " + got.getClass());
         Iterator<T> leftIt = wanted.iterator();
-        Iterator rightIt = ((Collection) got).iterator();
+        Iterator<?> rightIt = ((Collection<?>) got).iterator();
         int i = 0;
         while (leftIt.hasNext() && rightIt.hasNext()) {
             T left = leftIt.next();
@@ -142,20 +142,20 @@ public abstract class GenericTestCaseBas
     }
 
     public static <T> void assertEquals(String msg, Collection<T> wanted, Object got) {
-        if (wanted instanceof List || wanted instanceof Set) {
+        if (wanted instanceof List<?> || wanted instanceof Set<?>) {
             // list.equals(list) and set.equals(set), see docs for Collection.equals
-            if (got instanceof Set) fail("Not a collection, is a set");
-            if (got instanceof List) fail("Not a collection, is a list");
+            if (got instanceof Set<?>) fail("Not a collection, is a set");
+            if (got instanceof List<?>) fail("Not a collection, is a list");
         }
         if (wanted.equals(got)) return;
-        if (!(got instanceof Collection)) fail(msg + "not a collection");
+        if (!(got instanceof Collection<?>)) fail(msg + "not a collection");
         // Need to check the reverse, wanted may not implement equals,
         // which is the case for HashMap.values()
         if (got.equals(wanted)) return;
         msg = msg == null ? "" : msg + ' ';
         assertNotNull(msg + "expected a value", got);
         List<T> list = new ArrayList<T>(wanted);
-        Iterator rightIt = ((Collection) got).iterator();
+        Iterator<?> rightIt = ((Collection<?>) got).iterator();
 OUTER:
         while (rightIt.hasNext()) {
             Object right = rightIt.next();
@@ -182,16 +182,14 @@ OUTER:
 
     public static <T> void assertEquals(String msg, Set<T> wanted, Object got) {
         if (wanted.equals(got)) return;
-        if (!(got instanceof Set)) fail(msg + "not a set");
+        if (!(got instanceof Set<?>)) fail(msg + "not a set");
         // Need to check the reverse, wanted may not implement equals,
         // which is the case for HashMap.values()
         if (got.equals(wanted)) return;
         msg = msg == null ? "" : msg + ' ';
         assertNotNull(msg + "expected a value", got);
         Set<T> wantedSet = new HashSet<T>(wanted);
-        Set gotSet = (Set) got;
-        Iterator rightIt = ((Set) got).iterator();
-OUTER:
+        Iterator<?> rightIt = ((Set<?>) got).iterator();
         while (rightIt.hasNext()) {
             Object right = rightIt.next();
             if (wantedSet.contains(right)) {
@@ -298,8 +296,8 @@ OUTER:
     public static <T> void assertEquals(String msg, Map<T, ?> wanted, Object got) {
         msg = msg == null ? "" : msg + ' ';
         assertNotNull(msg + "expected a value", got);
-        if (!(got instanceof Map)) fail(msg + "expected a map");
-        Map<?, ?> gotMap = (Map) got;
+        if (!(got instanceof Map<?, ?>)) fail(msg + "expected a map");
+        Map<?, ?> gotMap = (Map<?, ?>) got;
         if (!got.equals(wanted)) {
             Set<T> leftKeys = new LinkedHashSet<T>(wanted.keySet());
             HashSet<Object> rightKeys = new HashSet<Object>(gotMap.keySet());