harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From smish...@apache.org
Subject svn commit: r449633 - /incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java
Date Mon, 25 Sep 2006 10:25:03 GMT
Author: smishura
Date: Mon Sep 25 03:25:02 2006
New Revision: 449633

URL: http://svn.apache.org/viewvc?view=rev&rev=449633
Log:
Add toString() testing
(relates to HARMONY-1522: [classlib][util] unexpected NPE for java.util.AbstractCollection.toString)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java?view=diff&rev=449633&r1=449632&r2=449633
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/AbstractCollectionTest.java
Mon Sep 25 03:25:02 2006
@@ -15,9 +15,11 @@
 
 package tests.api.java.util;
 
+import java.util.AbstractCollection;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.Iterator;
 
 public class AbstractCollectionTest extends junit.framework.TestCase {
 
@@ -167,6 +169,33 @@
             assertTrue("Duplicate found at i = " + i, !duplicates
                     .contains(intArray[i]));
             duplicates.add(intArray[i]);
+        }
+    }
+
+    /**
+     * @tests java.util.AbstractCollection#toString()
+     */
+    public void test_toString() {
+        // see HARMONY-1522
+        // collection that returns null iterator(this is against the spec.)
+        AbstractCollection c = new AbstractCollection() {
+            public int size() {
+                // return not zero to pass 'is empty' check
+                return 1;
+            }
+
+            public Iterator iterator() {
+                // this violates the spec.
+                return null;
+            }
+        };
+
+        try {
+            // AbstractCollection.toString() doesn't verify
+            // whether iterator() returns null value or not
+            c.toString();
+            fail("No expected NullPointerException");
+        } catch (NullPointerException e) {
         }
     }
 



Mime
View raw message