[hibernate-commits] Hibernate SVN: r18328 - in core/trunk/core/src: test/java/org/hibernate and 1 other directories.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Thu Dec 24 08:26:38 EST 2009


Author: stliu
Date: 2009-12-24 08:26:38 -0500 (Thu, 24 Dec 2009)
New Revision: 18328

Added:
   core/trunk/core/src/test/java/org/hibernate/connection/
   core/trunk/core/src/test/java/org/hibernate/connection/PropertiesTest.java
Modified:
   core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
Log:
HHH-4574 ConnectionProviderFactory.getConnectionProperties() includes extra properties 

Modified: core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java
===================================================================
--- core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java	2009-12-24 11:55:08 UTC (rev 18327)
+++ core/trunk/core/src/main/java/org/hibernate/connection/ConnectionProviderFactory.java	2009-12-24 13:26:38 UTC (rev 18328)
@@ -145,7 +145,7 @@
 	 * Transform JDBC connection properties.
 	 *
 	 * Passed in the form <tt>hibernate.connection.*</tt> to the
-	 * format accepted by <tt>DriverManager</tt> by triming the leading "<tt>hibernate.connection</tt>".
+	 * format accepted by <tt>DriverManager</tt> by trimming the leading "<tt>hibernate.connection</tt>".
 	 */
 	public static Properties getConnectionProperties(Properties properties) {
 
@@ -153,7 +153,7 @@
 		Properties result = new Properties();
 		while ( iter.hasNext() ) {
 			String prop = (String) iter.next();
-			if ( prop.indexOf(Environment.CONNECTION_PREFIX) > -1 && !SPECIAL_PROPERTIES.contains(prop) ) {
+			if ( prop.startsWith(Environment.CONNECTION_PREFIX) && !SPECIAL_PROPERTIES.contains(prop) ) {
 				result.setProperty(
 					prop.substring( Environment.CONNECTION_PREFIX.length()+1 ),
 					properties.getProperty(prop)

Added: core/trunk/core/src/test/java/org/hibernate/connection/PropertiesTest.java
===================================================================
--- core/trunk/core/src/test/java/org/hibernate/connection/PropertiesTest.java	                        (rev 0)
+++ core/trunk/core/src/test/java/org/hibernate/connection/PropertiesTest.java	2009-12-24 13:26:38 UTC (rev 18328)
@@ -0,0 +1,54 @@
+/*
+ * Hibernate, Relational Persistence for Idiomatic Java
+ *
+ * Copyright (c) 2008, Red Hat Middleware LLC or third-party contributors as
+ * indicated by the @author tags or express copyright attribution
+ * statements applied by the authors.  All third-party contributions are
+ * distributed under license by Red Hat Middleware LLC.
+ *
+ * This copyrighted material is made available to anyone wishing to use, modify,
+ * copy, or redistribute it subject to the terms and conditions of the GNU
+ * Lesser General Public License, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this distribution; if not, write to:
+ * Free Software Foundation, Inc.
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA  02110-1301  USA
+ *
+ */
+package org.hibernate.connection;
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+/**
+ * Undocumented
+ *
+ * @author kbow
+ */
+
+public class PropertiesTest extends TestCase {
+	public void testProperties() throws Exception {
+		final Properties props = new Properties();
+
+		props.put("rpt.1.hibernate.dialect", "org.hibernate.dialect.DerbyDialect");
+		props.put("rpt.2.hibernate.connection.driver_class", "org.apache.derby.jdbc.ClientDriver");
+		props.put("rpt.3.hibernate.connection.url", "jdbc:derby://localhost:1527/db/reports.db");
+		props.put("rpt.4.hibernate.connection.username", "sa");
+		props.put("rpt.5.hibernate.connection.password_enc", "76f271db3661fd50082e68d4b953fbee");
+		props.put("rpt.6.hibernate.connection.password_enc", "76f271db3661fd50082e68d4b953fbee");
+		props.put("hibernate.connection.create", "true");
+
+		final Properties outputProps = ConnectionProviderFactory.getConnectionProperties(props);
+		assertEquals(1, outputProps.size());
+		assertEquals("true", outputProps.get("create"));
+	}
+
+}



More information about the hibernate-commits mailing list