diff --git a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java index ca8e9cecb..52e3569ac 100644 --- a/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java +++ b/src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java @@ -1212,7 +1212,7 @@ public static synchronized void unregisterPerformanceLogCallback() { static Properties fixupProperties(Properties props) throws SQLServerException { // assert props !=null Properties fixedup = new Properties(); - Enumeration e = props.keys(); + Enumeration e = props.propertyNames(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); String newname = getNormalizedPropertyName(name, drLogger); diff --git a/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java b/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java index be9333e24..ab885e414 100644 --- a/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java +++ b/src/test/java/com/microsoft/sqlserver/jdbc/SQLServerDriverTest.java @@ -192,6 +192,37 @@ public void testConnectionDriver() throws SQLException { } } } + + /** + * test connection properties + * + * @throws SQLException + */ + @Test + public void testDefaultProperties() throws SQLException { + SQLServerDriver d = new SQLServerDriver(); + Properties defaults = new Properties(); + defaults.setProperty(SQLServerDriverIntProperty.PORT_NUMBER.toString(), "101"); + defaults.setProperty(SQLServerDriverStringProperty.DATABASE_NAME.toString(), "test"); + + Properties info = new Properties(defaults); + StringBuffer url = new StringBuffer(); + url.append(Constants.JDBC_PREFIX).append(randomServer).append(";packetSize=512;"); + + // test defaults + DriverPropertyInfo[] infoArray = d.getPropertyInfo(url.toString(), info); + + for (DriverPropertyInfo anInfoArray : infoArray) { + if (anInfoArray.name.equalsIgnoreCase(Constants.PORT_NUMBER)) { + assertTrue(anInfoArray.value.equalsIgnoreCase("101"), + TestResource.getResource("R_valuesAreDifferent")); + } + if (anInfoArray.name.equalsIgnoreCase(Constants.DATABASE_NAME)) { + assertTrue(anInfoArray.value.equalsIgnoreCase("test"), + TestResource.getResource("R_valuesAreDifferent")); + } + } + } /** * test application name