harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r768935 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/StringTokenizer.java test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java
Date Mon, 27 Apr 2009 11:41:37 GMT
Author: tellison
Date: Mon Apr 27 11:41:37 2009
New Revision: 768935

URL: http://svn.apache.org/viewvc?rev=768935&view=rev
Log:
Apply patch for HARMONY-6142 ([classlib][luni] java.util.StringTokenizer.nextToken(String
delim) should throw NullPointerException when the given delim is null)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java?rev=768935&r1=768934&r2=768935&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/StringTokenizer.java
Mon Apr 27 11:41:37 2009
@@ -124,6 +124,9 @@
      * @return true if unprocessed tokens remain
      */
     public boolean hasMoreTokens() {
+        if (delimiters == null) {
+            throw new NullPointerException();
+        }
         int length = string.length();
         if (position < length) {
             if (returnDelimiters)
@@ -157,6 +160,9 @@
      *                if no tokens remain
      */
     public String nextToken() {
+        if (delimiters == null) {
+            throw new NullPointerException();
+        }
         int i = position;
         int length = string.length();
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java?rev=768935&r1=768934&r2=768935&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/StringTokenizerTest.java
Mon Apr 27 11:41:37 2009
@@ -167,6 +167,92 @@
 				"es", st.nextToken());
 	}
 
+    public void test_hasMoreElements_NPE() {
+        StringTokenizer stringTokenizer = new StringTokenizer(new String(),
+                (String) null, true);
+        try {
+            stringTokenizer.hasMoreElements();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        stringTokenizer = new StringTokenizer(new String(), (String) null);
+        try {
+            stringTokenizer.hasMoreElements();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_hasMoreTokens_NPE() {
+        StringTokenizer stringTokenizer = new StringTokenizer(new String(),
+                (String) null, true);
+        try {
+            stringTokenizer.hasMoreTokens();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        stringTokenizer = new StringTokenizer(new String(), (String) null);
+        try {
+            stringTokenizer.hasMoreTokens();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_nextElement_NPE() {
+        StringTokenizer stringTokenizer = new StringTokenizer(new String(),
+                (String) null, true);
+        try {
+            stringTokenizer.nextElement();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        stringTokenizer = new StringTokenizer(new String(), (String) null);
+        try {
+            stringTokenizer.nextElement();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_nextToken_NPE() {
+        StringTokenizer stringTokenizer = new StringTokenizer(new String(),
+                (String) null, true);
+        try {
+            stringTokenizer.nextToken();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+
+        stringTokenizer = new StringTokenizer(new String(), (String) null);
+        try {
+            stringTokenizer.nextToken();
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
+    public void test_nextTokenLjava_lang_String_NPE() {
+        StringTokenizer stringTokenizer = new StringTokenizer(new String());
+        try {
+            stringTokenizer.nextToken(null);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // Expected
+        }
+    }
+
 	/**
 	 * Sets up the fixture, for example, open a network connection. This method
 	 * is called before a test is executed.



Mime
View raw message