You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2009/07/09 12:46:21 UTC
svn commit: r792491 - in /db/derby/code/branches/10.5: ./
java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
Author: kahatlen
Date: Thu Jul 9 10:46:21 2009
New Revision: 792491
URL: http://svn.apache.org/viewvc?rev=792491&view=rev
Log:
DERBY-3669: ClientXADataSource fetched from JNDI not identical as originally bound; some properties have String "null" instead of null
Merged fix from trunk (revision 792434).
Modified:
db/derby/code/branches/10.5/ (props changed)
db/derby/code/branches/10.5/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
Propchange: db/derby/code/branches/10.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jul 9 10:46:21 2009
@@ -1 +1 @@
-/db/derby/code/trunk:769596,772090,772449,772534,774281,779681,782991,785163,785570,785662,788369,788670,788674,788968,789264,790218
+/db/derby/code/trunk:769596,772090,772449,772534,774281,779681,782991,785163,785570,785662,788369,788670,788674,788968,789264,790218,792434
Modified: db/derby/code/branches/10.5/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java?rev=792491&r1=792490&r2=792491&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java (original)
+++ db/derby/code/branches/10.5/java/client/org/apache/derby/jdbc/ClientBaseDataSource.java Thu Jul 9 10:46:21 2009
@@ -563,8 +563,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/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java
URL: http://svn.apache.org/viewvc/db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java?rev=792491&r1=792490&r2=792491&view=diff
==============================================================================
--- db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java (original)
+++ db/derby/code/branches/10.5/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/XAJNDITest.java Thu Jul 9 10:46:21 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.
*