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 2010/11/11 10:23:21 UTC
svn commit: r1033851 - in
/db/derby/code/trunk/java/testing/org/apache/derbyTesting:
functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
junit/TestConfiguration.java
Author: kahatlen
Date: Thu Nov 11 09:23:20 2010
New Revision: 1033851
URL: http://svn.apache.org/viewvc?rev=1033851&view=rev
Log:
DERBY-4898: testGetURL test fails in nightly runs
Disregard differences in ordering when comparing connection
attributes.
Modified:
db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java?rev=1033851&r1=1033850&r2=1033851&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DatabaseMetaDataTest.java Thu Nov 11 09:23:20 2010
@@ -42,6 +42,8 @@ import java.util.ArrayList;
import java.util.Arrays;
//import java.util.HashMap;
//import java.util.Iterator;
+import java.util.Enumeration;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
//import java.util.Map;
@@ -708,11 +710,39 @@ public class DatabaseMetaDataTest extend
assertFalse("getURL is supported!", JDBC.vmSupportsJSR169());
assertTrue("getURL is supported!", JDBC.vmSupportsJDBC3());
+ TestConfiguration config = getTestConfiguration();
+ String expectedURL = config.getJDBCUrl();
+
// DERBY-4886: Embedded returns the URL without connection attributes,
// client returns the URL with connection attributes.
- TestConfiguration config = getTestConfiguration();
- String expectedURL = usingEmbedded() ?
- config.getJDBCUrl() : config.getJDBCUrlWithAttributes();
+ if (usingDerbyNetClient()) {
+ String[] urlComponents = url.split(";");
+
+ // Only compare whatever comes before the first semi-colon with
+ // the expected URL. Check connection attributes separately.
+ url = urlComponents[0];
+
+ // Put each actual connection attribute in a HashSet for easy
+ // comparison.
+ HashSet attrs = new HashSet();
+ for (int i = 1; i < urlComponents.length; i++) {
+ attrs.add(urlComponents[i]);
+ }
+
+ // Put each expected connection attribute in a HashSet.
+ HashSet expectedAttrs = new HashSet();
+ Properties ca = config.getConnectionAttributes();
+ Enumeration e = ca.propertyNames();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ expectedAttrs.add(key + '=' + ca.getProperty(key));
+ }
+
+ // Verify that the actual connection attributes match the
+ // expected attributes. Order is irrelevant.
+ assertEquals("Connection attributes don't match",
+ expectedAttrs, attrs);
+ }
assertEquals("getURL match", expectedURL, url);
}
Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java?rev=1033851&r1=1033850&r2=1033851&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/TestConfiguration.java Thu Nov 11 09:23:20 2010
@@ -1009,6 +1009,7 @@ public final class TestConfiguration {
logicalDbMapping.put(DEFAULT_DBNAME, DEFAULT_DBNAME);
this.userName = DEFAULT_USER_NAME;
this.userPassword = DEFAULT_USER_PASSWORD;
+ this.connectionAttributes = new Properties();
this.hostName = null;
this.port = basePort;
this.isVerbose = Boolean.valueOf(
@@ -1221,6 +1222,7 @@ public final class TestConfiguration {
userName = props.getProperty(KEY_USER_NAME, DEFAULT_USER_NAME);
userPassword = props.getProperty(KEY_USER_PASSWORD,
DEFAULT_USER_PASSWORD);
+ connectionAttributes = new Properties();
hostName = props.getProperty(KEY_HOSTNAME, DEFAULT_HOSTNAME);
isVerbose = Boolean.valueOf(props.getProperty(KEY_VERBOSE)).booleanValue();
doTrace = Boolean.valueOf(props.getProperty(KEY_TRACE)).booleanValue();
@@ -1363,21 +1365,6 @@ public final class TestConfiguration {
}
/**
- * Return the JDBC URL for connecting to the default database, including
- * any connection attributes.
- *
- * @return JDBC URL with connection attributes
- */
- public String getJDBCUrlWithAttributes() {
- String attrs = getConnectionAttributesString();
- if (attrs == null) {
- return url;
- } else {
- return url + ';' + attrs;
- }
- }
-
- /**
* Return the jdbc url for a connecting to the database.
*
* @param databaseName name of database.
@@ -1430,9 +1417,9 @@ public final class TestConfiguration {
* {@link #getUserName()} or {@link #getUserPassword()} instead to
* retrieve those attributes.
*
- * @return connection attributes (can be {@code null})
+ * @return connection attributes (never {@code null})
*/
- Properties getConnectionAttributes() {
+ public Properties getConnectionAttributes() {
return connectionAttributes;
}
@@ -1444,10 +1431,6 @@ public final class TestConfiguration {
* are no attributes)
*/
String getConnectionAttributesString() {
- if (connectionAttributes == null) {
- return null;
- }
-
StringBuffer sb = new StringBuffer();
Enumeration e = connectionAttributes.propertyNames();
boolean first = true;