You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/10/30 17:48:29 UTC
svn commit: r590139 [3/5] -
/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/
Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java?rev=590139&r1=590138&r2=590139&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java Tue Oct 30 09:48:16 2007
@@ -17,51 +17,49 @@
package org.apache.harmony.tests.java.util.regex;
import java.util.regex.Pattern;
+
import junit.framework.TestCase;
/**
* Test boundary and error conditions in java.util.regex.Pattern
- *
*/
+@SuppressWarnings("nls")
public class PatternErrorTest extends TestCase {
- public void testCompileErrors() throws Exception {
- // null regex string - should get NullPointerException
- try {
- Pattern.compile(null);
+ public void testCompileErrors() throws Exception {
+ // null regex string - should get NullPointerException
+ try {
+ Pattern.compile(null);
fail("NullPointerException expected");
- } catch (NullPointerException e) {
- }
-
+ } catch (NullPointerException e) {
+ }
- // empty regex string - no exception should be thrown
- Pattern.compile("");
+ // empty regex string - no exception should be thrown
+ Pattern.compile("");
- // note: invalid regex syntax checked in PatternSyntaxExceptionTest
+ // note: invalid regex syntax checked in PatternSyntaxExceptionTest
- // flags = 0 should raise no exception
- int flags = 0;
- Pattern.compile("foo", flags);
-
- // check that all valid flags accepted without exception
- flags |= Pattern.UNIX_LINES;
- flags |= Pattern.CASE_INSENSITIVE;
- flags |= Pattern.MULTILINE;
- flags |= Pattern.CANON_EQ;
- flags |= Pattern.COMMENTS;
- flags |= Pattern.DOTALL;
- flags |= Pattern.UNICODE_CASE;
- Pattern.compile("foo", flags);
+ // flags = 0 should raise no exception
+ int flags = 0;
+ Pattern.compile("foo", flags);
+
+ // check that all valid flags accepted without exception
+ flags |= Pattern.UNIX_LINES;
+ flags |= Pattern.CASE_INSENSITIVE;
+ flags |= Pattern.MULTILINE;
+ flags |= Pattern.CANON_EQ;
+ flags |= Pattern.COMMENTS;
+ flags |= Pattern.DOTALL;
+ flags |= Pattern.UNICODE_CASE;
+ Pattern.compile("foo", flags);
- // add invalid flags - should get IllegalArgumentException
+ // add invalid flags - should get IllegalArgumentException
// regression test for HARMONY-4248
- flags |= 0xFFFFFFFF;
- try {
- Pattern.compile("foo",flags);
- } catch (IllegalArgumentException e) {
- // This is the expected exception
- return;
- }
-
- fail("Expected IllegalArgumentException to be thrown");
- }
+ flags |= 0xFFFFFFFF;
+ try {
+ Pattern.compile("foo", flags);
+ fail("Expected IllegalArgumentException to be thrown");
+ } catch (IllegalArgumentException e) {
+ // This is the expected exception
+ }
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.java?rev=590139&r1=590138&r2=590139&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.java Tue Oct 30 09:48:16 2007
@@ -16,20 +16,20 @@
package org.apache.harmony.tests.java.util.regex;
-import junit.framework.TestCase;
-
import java.io.ObjectStreamClass;
import java.io.Serializable;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
+import junit.framework.TestCase;
+
import org.apache.harmony.testframework.serialization.SerializationTest;
import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
/**
* TODO Type description
- *
*/
+@SuppressWarnings("nls")
public class PatternSyntaxExceptionTest extends TestCase {
public void testCase() {
String regex = "(";
@@ -42,11 +42,11 @@
// assertEquals("Unclosed group", e.getDescription());
assertEquals(1, e.getIndex());
// assertEquals("Unclosed group near index 1\n(\n ^",
- // e.getMessage());
+ // e.getMessage());
assertEquals(regex, e.getPattern());
}
}
-
+
public void testCase2() {
String regex = "[4-";
try {
@@ -57,20 +57,21 @@
// TOFIX: should we match exception strings?
// assertEquals("Illegal character range", e.getDescription());
assertEquals(3, e.getIndex());
- // assertEquals("Illegal character range near index 3\n[4-\n ^",
- // e.getMessage());
+ // assertEquals("Illegal character range near index 3\n[4-\n ^",
+ // e.getMessage());
assertEquals(regex, e.getPattern());
}
}
-
+
/**
* @tests serialization/deserialization compatibility.
*/
public void testSerializationSelf() throws Exception {
- PatternSyntaxException object = new PatternSyntaxException("TESTDESC", "TESTREGEX", 3);
+ PatternSyntaxException object = new PatternSyntaxException("TESTDESC",
+ "TESTREGEX", 3);
SerializationTest.verifySelf(object, PATTERNSYNTAXEXCEPTION_COMPARATOR);
}
-
+
/**
* @tests serialization/deserialization compatibility with RI.
*/
@@ -80,14 +81,14 @@
SerializationTest.verifyGolden(this, object,
PATTERNSYNTAXEXCEPTION_COMPARATOR);
}
-
- //Regression test for HARMONY-3787
+
+ // Regression test for HARMONY-3787
public void test_objectStreamField() {
ObjectStreamClass objectStreamClass = ObjectStreamClass
.lookup(PatternSyntaxException.class);
assertNotNull(objectStreamClass.getField("desc"));
}
-
+
// comparator for BatchUpdateException field updateCounts
private static final SerializableAssert PATTERNSYNTAXEXCEPTION_COMPARATOR = new SerializableAssert() {
public void assertDeserialized(Serializable initial,
@@ -101,9 +102,12 @@
PatternSyntaxException dserPatternSyntaxException = (PatternSyntaxException) deserialized;
// verify fields
- assertEquals(initPatternSyntaxException.getDescription(), dserPatternSyntaxException.getDescription());
- assertEquals(initPatternSyntaxException.getPattern(), dserPatternSyntaxException.getPattern());
- assertEquals(initPatternSyntaxException.getIndex(), dserPatternSyntaxException.getIndex());
+ assertEquals(initPatternSyntaxException.getDescription(),
+ dserPatternSyntaxException.getDescription());
+ assertEquals(initPatternSyntaxException.getPattern(),
+ dserPatternSyntaxException.getPattern());
+ assertEquals(initPatternSyntaxException.getIndex(),
+ dserPatternSyntaxException.getIndex());
}
};
}