harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r462599 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/RuleBasedCollator.java test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
Date Tue, 10 Oct 2006 22:06:45 GMT
Author: tellison
Date: Tue Oct 10 15:06:45 2006
New Revision: 462599

URL: http://svn.apache.org/viewvc?view=rev&rev=462599
Log:
Apply patch HARMONY-1352 ([classlib][text] unexpected IllegalArgumentException for RuleBasedCollator.getCollationElementIterator((String)null))

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java?view=diff&rev=462599&r1=462598&r2=462599
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/RuleBasedCollator.java
Tue Oct 10 15:06:45 2006
@@ -90,6 +90,8 @@
 	 */
 	public CollationElementIterator getCollationElementIterator(
 			CharacterIterator source) {
+		if (source == null)
+			throw new NullPointerException();
 		return new CollationElementIterator(
 				((com.ibm.icu.text.RuleBasedCollator) this.icuColl)
 						.getCollationElementIterator(source));
@@ -103,6 +105,8 @@
 	 * @return a <code>CollationElementIterator</code> for the given String
 	 */
 	public CollationElementIterator getCollationElementIterator(String source) {
+		if (source == null)
+			throw new NullPointerException();
 		return new CollationElementIterator(
 				((com.ibm.icu.text.RuleBasedCollator) this.icuColl)
 						.getCollationElementIterator(source));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java?view=diff&rev=462599&r1=462598&r2=462599
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java
Tue Oct 10 15:06:45 2006
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.text.tests.java.text;
 
+import java.text.CharacterIterator;
 import java.text.CollationElementIterator;
 import java.text.CollationKey;
 import java.text.Collator;
@@ -121,7 +122,7 @@
      * Class under test for java.text.CollationElementIterator
      * getCollationElementIterator(java.lang.String)
      */
-    public void testGetCollationElementIteratorString() {
+    public void testGetCollationElementIteratorString() throws Exception {
         {
             Locale locale = new Locale("es", "", "TRADITIONAL");
             RuleBasedCollator coll = (RuleBasedCollator) Collator
@@ -157,13 +158,20 @@
                 assertEquals(e_offset[i++], offset);
             }
         }
+        //Regression for HARMONY-1352
+        try {
+            new RuleBasedCollator("< a< b< c< d").getCollationElementIterator((String)null);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+            //expected
+        }
     }
 
     /*
      * Class under test for java.text.CollationElementIterator
      * getCollationElementIterator(java.text.CharacterIterator)
      */
-    public void testGetCollationElementIteratorCharacterIterator() {
+    public void testGetCollationElementIteratorCharacterIterator() throws Exception {
         {
             Locale locale = new Locale("es", "", "TRADITIONAL");
             RuleBasedCollator coll = (RuleBasedCollator) Collator
@@ -201,6 +209,13 @@
                 offset = iterator.getOffset();
                 assertEquals(e_offset[i++], offset);
             }
+        }
+        //Regression for HARMONY-1352
+        try {
+            new RuleBasedCollator("< a< b< c< d").getCollationElementIterator((CharacterIterator)null);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+            //expected
         }
     }
 



Mime
View raw message