You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/04/25 22:03:48 UTC

svn commit: r396968 [1/5] - in /incubator/harmony/enhanced/classlib/trunk: modules/text/make/common/ modules/text/src/test/java/org/apache/harmony/tests/java/text/ modules/text/src/test/java/org/apache/harmony/tests/text/ modules/text/src/test/java/org...

Author: gharley
Date: Tue Apr 25 13:03:30 2006
New Revision: 396968

URL: http://svn.apache.org/viewcvs?rev=396968&view=rev
Log:
Merge all text tests into one package whose name meets naming convention. Other modules to follow.

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/AllTests.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/ChoiceFormatTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationElementIteratorTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollationKeyTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/CollatorTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DataFormatFieldTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/FieldPositionTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatFieldTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/MessageFormatTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatFieldTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/NumberFormatTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/ParseExceptionTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/ParsePositionTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/RuleBasedCollatorTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java   (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/StringCharacterIteratorTest.java   (with props)
Removed:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AnnotationTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/BreakIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/ChoiceFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DecimalFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/MessageFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/RuleBasedCollatorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/StringCharacterIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/text/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AnnotationTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AttributedCharacterIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AttributedStringTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/BidiTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/BreakIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/ChoiceFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/CollationElementIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/CollationKeyTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/CollatorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DateFormatFieldTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DateFormatSymbolsTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DateFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/FieldPositionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/MessageFormatFieldTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/MessageFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/NumberFormatFieldTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/NumberFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/ParseExceptionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/ParsePositionTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/RuleBasedCollatorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/SimpleDateFormatTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/StringCharacterIteratorTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/text/AllTests.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/main/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml?rev=396968&r1=396967&r2=396968&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml Tue Apr 25 13:03:30 2006
@@ -100,7 +100,7 @@
                     <exclude name="**/ChoiceFormatTest.java"/>
                     <exclude name="**/CollationKeyTest.java"/>
                     <exclude name="**/CollatorTest.java"/>
-                    <exclude name="tests/api/java/text/DecimalFormatTest.java"/>
+                    <exclude name="**/DecimalFormatTest.java"/>
                     <exclude name="**/MessageFormatTest.java"/>
                     <exclude name="**/NumberFormatTest.java"/>
                 </fileset>

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/AllTests.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/AllTests.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,38 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.text.tests;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite that includes all tests for the Text project.
+ * 
+ */
+public class AllTests {
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(AllTests.suite());
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite("All Text test suites");
+		// $JUnit-BEGIN$
+		suite.addTest(org.apache.harmony.text.tests.java.text.AllTests.suite());
+		// $JUnit-END$
+		return suite;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.harmony.text.tests.java.text;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class AllTests {
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(AllTests.suite());
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(
+				"Suite org.apache.harmony.text.tests.java.text");
+		//$JUnit-BEGIN$
+		suite.addTestSuite(AnnotationTest.class);
+		suite.addTestSuite(AttributedCharacterIteratorTest.class);
+		suite.addTestSuite(AttributedStringTest.class);
+		suite.addTestSuite(BidiTest.class);
+		suite.addTestSuite(BreakIteratorTest.class);
+        suite.addTestSuite(ChoiceFormatTest.class);
+        suite.addTestSuite(CollationElementIteratorTest.class);
+        suite.addTestSuite(CollationKeyTest.class);
+        suite.addTestSuite(CollatorTest.class);
+        suite.addTestSuite(DataFormatFieldTest.class);
+        suite.addTestSuite(DateFormatSymbolsTest.class);
+        suite.addTestSuite(DateFormatTest.class);
+        suite.addTestSuite(DecimalFormatSymbolsTest.class);
+        suite.addTestSuite(DecimalFormatTest.class);
+        suite.addTestSuite(FieldPositionTest.class);
+        suite.addTestSuite(MessageFormatFieldTest.class);
+        suite.addTestSuite(MessageFormatTest.class);
+        suite.addTestSuite(NumberFormatFieldTest.class);
+        suite.addTestSuite(NumberFormatTest.class);
+        suite.addTestSuite(ParseExceptionTest.class);
+        suite.addTestSuite(ParsePositionTest.class);
+        suite.addTestSuite(RuleBasedCollatorTest.class);
+        suite.addTestSuite(SimpleDateFormatTest.class);
+        suite.addTestSuite(StringCharacterIteratorTest.class);
+		//$JUnit-END$
+		return suite;
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AllTests.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,52 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.text.tests.java.text;
+
+import java.text.Annotation;
+
+import junit.framework.TestCase;
+
+public class AnnotationTest extends TestCase {
+
+	/**
+	 * @tests java.text.Annotation(Object)
+	 */
+	public void testAnnotation() {
+		assertNotNull(new Annotation(null));
+		assertNotNull(new Annotation("value"));
+	}
+
+	/**
+	 * @tests java.text.Annotation.getValue()
+	 */
+	public void testGetValue() {
+		Annotation a = new Annotation(null);
+		assertNull(a.getValue());
+		a = new Annotation("value");
+		assertEquals("value", a.getValue());
+	}
+
+	/**
+	 * @tests java.text.Annotation.toString()
+	 */
+	public void testToString() {
+        Annotation ant = new Annotation("HelloWorld");
+        assertTrue("toString error.", ant.toString().equals(
+                "java.text.Annotation[value=HelloWorld]"));
+		assertNotNull(new Annotation(null).toString());
+		assertNotNull(new Annotation("value").toString());
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AnnotationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,178 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.text.tests.java.text;
+
+import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
+import java.text.CharacterIterator;
+
+public class AttributedCharacterIteratorTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#current()
+	 */
+	public void test_current() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		assertTrue("Wrong first", it.current() == 'T');
+		it.next();
+		assertTrue("Wrong second", it.current() == 'e');
+		for (int i = 0; i < 9; i++)
+			it.next();
+		assertTrue("Wrong last", it.current() == 'g');
+		it.next();
+		assertTrue("Wrong final", it.current() == CharacterIterator.DONE);
+
+		it = attrString.getIterator(null, 2, 8);
+		assertTrue("Wrong first2", it.current() == 's');
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#first()
+	 */
+	public void test_first() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		assertTrue("Wrong first1", it.first() == 'T');
+		it = attrString.getIterator(null, 0, 3);
+		assertTrue("Wrong first2", it.first() == 'T');
+		it = attrString.getIterator(null, 2, 8);
+		assertTrue("Wrong first3", it.first() == 's');
+		it = attrString.getIterator(null, 11, 11);
+		assertTrue("Wrong first4", it.first() == CharacterIterator.DONE);
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#getBeginIndex()
+	 */
+	public void test_getBeginIndex() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator(null, 2, 6);
+		assertTrue("Wrong begin index", it.getBeginIndex() == 2);
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#getEndIndex()
+	 */
+	public void test_getEndIndex() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator(null, 2, 6);
+		assertTrue("Wrong begin index", it.getEndIndex() == 6);
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#getIndex()
+	 */
+	public void test_getIndex() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		assertTrue("Wrong first", it.getIndex() == 0);
+		it.next();
+		assertTrue("Wrong second", it.getIndex() == 1);
+		for (int i = 0; i < 9; i++)
+			it.next();
+		assertTrue("Wrong last", it.getIndex() == 10);
+		it.next();
+		assertTrue("Wrong final", it.getIndex() == 11);
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#last()
+	 */
+	public void test_last() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		assertTrue("Wrong last1", it.last() == 'g');
+		it = attrString.getIterator(null, 0, 3);
+		assertTrue("Wrong last2", it.last() == 's');
+		it = attrString.getIterator(null, 2, 8);
+		assertTrue("Wrong last3", it.last() == 'r');
+		it = attrString.getIterator(null, 0, 0);
+		assertTrue("Wrong last4", it.last() == CharacterIterator.DONE);
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#next()
+	 */
+	public void test_next() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		assertTrue("Wrong first", it.next() == 'e');
+		for (int i = 0; i < 8; i++)
+			it.next();
+		assertTrue("Wrong last", it.next() == 'g');
+		assertTrue("Wrong final", it.next() == CharacterIterator.DONE);
+
+		it = attrString.getIterator(null, 2, 8);
+		assertTrue("Wrong first2", it.next() == 't');
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#previous()
+	 */
+	public void test_previous() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		it.setIndex(11);
+		assertTrue("Wrong first", it.previous() == 'g');
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#setIndex(int)
+	 */
+	public void test_setIndexI() {
+		String test = "Test 23ring";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		it.setIndex(5);
+		assertTrue("Wrong first", it.current() == '2');
+	}
+
+	/**
+	 * @tests java.text.AttributedCharacterIterator#getRunLimit(java.text.AttributedCharacterIterator$Attribute)
+	 */
+	public void test_getRunLimitLjava_text_AttributedCharacterIterator$Attribute() {
+		AttributedString as = new AttributedString("test");
+		as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, "a", 2,
+				3);
+		AttributedCharacterIterator it = as.getIterator();
+		assertTrue(
+				"non-null value limit",
+				it.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 2);
+
+		as = new AttributedString("test");
+		as.addAttribute(AttributedCharacterIterator.Attribute.LANGUAGE, null,
+				2, 3);
+		it = as.getIterator();
+		assertTrue(
+				"null value limit",
+				it.getRunLimit(AttributedCharacterIterator.Attribute.LANGUAGE) == 4);
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedCharacterIteratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,43 @@
+/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.harmony.text.tests.java.text;
+
+import java.text.AttributedCharacterIterator;
+import java.text.AttributedString;
+import java.text.CharacterIterator;
+
+public class AttributedStringTest extends junit.framework.TestCase {
+
+	/**
+	 * @tests java.text.AttributedString#AttributedString(java.lang.String)
+	 */
+	public void test_ConstructorLjava_lang_String() {
+		String test = "Test string";
+		AttributedString attrString = new AttributedString(test);
+		AttributedCharacterIterator it = attrString.getIterator();
+		StringBuffer buf = new StringBuffer();
+		buf.append(it.first());
+		char ch;
+		while ((ch = it.next()) != CharacterIterator.DONE)
+			buf.append(ch);
+		assertTrue("Wrong string: " + buf, buf.toString().equals(test));
+	}
+
+	protected void setUp() {
+	}
+
+	protected void tearDown() {
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/AttributedStringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,813 @@
+/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.text.tests.java.text;
+
+import java.text.AttributedString;
+import java.text.Bidi;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class BidiTest extends TestCase {
+
+	Bidi bd;
+
+	public static void assertRunArrayEquals(int[][] expected, Bidi bidi) {
+		assertEquals("different length", expected.length, bidi.getRunCount());
+
+		FORRUN: for (int i = 0; i < bidi.getRunCount(); i++) {
+			int[] butWas = new int[] { bidi.getRunStart(i),
+					bidi.getRunLimit(i), bidi.getRunLevel(i) };
+
+			for (int j = 0; j < expected.length; j++) {
+				if (expected[j][0] == butWas[0] && expected[j][1] == butWas[1]
+						&& expected[j][2] == butWas[2]) {
+					continue FORRUN;
+				}
+			}
+			fail("expected [" + i + "] " + " start: " + butWas[0] + " limit: "
+					+ butWas[1] + " level: " + butWas[2]);
+		}
+	}
+
+	public void testNullPointerConstructor() {
+		try {
+			bd = new Bidi(null, Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			bd = new Bidi(null, 0, new byte[] { 0 }, 0, 0,
+					Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		bd = new Bidi("a".toCharArray(), 0, null, 0, 1,
+				Bidi.DIRECTION_RIGHT_TO_LEFT);
+	}
+
+	public void testBadLength() {
+		try {
+			bd = new Bidi("1".toCharArray(), 0, new byte[] { 0 }, 0, 20,
+					Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			bd = new Bidi("1234567".toCharArray(), 0, new byte[] { 0 }, 0, 4,
+					Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			bd = new Bidi("1234567".toCharArray(), 4, new byte[] { 0, 1, 2, 3,
+					4 }, 0, 5, Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			bd = new Bidi("1234567".toCharArray(), 0, new byte[] { 0, 1, 2, 3,
+					4 }, 4, 5, Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+	}
+
+	public void testEmptyParagraph() {
+		bd = new Bidi("", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(0, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 0, 0 } }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(0, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 0, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+
+		bd = new Bidi("", Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(0, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 0, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("", Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(0, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 0, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+	}
+
+	public void testSpaceParagraph() {
+		bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(" ", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+
+		bd = new Bidi(" ", Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(" ", Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+	}
+
+	public void testSimpleParagraph() {
+		bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("t", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("t", Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testBadFlags() {
+		bd = new Bidi("", 173);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(0, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 0, 0 }, }, bd);
+		assertTrue(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testBadEmbeddings() {
+		try {
+			bd = new Bidi("".toCharArray(), 0, new byte[] {}, 0, 1,
+					Bidi.DIRECTION_RIGHT_TO_LEFT);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+	}
+
+	public void testOverrideEmbeddings() {
+		bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -7,
+				(byte) -2, (byte) -3 }, 0, 3,
+				Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(7, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 7 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
+				(byte) -2, (byte) -3 }, 0, 3,
+				Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
+				(byte) -2, (byte) -3 }, 0, 3, Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) -1,
+				(byte) -2, (byte) -3 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testDefaultEmbeddings() {
+		bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) 0,
+				(byte) 0, (byte) 0 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(2, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(2, bd.getLevelAt(2));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 3, 2 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testRelativeEmbeddings() {
+		bd = new Bidi(new char[] { 's', 's', 's' }, 0, new byte[] { (byte) 1,
+				(byte) 2, (byte) 3 }, 0, 3, Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(2, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(4, bd.getLevelAt(2));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 2, 2 }, { 2, 3, 4 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testSimpleHebrewParagraph() {
+		bd = new Bidi("\u05D0", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+
+		bd = new Bidi("\u05D0", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+
+		bd = new Bidi("\u05D0", Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertFalse(bd.isMixed());
+		assertTrue(bd.isRightToLeft());
+	}
+
+	public void testSimpleBidiParagraph_1() {
+		bd = new Bidi("\u05D0a", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("\u05D0a", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("\u05D0a", Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 0 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("\u05D0a", Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testSimpleBidiParagraph_2() {
+		bd = new Bidi("a\u05D0", Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, { 1, 2, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("a\u05D0", Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, { 1, 2, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("a\u05D0", Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(0, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 0 }, { 1, 2, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi("a\u05D0", Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(2, bd.getLength());
+		assertEquals(2, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(2, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 2, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	/*
+	 * spec reads: public static final int DIRECTION_RIGHT_TO_LEFT Constant
+	 * indicating base direction is right-to-left. according to that, the method
+	 * baseIsLeftToRight() here should return false. however, RI doesn't act so.
+	 */
+	public void testRIBug_1() {
+		bd = new Bidi("t", Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		// the base level it the essential cause
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(2, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 2 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	// this is essentially the same bug as Bug_1
+	public void testRIBug_2() {
+		bd = new Bidi("\u05D0", Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(1, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(1, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testComplicatedBidi() {
+		bd = new Bidi("a\u05D0a\"a\u05D0\"\u05D0a",
+				Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(9, bd.getLength());
+		assertEquals(2, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1));
+		assertEquals(2, bd.getLevelAt(2));
+		assertEquals(2, bd.getLevelAt(3));
+		assertEquals(2, bd.getLevelAt(4));
+		assertEquals(1, bd.getLevelAt(5));
+		assertEquals(1, bd.getLevelAt(6));
+		assertEquals(1, bd.getLevelAt(7));
+		assertEquals(2, bd.getLevelAt(8));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(5, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 2, 1 },
+				{ 2, 5, 2 }, { 5, 8, 1 }, { 8, 9, 2 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testComplicatedOverrideBidi() {
+		bd = new Bidi("a\u05D0a\"a\u05D0\"\u05D0a".toCharArray(), 0,
+				new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9,
+				Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(9, bd.getLength());
+		assertEquals(2, bd.getLevelAt(0));
+		assertEquals(1, bd.getLevelAt(1));
+		assertEquals(2, bd.getLevelAt(2));
+		assertEquals(3, bd.getLevelAt(3));
+		assertEquals(3, bd.getLevelAt(4));
+		assertEquals(3, bd.getLevelAt(5));
+		assertEquals(2, bd.getLevelAt(6));
+		assertEquals(1, bd.getLevelAt(7));
+		assertEquals(4, bd.getLevelAt(8));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(7, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 2, 1 },
+				{ 2, 3, 2 }, { 3, 6, 3 }, { 6, 7, 2 }, { 7, 8, 1 },
+				{ 8, 9, 4 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testRequiresBidi() {
+		assertFalse(Bidi.requiresBidi(null, 0, 0));
+
+		try {
+			assertFalse(Bidi.requiresBidi(null, 0, 1));
+			fail("should throw NPE");
+		} catch (NullPointerException e) {
+			// expected
+		}
+		try {
+			assertFalse(Bidi.requiresBidi("".toCharArray(), 0, 1));
+			fail("should throw ArrayIndexOutOfBoundsException");
+		} catch (ArrayIndexOutOfBoundsException e) {
+			// expected
+		}
+		try {
+			assertFalse(Bidi.requiresBidi("".toCharArray(), -1, 1));
+			fail("should throw ArrayIndexOutOfBoundsException");
+		} catch (ArrayIndexOutOfBoundsException e) {
+			// expected
+		}
+		try {
+			assertFalse(Bidi.requiresBidi("".toCharArray(), 1, 2));
+			fail("should throw ArrayIndexOutOfBoundsException");
+		} catch (ArrayIndexOutOfBoundsException e) {
+			// expected
+		}
+		try {
+			assertFalse(Bidi.requiresBidi("".toCharArray(), 4, 5));
+			fail("should throw ArrayIndexOutOfBoundsException");
+		} catch (ArrayIndexOutOfBoundsException e) {
+			// expected
+		}
+		assertFalse(Bidi.requiresBidi("".toCharArray(), 7, 7));
+		assertFalse(Bidi.requiresBidi(" ".toCharArray(), 0, 1));
+		assertFalse(Bidi.requiresBidi("\u05D0".toCharArray(), 1, -1));
+		assertFalse(Bidi.requiresBidi("\u05D0".toCharArray(), -1, -2));
+		assertFalse(Bidi.requiresBidi("\u05D0".toCharArray(), 4, 4));
+		assertFalse(Bidi.requiresBidi("\u05D0".toCharArray(), 3, 1));
+		assertTrue(Bidi.requiresBidi("\u05D0".toCharArray(), 0, 1));
+	}
+
+	public void testHebrewOverrideEmbeddings() {
+		bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
+				new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
+				Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
+				new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
+				Bidi.DIRECTION_DEFAULT_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
+				new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
+				Bidi.DIRECTION_LEFT_TO_RIGHT);
+		assertTrue(bd.baseIsLeftToRight());
+		assertEquals(0, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(0, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+
+		bd = new Bidi(new char[] { '\u05D0', '\u05D0', '\u05D0' }, 0,
+				new byte[] { (byte) -1, (byte) -2, (byte) -3 }, 0, 3,
+				Bidi.DIRECTION_RIGHT_TO_LEFT);
+		assertFalse(bd.baseIsLeftToRight());
+		assertEquals(1, bd.getBaseLevel());
+		assertEquals(3, bd.getLength());
+		assertEquals(1, bd.getLevelAt(0));
+		assertEquals(2, bd.getLevelAt(1));
+		assertEquals(3, bd.getLevelAt(2));
+		assertEquals(1, bd.getLevelAt(1000));
+		assertEquals(3, bd.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 1 }, { 1, 2, 2 },
+				{ 2, 3, 3 }, }, bd);
+		assertFalse(bd.isLeftToRight());
+		assertTrue(bd.isMixed());
+		assertFalse(bd.isRightToLeft());
+	}
+
+	public void testCreateLineBidi() {
+		bd = new Bidi("a\u05D0a\na\u05D0\"\u05D0a".toCharArray(), 0,
+				new byte[] { 0, 0, 0, -3, -3, 2, 2, 0, 3 }, 0, 9,
+				Bidi.DIRECTION_RIGHT_TO_LEFT);
+		Bidi line = bd.createLineBidi(2, 7);
+		assertFalse(line.baseIsLeftToRight());
+		assertEquals(1, line.getBaseLevel());
+		assertEquals(5, line.getLength());
+		assertEquals(2, line.getLevelAt(0));
+		assertEquals(1, line.getLevelAt(1));
+		assertEquals(3, line.getLevelAt(2));
+		assertEquals(3, line.getLevelAt(3));
+		assertEquals(2, line.getLevelAt(4));
+		assertEquals(1, line.getLevelAt(1000));
+		assertEquals(4, line.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 1, 2 }, { 1, 2, 1 },
+				{ 2, 4, 3 }, { 4, 5, 2 }, }, line);
+		assertFalse(line.isLeftToRight());
+		assertTrue(line.isMixed());
+		assertFalse(line.isRightToLeft());
+	}
+
+	public void testIncompatibleLineAlgorithm() {
+		// ICU treat a new line as in the same run, however RI does not
+		bd = new Bidi("aaaaa".toCharArray(), 0,
+				new byte[] { -2, -1, -3, -3, -2 }, 0, 5,
+				Bidi.DIRECTION_RIGHT_TO_LEFT);
+		Bidi line = bd.createLineBidi(1, 4);
+		assertFalse(line.baseIsLeftToRight());
+		assertEquals(1, line.getBaseLevel());
+		assertEquals(3, line.getLength());
+		assertEquals(1, line.getLevelAt(0));
+		assertEquals(1, line.getLevelAt(1));
+		assertEquals(1, line.getLevelAt(2));
+		assertEquals(1, line.getLevelAt(1000));
+		assertEquals(1, line.getRunCount());
+		assertRunArrayEquals(new int[][] { { 0, 3, 1 }, }, line);
+		assertFalse(line.isLeftToRight());
+		assertFalse(line.isMixed());
+		assertTrue(line.isRightToLeft());
+	}
+
+	public void testReorderVisually() {
+		String[] init = new String[] { "a", "b", "c", "d" };
+		String[] s = new String[4];
+
+		System.arraycopy(init, 0, s, 0, s.length);
+		Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 0, s, 0, 4);
+		assertEquals("[c, b, a, d]", Arrays.asList(s).toString());
+
+		System.arraycopy(init, 0, s, 0, s.length);
+		Bidi.reorderVisually(new byte[] { 1, 3 }, 0, s, 1, 2);
+		assertEquals("[a, c, b, d]", Arrays.asList(s).toString());
+
+		System.arraycopy(init, 0, s, 0, s.length);
+		Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 1, s, 1, 2);
+		assertEquals("[a, c, b, d]", Arrays.asList(s).toString());
+
+		System.arraycopy(init, 0, s, 0, s.length);
+		Bidi.reorderVisually(new byte[] { 2, 1, 2, 1 }, 1, s, 0, 3);
+		assertEquals("[c, b, a, d]", Arrays.asList(s).toString());
+
+		System.arraycopy(init, 0, s, 0, s.length);
+		Bidi.reorderVisually(new byte[] { 2, 1, 0, 1 }, 1, s, 0, 3);
+		assertEquals("[a, b, c, d]", Arrays.asList(s).toString());
+	}
+
+	public void testBadReorderVisually() {
+		String[] s = new String[] { "a", "b", "c", "d" };
+
+		try {
+			Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 0, s, 0, 5);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 0, s, -1, 1);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, -1, s, 0, 1);
+			fail("should throw IAE");
+		} catch (IllegalArgumentException e) {
+			// expected
+		}
+
+		try {
+			Bidi.reorderVisually(null, 0, s, 0, 1);
+			fail("should throw NPE");
+		} catch (NullPointerException e) {
+			// expected
+		}
+
+		try {
+			Bidi.reorderVisually(new byte[] { 2, 1, 3, 0 }, 0, null, 0, 1);
+			fail("should throw NPE");
+		} catch (NullPointerException e) {
+			// expected
+		}
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BidiTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java?rev=396968&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java Tue Apr 25 13:03:30 2006
@@ -0,0 +1,430 @@
+/*
+ * Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ * 
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package org.apache.harmony.text.tests.java.text;
+
+import java.text.BreakIterator;
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+public class BreakIteratorTest extends TestCase {
+
+    private static final String TEXT = "a\u0308abc def, gh-12i?jkl.mno?";
+
+    BreakIterator iterator;
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        iterator = BreakIterator.getCharacterInstance(Locale.US);
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testConsts() {
+        assertEquals(-1, BreakIterator.DONE);
+    }
+
+    public void testCache() {
+        BreakIterator newOne = BreakIterator.getCharacterInstance(Locale.US);
+        assertNotSame(newOne, iterator);
+        assertEquals(newOne, iterator);
+
+        newOne = BreakIterator.getCharacterInstance();
+        assertEquals(newOne, iterator);
+
+        newOne = BreakIterator.getCharacterInstance(Locale.CHINA);
+        assertEquals(newOne, iterator);
+
+        BreakIterator wordIterator = BreakIterator.getWordInstance();
+        assertFalse(wordIterator.equals(iterator));
+
+        BreakIterator lineIterator = BreakIterator.getLineInstance();
+        assertFalse(lineIterator.equals(iterator));
+
+        BreakIterator senteIterator = BreakIterator.getSentenceInstance();
+        assertFalse(senteIterator.equals(iterator));
+    }
+
+    public void testClone() {
+        BreakIterator cloned = (BreakIterator) iterator.clone();
+        assertNotSame(cloned, iterator);
+        assertEquals(cloned, iterator);
+    }
+
+    public void testCurrent() {
+        assertEquals(0, iterator.current());
+        iterator.setText(TEXT);
+        assertEquals(iterator.first(), iterator.current());
+    }
+
+    public void testFirst() {
+        assertEquals(0, iterator.first());
+        iterator.setText(TEXT);
+        assertEquals(0, iterator.first());
+    }
+
+    public void testFollowing() {
+        try {
+            iterator.following(1);
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+        iterator.setText(TEXT);
+        assertEquals(2, iterator.following(1));
+        try {
+            assertEquals(0, iterator.following(-1));
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+        try {
+            iterator.following(TEXT.length());
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    public void testIsBoundary() {
+        try {
+            iterator.isBoundary(2);
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+        iterator.setText(TEXT);
+        assertTrue(iterator.isBoundary(2));
+        assertFalse(iterator.isBoundary(1));
+        assertTrue(iterator.isBoundary(0));
+        try {
+            iterator.isBoundary(-1);
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+        try {
+            iterator.isBoundary(TEXT.length());
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    public void testLast() {
+        assertEquals(0, iterator.last());
+        iterator.setText(TEXT);
+        assertEquals(TEXT.length(), iterator.last());
+    }
+
+    /*
+     * Class under test for int next(int)
+     */
+    public void testNextint() {
+        assertEquals(BreakIterator.DONE, iterator.next(3));
+        iterator.setText(TEXT);
+        assertEquals(4, iterator.next(3));
+        assertEquals(24, iterator.next(20));
+        assertEquals(23, iterator.next(-1));
+        assertEquals(-1, iterator.next(TEXT.length()));
+    }
+
+    public void testPreceding() {
+        try {
+            iterator.preceding(2);
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+        iterator.setText(TEXT);
+        assertEquals(0, iterator.preceding(2));
+        assertEquals(2, iterator.preceding(3));
+        assertEquals(16, iterator.preceding(17));
+        assertEquals(17, iterator.preceding(18));
+        assertEquals(18, iterator.preceding(19));
+        try {
+            iterator.preceding(-1);
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+        try {
+            iterator.preceding(TEXT.length());
+            fail("should throw illegal argument exception");
+        } catch (IllegalArgumentException e) {
+        }
+    }
+
+    public void testPrevious() {
+        assertEquals(-1, iterator.previous());
+        iterator.setText(TEXT);
+        assertEquals(-1, iterator.previous());
+        iterator.last();
+        assertEquals(TEXT.length() - 1, iterator.previous());
+    }
+
+    // public void testGetAvailableLocales() {
+    // Locale[] locales = BreakIterator.getAvailableLocales();
+    // }
+
+    /*
+     * Class under test for BreakIterator getCharacterInstance()
+     */
+    public void testGetCharacterInstance() {
+        BreakIterator.getCharacterInstance();
+    }
+
+    /*
+     * Class under test for BreakIterator getCharacterInstance(Locale)
+     */
+    public void testGetCharacterInstanceLocale() {
+        BreakIterator it = BreakIterator.getCharacterInstance(Locale.US);
+        BreakIterator it2 = BreakIterator.getCharacterInstance(Locale.CHINA);
+        assertEquals(it, it2);
+    }
+
+    /*
+     * Class under test for BreakIterator getLineInstance()
+     */
+    public void testGetLineInstance() {
+        BreakIterator it = BreakIterator.getLineInstance();
+    }
+
+    /*
+     * Class under test for BreakIterator getLineInstance(Locale)
+     */
+    public void testGetLineInstanceLocale() {
+        BreakIterator it = BreakIterator.getLineInstance(Locale.US);
+        BreakIterator.getLineInstance(new Locale("bad locale"));
+    }
+
+    /*
+     * Class under test for BreakIterator getSentenceInstance()
+     */
+    public void testGetSentenceInstance() {
+        BreakIterator it = BreakIterator.getSentenceInstance();
+    }
+
+    /*
+     * Class under test for BreakIterator getSentenceInstance(Locale)
+     */
+    public void testGetSentenceInstanceLocale() {
+        BreakIterator it = BreakIterator.getSentenceInstance(Locale.US);
+    }
+
+    public void testGetText() {
+        assertEquals(new StringCharacterIterator(""), iterator.getText());
+        iterator.setText(TEXT);
+        assertEquals(new StringCharacterIterator(TEXT), iterator.getText());
+    }
+
+    /*
+     * Class under test for BreakIterator getWordInstance()
+     */
+    public void testGetWordInstance() {
+        BreakIterator it = BreakIterator.getWordInstance();
+    }
+
+    /*
+     * Class under test for BreakIterator getWordInstance(Locale)
+     */
+    public void testGetWordInstanceLocale() {
+        BreakIterator it = BreakIterator.getWordInstance(Locale.US);
+    }
+
+    /*
+     * Class under test for void setText(CharacterIterator)
+     */
+    public void testSetTextCharacterIterator() {
+        try {
+            iterator.setText((CharacterIterator) null);
+            fail();
+        } catch (NullPointerException e) {
+        }
+        CharacterIterator it = new StringCharacterIterator("abc");
+        iterator.setText(it);
+        assertSame(it, iterator.getText());
+    }
+
+    /*
+     * Class under test for void setText(String)
+     */
+    public void testSetTextString() {
+        try {
+            iterator.setText((String) null);
+            fail();
+        } catch (NullPointerException e) {
+        }
+        iterator.setText("abc");
+        CharacterIterator it = new StringCharacterIterator("abc");
+        assertEquals(it, iterator.getText());
+    }
+    
+	public void test_next() {
+		// Regression test for HARMONY-30
+		BreakIterator bi = BreakIterator.getWordInstance(Locale.US);
+		bi.setText("This is the test, WordInstance");
+		int n = bi.first();
+		n = bi.next();
+		assertEquals("Assert 0: next() returns incorrect value ", 4, n);
+        
+        assertEquals(BreakIterator.DONE, iterator.next());
+        iterator.setText(TEXT);
+        assertEquals(2, iterator.next());
+	}
+
+	public void test_getShort() {
+		try {
+			MockBreakIterator.publicGetShort(null, 0);
+			fail("should throw NPE.");
+		} catch (NullPointerException e) {
+		}
+		try {
+			MockBreakIterator.publicGetShort(null, -1);
+			fail("should throw NPE.");
+		} catch (NullPointerException e) {
+		}
+		try {
+			MockBreakIterator.publicGetShort(new byte[] { 0, 0, 0, 1 , 1}, -1);
+			fail("should throw ArrayIndexOutOfBoundsException.");
+		} catch (ArrayIndexOutOfBoundsException e) {
+		}
+		try {
+			MockBreakIterator.publicGetShort(new byte[] { 0, 0 }, 1);
+			fail("should throw ArrayIndexOutOfBoundsException.");
+		} catch (ArrayIndexOutOfBoundsException e) {
+		}
+		assertEquals(0, MockBreakIterator.publicGetShort(new byte[] { 0, 0 }, 0));
+		assertEquals(1, MockBreakIterator.publicGetShort(new byte[] { 0, 1 }, 0));
+		assertEquals(-1, MockBreakIterator.publicGetShort(new byte[] { (byte)0xff, (byte)0xff }, 0));
+		assertEquals(1, MockBreakIterator.publicGetShort(new byte[] { 1, 0, 1, 0 }, 1));
+		assertEquals(1, MockBreakIterator.publicGetShort(new byte[] { 0, 0, 1, 0 }, 1));
+		assertEquals(1, MockBreakIterator.publicGetShort(new byte[] { 0, 0, 1, 1 }, 1));
+		assertEquals(257, MockBreakIterator.publicGetShort(new byte[] { 0, 1, 1 }, 1));
+	}
+	
+	public void test_getInt() {
+		try {
+			MockBreakIterator.publicGetInt(null, 0);
+			fail("should throw NPE.");
+		} catch (NullPointerException e) {
+		}
+		try {
+			MockBreakIterator.publicGetInt(null, -1);
+			fail("should throw NPE.");
+		} catch (NullPointerException e) {
+		}
+		try {
+			MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 1 , 1}, -1);
+			fail("should throw ArrayIndexOutOfBoundsException.");
+		} catch (ArrayIndexOutOfBoundsException e) {
+		}
+		try {
+			MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 0}, 1);
+			fail("should throw ArrayIndexOutOfBoundsException.");
+		} catch (ArrayIndexOutOfBoundsException e) {
+		}
+		assertEquals(0, MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 0 }, 0));
+		assertEquals(1, MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 1 }, 0));
+		assertEquals(-1, MockBreakIterator.publicGetInt(new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }, 0));
+		assertEquals(1, MockBreakIterator.publicGetInt(new byte[] { 1, 0, 0, 0, 1, 0 }, 1));
+		assertEquals(1, MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 0, 1, 0 }, 1));
+		assertEquals(1, MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 0, 1, 1 }, 1));
+		assertEquals(257, MockBreakIterator.publicGetInt(new byte[] { 0, 0, 0, 1, 1 }, 1));
+	}
+	
+	public void test_getLong() {
+		try {
+			MockBreakIterator.publicGetLong(null, 0);
+			fail("should throw NPE.");
+		} catch (NullPointerException e) {
+		}
+		try {
+			MockBreakIterator.publicGetLong(null, -1);
+			fail("should throw NPE.");
+		} catch (NullPointerException e) {
+		}
+		try {
+			MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 1, 1}, -1);
+			fail("should throw ArrayIndexOutOfBoundsException.");
+		} catch (ArrayIndexOutOfBoundsException e) {
+		}
+		try {
+			MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 1, 1}, 1);
+			fail("should throw ArrayIndexOutOfBoundsException.");
+		} catch (ArrayIndexOutOfBoundsException e) {
+		}
+		assertEquals(0, MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 }, 0));
+		assertEquals(1, MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, 0));
+		assertEquals(-1, MockBreakIterator.publicGetLong(new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff }, 0));
+		assertEquals(1, MockBreakIterator.publicGetLong(new byte[] { 1, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, 1));
+		assertEquals(1, MockBreakIterator.publicGetLong(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 }, 1));
+		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));
+	}
+
+	private static class MockBreakIterator extends BreakIterator {
+		public static int publicGetInt(byte[] buf, int offset) {
+			return BreakIterator.getInt(buf, offset);
+		}
+
+		public static long publicGetLong(byte[] buf, int offset) {
+			return BreakIterator.getLong(buf, offset);
+		}
+
+		public static short publicGetShort(byte[] buf, int offset) {
+			return BreakIterator.getShort(buf, offset);
+		}
+
+		public int current() {
+			return 0;
+		}
+
+		public int first() {
+			return 0;
+		}
+
+		public int following(int offset) {
+			return 0;
+		}
+
+		public CharacterIterator getText() {
+			return null;
+		}
+
+		public int last() {
+			return 0;
+		}
+
+		public int next() {
+			return 0;
+		}
+
+		public int next(int n) {
+			return 0;
+		}
+
+		public int previous() {
+			return 0;
+		}
+
+		public void setText(CharacterIterator newText) {
+		}
+	}
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/BreakIteratorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native