db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kahat...@apache.org
Subject svn commit: r792434 - in /db/derby/code/trunk/java: client/org/apache/derby/jdbc/ClientBaseDataSource.java testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
Date Thu, 09 Jul 2009 07:49:42 GMT
Author: kahatlen
Date: Thu Jul  9 07:49:41 2009
New Revision: 792434

URL: http://svn.apache.org/viewvc?rev=792434&view=rev
Log:
DERBY-3669: ClientXADataSource fetched from JNDI not identical as originally bound; some properties
have String "null" instead of null

Changed ClientBaseDataSource.getReference() to match the embedded
implementation in ReferenceableDataSource, which already handles null
values.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=792434&r1=792433&r2=792434&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Thu Jul
 9 07:49:41 2009
@@ -566,8 +566,11 @@
 
                 try {
                     Object ov = m.invoke(this, null);
-                    String value = ov == null ? null : ov.toString();
-                    ref.add(new StringRefAddr(propertyName, value));
+                    // Need to check if property value is null, otherwise
+                    // "null" string gets stored.
+                    if (ov != null) {
+                        ref.add(new StringRefAddr(propertyName, ov.toString()));
+                    }
                 } catch (IllegalAccessException iae) {
                 } catch (InvocationTargetException ite) {
                 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java?rev=792434&r1=792433&r2=792434&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
Thu Jul  9 07:49:41 2009
@@ -106,29 +106,30 @@
             ic.rebind("cn=compareDS, o=" + dnString, xads);
             javax.sql.XADataSource ads =
                 (javax.sql.XADataSource)ic.lookup("cn=compareDS, o=" + dnString);
-            // At this point, the directly created xads should be matching the looked up
one.
+
+            // Embedded data sources implement equals(), so use it to check
+            // that the two data sources are equal.
             if (usingEmbedded())
             {
                 assertEquals(xads, ads);
             }
-            else
-            {
-                // DERBY-3669; with DerbyNetClient, the original and looked-up
-                // xadatasource are not the same...So, compare piece by piece:
-                // When fixed, rest of else can be replaced by uncommenting 
-                // next line
-                //assertEquals(xads,ads);
-                String[] orgprops = getPropertyBeanList(xads);
-                String[] bindprops = getPropertyBeanList(ads);
-                assertEquals(orgprops.length, bindprops.length);
-                // following is actually checked in DataSourceReferenceTest
-                for (int i=0;i<orgprops.length;i++){
-                    assertEquals(orgprops[i], bindprops[i]);
-                }
-                // We have the same properties, now compare the values
-                assertEqualPropValues(xads,ads, orgprops);
+
+            // Client data sources don't implement equals(), so compare each
+            // property manually. And by the way, we don't trust that equals()
+            // in embedded data sources checks all the properties, so do a
+            // full check for embedded as well.
+            String[] orgprops = getPropertyBeanList(xads);
+            String[] bindprops = getPropertyBeanList(ads);
+            assertEquals(orgprops.length, bindprops.length);
+
+            // Check that all properties are equal.
+            for (int i=0;i<orgprops.length;i++){
+                assertEquals(orgprops[i], bindprops[i]);
+                assertEquals(
+                        JDBCDataSource.getBeanProperty(xads, orgprops[i]),
+                        JDBCDataSource.getBeanProperty(ads, bindprops[i]));
             }
-            
+
             // modify something essential of the original XADataSource
             JDBCDataSource.clearStringBeanProperty(xads, "createDatabase");
             
@@ -136,32 +137,6 @@
             assertFalse(xads.equals(ads));
     }
 
-    public void assertEqualPropValues(
-            XADataSource orgds, XADataSource lookedupds, String[] props)
-    throws Exception {
-        for (int i=0;i<props.length;i++){
-            if (JDBCDataSource.getBeanProperty(orgds, props[i]) != null && 
-                    JDBCDataSource.getBeanProperty(lookedupds, props[i]) != null)
-            {
-                assertEquals(
-                        JDBCDataSource.getBeanProperty(orgds, props[i]),
-                        JDBCDataSource.getBeanProperty(lookedupds, props[i])
-                );
-            }
-            else {
-                if (JDBCDataSource.getBeanProperty(lookedupds,props[i]) != null)
-                {
-                    assertNull(JDBCDataSource.getBeanProperty(orgds,props[i]));
-                }
-                else
-                {
-                    assertNull(JDBCDataSource.getBeanProperty(orgds,props[i]));
-                    assertNull(JDBCDataSource.getBeanProperty(lookedupds,props[i]));
-                }
-            }
-        }
-    }
-    
     /**
      * Obtains a list of bean properties through reflection.
      * 



Mime
View raw message