You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/08/29 12:06:48 UTC

svn commit: r438039 - in /incubator/harmony/enhanced/classlib/trunk/modules/sql/src: main/java/java/sql/ test/java/org/apache/harmony/sql/tests/java/sql/ test/resources/serialization/org/apache/harmony/sql/tests/java/sql/

Author: smishura
Date: Tue Aug 29 03:06:48 2006
New Revision: 438039

URL: http://svn.apache.org/viewvc?rev=438039&view=rev
Log:
Apply patch for HARMONY-1302 ([classlib][sql] The field "int nanoseconds" of java.sql.Timestamp should be "int nanos" according to serialization form)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/resources/serialization/org/apache/harmony/sql/tests/java/sql/TimestampTest.golden.ser   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
    incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java?rev=438039&r1=438038&r2=438039&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/java/sql/Timestamp.java Tue Aug 29 03:06:48 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 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.
@@ -43,7 +43,7 @@
     private static final long serialVersionUID = 2745179027874758501L;
 
     // The nanoseconds time value of the Timestamp
-    private int nanoseconds;
+    private int nanos;
 
     /**
      * @deprecated Please use the constructor Timestamp( long ) Returns a
@@ -75,7 +75,7 @@
         if (theNano < 0 || theNano > 999999999) {
             throw new IllegalArgumentException();
         }
-        nanoseconds = theNano;
+        nanos = theNano;
     }
 
     /**
@@ -234,7 +234,7 @@
      *         999,999,999
      */
     public int getNanos() {
-        return nanoseconds;
+        return nanos;
     }
 
     /**
@@ -244,7 +244,7 @@
      */
     public long getTime() {
         long theTime = super.getTime();
-        theTime = theTime + (nanoseconds / 1000000);
+        theTime = theTime + (nanos / 1000000);
         return theTime;
     }
 
@@ -256,7 +256,7 @@
             // sql.0=Value out of range
             throw new IllegalArgumentException(Messages.getString("sql.0")); //$NON-NLS-1$
         }
-        nanoseconds = n;
+        nanos = n;
     }
 
     /**
@@ -305,7 +305,7 @@
         DecimalFormat decimalFormat = new DecimalFormat("0"); //$NON-NLS-1$
         decimalFormat.setMinimumIntegerDigits(9);
         decimalFormat.setMaximumIntegerDigits(9);
-        String theNanos = decimalFormat.format(nanoseconds);
+        String theNanos = decimalFormat.format(nanos);
         theNanos = stripTrailingZeros(theNanos);
         // Concatenate the nanosecond value with a dot - and return
         return (dateFormat.format(this) + '.' + theNanos);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java?rev=438039&r1=438038&r2=438039&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/TimestampTest.java Tue Aug 29 03:06:48 2006
@@ -1,4 +1,4 @@
-/* Copyright 2004 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 2004, 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.
@@ -19,6 +19,7 @@
 import java.util.Date;
 import java.util.TimeZone;
 
+import org.apache.harmony.testframework.serialization.SerializationTest;
 import junit.framework.TestCase;
 
 /**
@@ -587,9 +588,10 @@
 		Timestamp theTimestamp = new Timestamp(TIME_ARRAY[1]);
 		try {
 			theTimestamp.compareTo(nastyTest);
-			fail(
-					"testCompareToObject: Did not get expected ClassCastException");
-		} catch (ClassCastException e) {
+            // It throws ClassCastException in JDK 1.5.0_06 but in 1.5.0_07 it
+            // does not throw the expected exception.
+            fail("testCompareToObject: Did not get expected ClassCastException");
+        } catch (ClassCastException e) {
 			// Should get here
 			/*
 			 * System.out.println("testCompareToObject: ClassCastException as
@@ -599,5 +601,21 @@
 		} // end try
 
 	} // end method testcompareToObject
+    
+    /**
+     * @tests serialization/deserialization compatibility.
+     */
+    public void testSerializationSelf() throws Exception {
+        Timestamp object = new Timestamp(100L);
+        SerializationTest.verifySelf(object);
+    }
+
+    /**
+     * @tests serialization/deserialization compatibility with RI.
+     */
+    public void testSerializationCompatibility() throws Exception {
+        Timestamp object = new Timestamp(100L);
+        SerializationTest.verifyGolden(this, object);
+    }
 
 } // end class TimestampTest

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

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