harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r537794 - in /harmony/enhanced/classlib/trunk/modules/regex/src: main/java/java/util/regex/ test/java/org/apache/harmony/tests/java/util/regex/ test/resources/serialization/org/apache/harmony/tests/java/util/regex/
Date Mon, 14 May 2007 12:07:15 GMT
Author: ayza
Date: Mon May 14 05:07:14 2007
New Revision: 537794

URL: http://svn.apache.org/viewvc?view=rev&rev=537794
Log:
Applying patch from HARMONY-3787 ([classlib][regex]java.util.regex.PatternSyntaxException
does not have an serialize field required by doc.)

Added:
    harmony/enhanced/classlib/trunk/modules/regex/src/test/resources/serialization/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.golden.ser
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PatternSyntaxException.java
    harmony/enhanced/classlib/trunk/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.java

Modified: harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PatternSyntaxException.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PatternSyntaxException.java?view=diff&rev=537794&r1=537793&r2=537794
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PatternSyntaxException.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/regex/src/main/java/java/util/regex/PatternSyntaxException.java
Mon May 14 05:07:14 2007
@@ -35,18 +35,18 @@
     
     private static final long serialVersionUID = -3864639126226059218L;
     
+    private String desc;
+    
     private String pattern;
-
-    private String message;
-
+   
     private int index = -1;
 
     /**
      * @com.intel.drl.spec_ref
      */
-    public PatternSyntaxException(String message, String pattern, int index) {
+    public PatternSyntaxException(String desc, String pattern, int index) {
+        this.desc = desc;
         this.pattern = pattern;
-        this.message = message;
         this.index = index;
     }
 
@@ -67,7 +67,7 @@
             Arrays.fill(temp, ' ');
             filler = new String(temp);
         }
-        return message
+        return desc
                 + ((pattern != null && pattern.length() != 0) ? Messages.getString("regex.07",
//$NON-NLS-1$
                         new Object[]{index, pattern, filler}) : ""); //$NON-NLS-1$
     }
@@ -76,7 +76,7 @@
      * @com.intel.drl.spec_ref
      */
     public String getDescription() {
-        return message;
+        return desc;
     }
 
     /**

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?view=diff&rev=537794&r1=537793&r2=537794
==============================================================================
--- 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
Mon May 14 05:07:14 2007
@@ -18,9 +18,14 @@
 
 import junit.framework.TestCase;
 
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
+
 /**
  * TODO Type description
  * 
@@ -57,4 +62,48 @@
             assertEquals(regex, e.getPattern());
         }
     }
+    
+    /**
+     * @tests serialization/deserialization compatibility.
+     */
+    public void testSerializationSelf() throws Exception {
+        PatternSyntaxException object = new PatternSyntaxException("TESTDESC", "TESTREGEX",
3);
+        SerializationTest.verifySelf(object, PATTERNSYNTAXEXCEPTION_COMPARATOR);
+    }
+    
+    /**
+     * @tests serialization/deserialization compatibility with RI.
+     */
+    public void testSerializationCompatibility() throws Exception {
+        PatternSyntaxException object = new PatternSyntaxException("TESTDESC",
+                "TESTREGEX", 3);
+        SerializationTest.verifyGolden(this, object,
+                PATTERNSYNTAXEXCEPTION_COMPARATOR);
+    }
+    
+    //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,
+                Serializable deserialized) {
+
+            // do common checks for all throwable objects
+            SerializationTest.THROWABLE_COMPARATOR.assertDeserialized(initial,
+                    deserialized);
+
+            PatternSyntaxException initPatternSyntaxException = (PatternSyntaxException)
initial;
+            PatternSyntaxException dserPatternSyntaxException = (PatternSyntaxException)
deserialized;
+
+            // verify fields
+            assertEquals(initPatternSyntaxException.getDescription(), dserPatternSyntaxException.getDescription());
+            assertEquals(initPatternSyntaxException.getPattern(), dserPatternSyntaxException.getPattern());
+            assertEquals(initPatternSyntaxException.getIndex(), dserPatternSyntaxException.getIndex());
           
+        }
+    };
 }

Added: harmony/enhanced/classlib/trunk/modules/regex/src/test/resources/serialization/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.golden.ser
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/regex/src/test/resources/serialization/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.golden.ser?view=auto&rev=537794
==============================================================================
Binary file - no diff available.

Propchange: harmony/enhanced/classlib/trunk/modules/regex/src/test/resources/serialization/org/apache/harmony/tests/java/util/regex/PatternSyntaxExceptionTest.golden.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message