[jbosscache-commits] JBoss Cache SVN: r7482 - in core/trunk/src: test/java/org/jboss/cache/eviction and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Thu Jan 15 15:53:44 EST 2009
Author: mircea.markus
Date: 2009-01-15 15:53:44 -0500 (Thu, 15 Jan 2009)
New Revision: 7482
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java
core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
Log:
fix test for jdk6
Modified: core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java 2009-01-15 18:46:35 UTC (rev 7481)
+++ core/trunk/src/main/java/org/jboss/cache/loader/C3p0ConnectionFactory.java 2009-01-15 20:53:44 UTC (rev 7482)
@@ -22,6 +22,7 @@
package org.jboss.cache.loader;
import com.mchange.v2.c3p0.DataSources;
+import com.mchange.v2.c3p0.PooledDataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -41,47 +42,29 @@
private static final Log log = LogFactory.getLog(C3p0ConnectionFactory.class);
private static final boolean trace = log.isTraceEnabled();
- private DataSource ds;
+ private PooledDataSource ds;
+ private Properties config = new Properties();
@Override
public void setConfig(AdjListJDBCCacheLoaderConfig config)
{
super.setConfig(config);
- Properties properties = config.getProperties();
+ writeProps(config.getProperties());
+ writeProps(System.getProperties());
+ if (trace) log.trace("Using props: " + this.config);
+ }
+
+ private void writeProps(Properties properties)
+ {
Enumeration e = properties.propertyNames();
while (e.hasMoreElements())
{
String property = (String) e.nextElement();
if (property.startsWith("c3p0."))
{
- /* System properties should come before settings from XML configuration.
-
- For simplicity (c3p0 manual says overrides should not carry c3p0. start whereas system properties yes)
- and to avoid parsing, it's easier to set the values from XML configuration that should be c3p0. as
- system properties.
-
- So, this check allows us to determine if the System property was not set, in which case, we take the
- value from the XML configuration and set it to be a System property. If the value from the XML config
- was already set as System property, we do nothing, original System property should stand. */
-
- String xmlPropertyValue = properties.getProperty(property);
- String sysPropertyValue = System.getProperty(property);
- if (System.getProperty(property) == null)
- {
- System.setProperty(property, xmlPropertyValue);
- if (log.isDebugEnabled())
- {
- log.debug("c3p0 property defined in XML: " + property + "=" + xmlPropertyValue);
- }
- }
- else
- {
- if (log.isDebugEnabled())
- {
- log.debug(property + "=" + sysPropertyValue + " defined as system property. It will override the value defined in XML which was: " + xmlPropertyValue);
- }
- }
+ String newName = property.substring("c3p0.".length());
+ this.config.put(newName, properties.get(property));
}
}
}
@@ -93,7 +76,7 @@
super.start();
DataSource unpooled = DataSources.unpooledDataSource(getUrl(), getUsr(), getPwd());
- ds = DataSources.pooledDataSource(unpooled);
+ ds = (PooledDataSource) DataSources.pooledDataSource(unpooled, config);
if (log.isDebugEnabled())
{
@@ -104,9 +87,16 @@
@Override
public Connection checkoutConnection() throws SQLException
{
+ if (trace)
+ {
+ log.trace("DataSource before checkout (NumBusyConnectionsAllUsers) : " + ds.getNumBusyConnectionsAllUsers());
+ log.trace("DataSource before checkout (NumConnectionsAllUsers) : " + ds.getNumConnectionsAllUsers());
+ }
Connection connection = ds.getConnection();
if (trace)
{
+ log.trace("DataSource after checkout (NumBusyConnectionsAllUsers) : " + ds.getNumBusyConnectionsAllUsers());
+ log.trace("DataSource after checkout (NumConnectionsAllUsers) : " + ds.getNumConnectionsAllUsers());
log.trace("Connection checked out: " + connection);
}
return connection;
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2009-01-15 18:46:35 UTC (rev 7481)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/LRUAlgorithmTest.java 2009-01-15 20:53:44 UTC (rev 7482)
@@ -21,7 +21,6 @@
*/
@Test(groups = "functional", testName = "eviction.LRUAlgorithmTest")
public class LRUAlgorithmTest extends EvictionTestsBase
-
{
RegionManager regionManager;
LRUAlgorithm algorithm;
Modified: core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2009-01-15 18:46:35 UTC (rev 7481)
+++ core/trunk/src/test/java/org/jboss/cache/loader/C3p0ConnectionFactoryTest.java 2009-01-15 20:53:44 UTC (rev 7482)
@@ -24,7 +24,7 @@
*
* @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
*/
- at Test(groups = {"functional"}, sequential = true, testName = "loader.C3p0ConnectionFactoryTest")
+ at Test(groups = {"functional"}, testName = "loader.C3p0ConnectionFactoryTest")
public class C3p0ConnectionFactoryTest
{
private C3p0ConnectionFactory cf;
More information about the jbosscache-commits
mailing list