harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r446515 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/
Date Fri, 15 Sep 2006 04:35:55 GMT
Author: ndbeyer
Date: Thu Sep 14 21:35:55 2006
New Revision: 446515

URL: http://svn.apache.org/viewvc?view=rev&rev=446515
Log:
Cleanup compiler warnings and JUnit API usage.

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArraysTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DateTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/VectorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/WeakHashMapTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArraysTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArraysTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArraysTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/ArraysTest.java
Thu Sep 14 21:35:55 2006
@@ -117,12 +117,13 @@
 	public void test_sort$D() {
 		// Test a basic sort
 		double[] reversedArray = new double[100];
-		for (int counter = 0; counter < reversedArray.length; counter ++)
-			reversedArray[counter] = (double)(reversedArray.length - counter - 1);
+		for (int counter = 0; counter < reversedArray.length; counter ++) {
+            reversedArray[counter] = (reversedArray.length - counter - 1);
+        }
 		Arrays.sort(reversedArray);
 		for (int counter = 0; counter < reversedArray.length; counter ++) {
 			assertTrue("Assert 0: Resulting array not sorted",
-					reversedArray[counter] == (double)counter);
+					reversedArray[counter] == counter);
 		}
 
 		// These have to sort as per the Double compare ordering
@@ -140,8 +141,9 @@
 
 		Arrays.sort(specials2);
 		Object[] print2 = new Object[specials2.length];
-		for (int i = 0; i < specials2.length; i++)
-			print2[i] = new Double(specials2[i]);
+		for (int i = 0; i < specials2.length; i++) {
+            print2[i] = new Double(specials2[i]);
+        }
 		assertTrue("Assert 2: specials sort incorrectly " + Arrays.asList(print2), 
 				Arrays.equals(specials2, answer));
 	}
@@ -153,12 +155,12 @@
 		// Test a basic sort
 		float[] reversedArray = new float[100];
 		for (int counter = 0; counter < reversedArray.length; counter ++) {
-			reversedArray[counter] = (float)(reversedArray.length - counter - 1);
+			reversedArray[counter] = (reversedArray.length - counter - 1);
 		}
 		Arrays.sort(reversedArray);
 		for (int counter = 0; counter < reversedArray.length; counter ++) {
 			assertTrue("Assert 0: Resulting array not sorted",
-					reversedArray[counter] == (float)counter);
+					reversedArray[counter] == counter);
 		}
 
 		float[] specials1 = new float[]{Float.NaN, Float.MAX_VALUE, Float.MIN_VALUE, 0f, -0f, Float.POSITIVE_INFINITY,
Float.NEGATIVE_INFINITY};

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/CollectionsTest.java
Thu Sep 14 21:35:55 2006
@@ -55,7 +55,7 @@
 	 */
 	public void test_binarySearchLjava_util_ListLjava_lang_ObjectLjava_util_Comparator() {
 		// Regression for HARMONY-94
-		LinkedList lst = new LinkedList();
+		LinkedList<Integer> lst = new LinkedList<Integer>();
 		lst.add(new Integer(30));
 		Collections.sort(lst, null);
 		int index = Collections.binarySearch(lst, new Integer(2), null);
@@ -66,7 +66,8 @@
 	 * @tests java.util.Collections#binarySearch(java.util.List,
 	 *        java.lang.Object)
 	 */
-	public void test_binarySearchLjava_util_ListLjava_lang_Object() {
+	@SuppressWarnings("unchecked")
+    public void test_binarySearchLjava_util_ListLjava_lang_Object() {
 		// regression for Harmony-1367
 		List localList = new LinkedList();
 		assertEquals(-1, Collections.binarySearch(localList, new Object()));
@@ -84,10 +85,10 @@
 	 */
 	public void test_rotateLjava_util_ListI() {
 		// Regression for HARMONY-19 Rotate an *empty* list
-		Collections.rotate(new ArrayList(), 25);
+		Collections.rotate(new ArrayList<Object>(), 25);
 
 		// Regression for HARMONY-20
-		List list = new ArrayList();
+		List<String> list = new ArrayList<String>();
 		list.add(0, "zero");
 		list.add(1, "one");
 		list.add(2, "two");
@@ -96,15 +97,15 @@
 
 		Collections.rotate(list, Integer.MIN_VALUE);
 		assertEquals("Rotated incorrectly at position 0, ", "three",
-				(String) list.get(0));
+				list.get(0));
 		assertEquals("Rotated incorrectly at position 1, ", "four",
-				(String) list.get(1));
+				list.get(1));
 		assertEquals("Rotated incorrectly at position 2, ", "zero",
-				(String) list.get(2));
+				list.get(2));
 		assertEquals("Rotated incorrectly at position 3, ", "one",
-				(String) list.get(3));
+				list.get(3));
 		assertEquals("Rotated incorrectly at position 4, ", "two",
-				(String) list.get(4));
+				list.get(4));
 	}
 
 	/**
@@ -246,7 +247,7 @@
             fail("Assert 0: frequency(null,<any>) must throw NPE");
         } catch (NullPointerException e) {}
 
-        List strings = Arrays.asList(new String[] { "1", "2", "3", "1", "1" });
+        List<String> strings = Arrays.asList(new String[] { "1", "2", "3", "1", "1"
});
 
         assertEquals("Assert 1: did not find three \"1\" strings", 3,
                 Collections.frequency(strings, "1"));
@@ -260,7 +261,7 @@
         assertEquals("Assert 4: matched on null when there are none", 0,
                 Collections.frequency(strings, null));
 
-        List objects = Arrays.asList(new Object[] { new Integer(1), null, null,
+        List<Object> objects = Arrays.asList(new Object[] { new Integer(1), null, null,
                 new Long(1) });
 
         assertEquals("Assert 5: did not find one Integer(1)", 1, Collections
@@ -277,7 +278,7 @@
      * @tests java.util.Collections#reverseOrder()
      */
     public void test_reverseOrder() {
-        Comparator roc = Collections.reverseOrder();
+        Comparator<String> roc = Collections.reverseOrder();
         assertNotNull("Assert 0: comparator must not be null", roc);
 
         assertTrue("Assert 1: comparator must implement Serializable",
@@ -294,7 +295,7 @@
      * @tests java.util.Collections#reverseOrder(java.util.Comparator)
      */
     public void test_reverseOrderLjava_util_Comparator() {
-        Comparator roc = Collections
+        Comparator<String> roc = Collections
                 .reverseOrder(String.CASE_INSENSITIVE_ORDER);
         assertNotNull("Assert 0: comparator must not be null", roc);
 
@@ -320,7 +321,7 @@
     }
 
     public void test_AddAll() {
-        List l = new ArrayList();
+        List<Object> l = new ArrayList<Object>();
         assertFalse(Collections.addAll(l, new Object[] {}));
         assertTrue(l.isEmpty());
         assertTrue(Collections.addAll(l, new Object[] { new Integer(1),
@@ -339,48 +340,48 @@
         for (int i = 0; i < arr2.length; i++) {
             arr2[i] = new Integer(100 + i);
         }
-        Collection c1 = new ArrayList();
-        Collection c2 = new ArrayList();
+        Collection<Object> c1 = new ArrayList<Object>();
+        Collection<Object> c2 = new ArrayList<Object>();
         Collections.addAll(c1, arr1);
         Collections.addAll(c2, arr2);
         assertTrue(Collections.disjoint(c1, c2));
         c1.add(arr2[10]);
         assertFalse(Collections.disjoint(c1, c2));
 
-        c1 = new LinkedList();
-        c2 = new LinkedList();
+        c1 = new LinkedList<Object>();
+        c2 = new LinkedList<Object>();
         Collections.addAll(c1, arr1);
         Collections.addAll(c2, arr2);
         assertTrue(Collections.disjoint(c1, c2));
         c1.add(arr2[10]);
         assertFalse(Collections.disjoint(c1, c2));
 
-        c1 = new TreeSet();
-        c2 = new TreeSet();
+        c1 = new TreeSet<Object>();
+        c2 = new TreeSet<Object>();
         Collections.addAll(c1, arr1);
         Collections.addAll(c2, arr2);
         assertTrue(Collections.disjoint(c1, c2));
         c1.add(arr2[10]);
         assertFalse(Collections.disjoint(c1, c2));
 
-        c1 = new HashSet();
-        c2 = new HashSet();
+        c1 = new HashSet<Object>();
+        c2 = new HashSet<Object>();
         Collections.addAll(c1, arr1);
         Collections.addAll(c2, arr2);
         assertTrue(Collections.disjoint(c1, c2));
         c1.add(arr2[10]);
         assertFalse(Collections.disjoint(c1, c2));
 
-        c1 = new LinkedList();
-        c2 = new TreeSet();
+        c1 = new LinkedList<Object>();
+        c2 = new TreeSet<Object>();
         Collections.addAll(c1, arr1);
         Collections.addAll(c2, arr2);
         assertTrue(Collections.disjoint(c1, c2));
         c1.add(arr2[10]);
         assertFalse(Collections.disjoint(c1, c2));
 
-        c1 = new Vector();
-        c2 = new HashSet();
+        c1 = new Vector<Object>();
+        c2 = new HashSet<Object>();
         Collections.addAll(c1, arr1);
         Collections.addAll(c2, arr2);
         assertTrue(Collections.disjoint(c1, c2));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DateTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DateTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DateTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/DateTest.java
Thu Sep 14 21:35:55 2006
@@ -24,7 +24,8 @@
 	/**
 	 * @tests java.util.Date#parse(String)
 	 */
-	public void test_parseLjava_lang_String() {
+	@SuppressWarnings("deprecation")
+    public void test_parseLjava_lang_String() {
 		// Regression for HARMONY-102
 		assertEquals("Assert 0: parse failure",
 				-5400000, Date.parse("Sat, 1 Jan 1970 +0130 00:00:00"));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IdentityHashMapTest.java
Thu Sep 14 21:35:55 2006
@@ -26,7 +26,7 @@
 	 * @tests java.util.IdentityHashMap#put(java.lang.Object, java.lang.Object)
 	 */
 	public void test_putLjava_lang_ObjectLjava_lang_Object() {
-		IdentityHashMap map = new IdentityHashMap();
+		IdentityHashMap<Object, Object> map = new IdentityHashMap<Object, Object>();
 		
 		// Test null as a key.
 		Object value = "Some value";
@@ -44,7 +44,7 @@
 	 */
 	public void test_removeLjava_lang_Object() {
 		// Regression for HARMONY-37
-		IdentityHashMap hashMap = new IdentityHashMap();
+		IdentityHashMap<String, String> hashMap = new IdentityHashMap<String, String>();
 		hashMap.remove("absent");
 		assertEquals("Assert 0: Size is incorrect", 0, hashMap.size());
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/IllegalFormatConversionExceptionTest.java
Thu Sep 14 21:35:55 2006
@@ -43,7 +43,7 @@
      */
     public void test_getArgumentClass() {
         char c = '*';
-        Class argClass = String.class;
+        Class<String> argClass = String.class;
         IllegalFormatConversionException illegalFormatConversionException = new IllegalFormatConversionException(
                 c, argClass);
         assertEquals(argClass, illegalFormatConversionException
@@ -56,7 +56,7 @@
      */
     public void test_getConversion() {
         char c = '*';
-        Class argClass = String.class;
+        Class<String> argClass = String.class;
         IllegalFormatConversionException illegalFormatConversionException = new IllegalFormatConversionException(
                 c, argClass);
         assertEquals(c, illegalFormatConversionException.getConversion());
@@ -68,7 +68,7 @@
      */
     public void test_getMessage() {
         char c = '*';
-        Class argClass = String.class;
+        Class<String> argClass = String.class;
         IllegalFormatConversionException illegalFormatConversionException = new IllegalFormatConversionException(
                 c, argClass);
         assertTrue(null != illegalFormatConversionException.getMessage());

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/InputMismatchExceptionTest.java
Thu Sep 14 21:35:55 2006
@@ -29,6 +29,7 @@
     /**
      * @tests java.util.InputMismatchException#InputMismatchException()
      */
+    @SuppressWarnings("cast")
     public void test_Constructor() {
         InputMismatchException exception = new InputMismatchException();
         assertNotNull(exception);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/VectorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/VectorTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/VectorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/VectorTest.java
Thu Sep 14 21:35:55 2006
@@ -26,10 +26,10 @@
 	 */
 	public void test_toString() {
 		// Ensure toString works with self-referencing elements.
-		Vector vec = new Vector(3);
+		Vector<Object> vec = new Vector<Object>(3);
 		vec.add(null);
 		vec.add(new Object());
 		vec.add(vec);
-		vec.toString();
+		assertNotNull(vec.toString());
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/WeakHashMapTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/WeakHashMapTest.java?view=diff&rev=446515&r1=446514&r2=446515
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/WeakHashMapTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/util/WeakHashMapTest.java
Thu Sep 14 21:35:55 2006
@@ -34,7 +34,7 @@
 	 * @tests java.util.WeakHashMap#entrySet()
 	 */
 	public void test_entrySet() {
-		WeakHashMap weakMap = new WeakHashMap();
+		WeakHashMap<Object, Object> weakMap = new WeakHashMap<Object, Object>();
 		KEY_ARRAY = new Object[100];
 		VALUE_ARRAY = new Object[100];
 		for (int i = 0; i < 100; i++) {
@@ -43,16 +43,16 @@
 			weakMap.put(KEY_ARRAY[i], VALUE_ARRAY[i]);
 		}
 
-		List keys = Arrays.asList(KEY_ARRAY);
-		List values = Arrays.asList(VALUE_ARRAY);
+		List<Object> keys = Arrays.asList(KEY_ARRAY);
+		List<Object> values = Arrays.asList(VALUE_ARRAY);
 
 		// Check the entry set has correct size & content
-		Set entrySet = weakMap.entrySet();
+		Set<Map.Entry<Object, Object>> entrySet = weakMap.entrySet();
 		assertEquals("Assert 0: Incorrect number of entries returned", 100,
 				entrySet.size());
-		Iterator it = entrySet.iterator();
+		Iterator<Map.Entry<Object, Object>> it = entrySet.iterator();
 		while (it.hasNext()) {
-			Map.Entry entry = (Map.Entry) it.next();
+			Map.Entry<Object, Object> entry = it.next();
 			assertTrue("Assert 1: Invalid map entry key returned", keys
 					.contains(entry.getKey()));
 			assertTrue("Assert 2: Invalid map entry value returned", values
@@ -93,8 +93,9 @@
 			it.next();
 			it.remove();
 			size--;
-			if (it.hasNext())
-				it.next();
+			if (it.hasNext()) {
+                it.next();
+            }
 
 		}
 		assertEquals("Assert 6: entry set count mismatch", size, entrySet



Mime
View raw message