harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r548543 - in /harmony/enhanced/classlib/trunk/modules/sql/src: main/java/javax/sql/ test/java/org/apache/harmony/sql/tests/javax/sql/ test/resources/serialization/org/apache/harmony/sql/tests/javax/sql/
Date Tue, 19 Jun 2007 01:22:13 GMT
Author: tonywu
Date: Mon Jun 18 18:22:11 2007
New Revision: 548543

URL: http://svn.apache.org/viewvc?view=rev&rev=548543
Log:
Apply patch HARMONY-3881 ([classlib][sql] deserialization of javax.sql.ConnectionEvent is
incompatible with RI
)

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

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java?view=diff&rev=548543&r1=548542&r2=548543
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/main/java/javax/sql/ConnectionEvent.java
Mon Jun 18 18:22:11 2007
@@ -30,7 +30,7 @@
 
     private static final long serialVersionUID = -4843217645290030002L;
 
-    private SQLException theSQLException;
+    private SQLException ex;
 
     /**
      * Creates a connection event initialized with a supplied PooledConnection.
@@ -56,7 +56,7 @@
     public ConnectionEvent(PooledConnection theConnection,
             SQLException theException) {
         super(theConnection);
-        theSQLException = theException;
+        ex = theException;
     }
 
     /**
@@ -67,6 +67,6 @@
      *         null if no error has occurred.
      */
     public SQLException getSQLException() {
-        return theSQLException;
+        return ex;
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/ConnectionEventTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/ConnectionEventTest.java?view=diff&rev=548543&r1=548542&r2=548543
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/ConnectionEventTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/ConnectionEventTest.java
Mon Jun 18 18:22:11 2007
@@ -17,8 +17,13 @@
 
 package org.apache.harmony.sql.tests.javax.sql;
 
+import java.io.Serializable;
 import java.sql.SQLException;
 import javax.sql.ConnectionEvent;
+
+import org.apache.harmony.testframework.serialization.SerializationTest;
+import org.apache.harmony.testframework.serialization.SerializationTest.SerializableAssert;
+
 import junit.framework.TestCase;
 
 public class ConnectionEventTest extends TestCase {
@@ -53,5 +58,58 @@
         assertSame(ipc, ce.getSource());
         assertSame(e, ce.getSQLException());
     }
+    
+    /**
+     * @tests serialization/deserialization compatibility.
+     */
+    public void testSerializationSelf() throws Exception {
+        Impl_PooledConnection ipc = new Impl_PooledConnection();
+        SQLException e = new SQLException();
+        ConnectionEvent ce = new ConnectionEvent(ipc, e);
+        SerializationTest.verifySelf(ce, CONNECTIONEVENT_COMPARATOR);
+    }
+
+    /**
+     * @tests serialization/deserialization compatibility with RI.
+     */
+    public void testSerializationCompatibility() throws Exception {
+        Impl_PooledConnection ipc = new Impl_PooledConnection();
+        SQLException nextSQLException = new SQLException("nextReason",
+                "nextSQLState", 33);
+
+        int vendorCode = 10;
+        SQLException sqlException = new SQLException("reason", "SQLState",
+                vendorCode);
+
+        sqlException.setNextException(nextSQLException);
+
+        ConnectionEvent ce = new ConnectionEvent(ipc, sqlException);
+
+        SerializationTest.verifyGolden(this, ce, CONNECTIONEVENT_COMPARATOR);
+    }
+
+    private static final SerializableAssert CONNECTIONEVENT_COMPARATOR = new SerializableAssert()
{
+
+        public void assertDeserialized(Serializable initial,
+                Serializable deserialized) {
+            ConnectionEvent ceInitial = (ConnectionEvent) initial;
+            ConnectionEvent ceDeser = (ConnectionEvent) deserialized;
+
+            SQLException initThr = ceInitial.getSQLException();
+            SQLException dserThr = ceDeser.getSQLException();
+
+            // verify SQLState
+            assertEquals(initThr.getSQLState(), dserThr.getSQLState());
+
+            // verify vendorCode
+            assertEquals(initThr.getErrorCode(), dserThr.getErrorCode());
+
+            // verify next
+            if (initThr.getNextException() == null) {
+                assertNull(dserThr.getNextException());
+            }
+        }
+
+    };
 }   
 

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

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



Mime
View raw message