harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r418825 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/BreakIterator.java test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
Date Mon, 03 Jul 2006 18:47:43 GMT
Author: ndbeyer
Date: Mon Jul  3 11:47:43 2006
New Revision: 418825

URL: http://svn.apache.org/viewvc?rev=418825&view=rev
Log:
Apply patch for HARMONY-265: java.text.BreakIterator.get*Instance((Locale)null) behaviour

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java?rev=418825&r1=418824&r2=418825&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/BreakIterator.java
Mon Jul  3 11:47:43 2006
@@ -126,8 +126,11 @@
 	 *         given locale.
 	 */
 	public static BreakIterator getCharacterInstance(Locale where) {
-		return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
-				.getCharacterInstance(where));
+	    if (where == null)
+	        throw new NullPointerException();
+
+	    return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
+	            .getCharacterInstance(where));
 	}
 
 	/**
@@ -152,8 +155,11 @@
 	 *         given locale.
 	 */
 	public static BreakIterator getLineInstance(Locale where) {
-		return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
-				.getLineInstance(where));
+	    if (where == null)
+	        throw new NullPointerException();
+
+	    return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
+	            .getLineInstance(where));
 	}
 
 	/**
@@ -178,8 +184,11 @@
 	 *         using given locale.
 	 */
 	public static BreakIterator getSentenceInstance(Locale where) {
-		return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
-				.getSentenceInstance(where));
+	    if (where == null)
+	        throw new NullPointerException();
+
+	    return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
+	            .getSentenceInstance(where));
 	}
 
 	/**
@@ -204,8 +213,11 @@
 	 *         given locale.
 	 */
 	public static BreakIterator getWordInstance(Locale where) {
-		return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
-				.getWordInstance(where));
+	    if (where == null)
+	        throw new NullPointerException();
+
+	    return new RuleBasedBreakIterator(com.ibm.icu.text.BreakIterator
+	            .getWordInstance(where));
 	}
 
 	/**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java?rev=418825&r1=418824&r2=418825&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
Mon Jul  3 11:47:43 2006
@@ -378,6 +378,42 @@
 		assertEquals(1, MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1,
1 }, 1));
 		assertEquals(257, MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1,
1 }, 1));
 	}
+    
+	/**
+	 * @tests java.text.BreakIterator#getCharacterInstance(Locale)
+	 */
+    public void testGetCharacterInstanceLocale_NPE() {
+        // Regression for HARMONY-265
+        try {
+            BreakIterator.getCharacterInstance(null);
+            fail("BreakIterator.getCharacterInstance(null); should throw NullPointerException");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    public void testGetLineInstanceLocale_NPE() {
+        try {
+            BreakIterator.getLineInstance(null);
+            fail("BreakIterator.getLineInstance(null); should throw NullPointerException");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    public void testGetSentenceInstanceLocale_NPE() {
+        try {
+            BreakIterator.getSentenceInstance(null);
+            fail("BreakIterator.getSentenceInstance(null); should throw NullPointerException");
+        } catch (NullPointerException e) {
+        }
+    }
+
+    public void testGetWordInstanceLocale_NPE() {
+        try {
+            BreakIterator.getWordInstance(null);
+            fail("BreakIterator.getWordInstance(null); should throw NullPointerException");
+        } catch (NullPointerException e) {
+        }
+    }
 
 	private static class MockBreakIterator extends BreakIterator {
 		public static int publicGetInt(byte[] buf, int offset) {



Mime
View raw message