HHH-6635 C3P0: hibernate.c3p0.* configuration properties not properly parsed
This commit is contained in:
parent
fcf43b2933
commit
ed9c2bb61c
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011, Red Hat Inc. 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 Inc.
|
||||||
|
*
|
||||||
|
* 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.test.c3p0;
|
||||||
|
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
|
import java.util.Set;
|
||||||
|
import javax.management.MBeanServer;
|
||||||
|
import javax.management.ObjectName;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
import org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider;
|
||||||
|
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||||
|
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Strong Liu
|
||||||
|
*/
|
||||||
|
public class C3P0ConnectionProviderTest extends BaseCoreFunctionalTestCase {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testC3P0isDefaultWhenThereIsC3P0Properties() {
|
||||||
|
JdbcServices jdbcServices = serviceRegistry().getService( JdbcServices.class );
|
||||||
|
ConnectionProvider provider = jdbcServices.getConnectionProvider();
|
||||||
|
assertTrue( provider instanceof C3P0ConnectionProvider );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testHHH6635() throws Exception {
|
||||||
|
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
|
||||||
|
Set<ObjectName> set = mBeanServer.queryNames( null, null );
|
||||||
|
boolean mbeanfound = false;
|
||||||
|
for ( ObjectName obj : set ) {
|
||||||
|
if ( obj.getKeyPropertyListString().indexOf( "PooledDataSource" ) > 0 ) {
|
||||||
|
mbeanfound = true;
|
||||||
|
|
||||||
|
// see according c3p0 settings in META-INF/persistence.xml
|
||||||
|
|
||||||
|
int actual_minPoolSize = (Integer) mBeanServer.getAttribute( obj, "minPoolSize" );
|
||||||
|
assertEquals( 50, actual_minPoolSize );
|
||||||
|
|
||||||
|
int actual_maxPoolSize = (Integer) mBeanServer.getAttribute( obj, "maxPoolSize" );
|
||||||
|
assertEquals( 800, actual_maxPoolSize );
|
||||||
|
|
||||||
|
int actual_maxStatements = (Integer) mBeanServer.getAttribute( obj, "maxStatements" );
|
||||||
|
assertEquals( 50, actual_maxStatements );
|
||||||
|
|
||||||
|
int actual_maxIdleTime = (Integer) mBeanServer.getAttribute( obj, "maxIdleTime" );
|
||||||
|
assertEquals( 300, actual_maxIdleTime );
|
||||||
|
|
||||||
|
int actual_idleConnectionTestPeriod = (Integer) mBeanServer.getAttribute(
|
||||||
|
obj,
|
||||||
|
"idleConnectionTestPeriod"
|
||||||
|
);
|
||||||
|
assertEquals( 3000, actual_idleConnectionTestPeriod );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue( "PooledDataSource BMean not found, please verify version of c3p0", mbeanfound );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
#
|
||||||
|
# Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010, Red Hat Inc. 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 Inc.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
hibernate.dialect org.hibernate.dialect.H2Dialect
|
||||||
|
hibernate.connection.driver_class org.h2.Driver
|
||||||
|
hibernate.connection.url jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;MVCC=TRUE
|
||||||
|
hibernate.connection.username sa
|
||||||
|
|
||||||
|
hibernate.connection.pool_size 5
|
||||||
|
hibernate.c3p0.min_size 50
|
||||||
|
hibernate.c3p0.max_size 800
|
||||||
|
hibernate.c3p0.max_statements 50
|
||||||
|
hibernate.c3p0.timeout 300
|
||||||
|
hibernate.c3p0.idle_test_period 3000
|
||||||
|
hibernate.c3p0.testConnectionOnCheckout true
|
||||||
|
|
||||||
|
hibernate.show_sql false
|
||||||
|
|
||||||
|
hibernate.max_fetch_depth 5
|
||||||
|
|
||||||
|
hibernate.cache.region_prefix hibernate.test
|
||||||
|
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
|
|
@ -0,0 +1,10 @@
|
||||||
|
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||||
|
log4j.appender.stdout.Target=System.out
|
||||||
|
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||||
|
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||||
|
|
||||||
|
|
||||||
|
log4j.rootLogger=info, stdout
|
||||||
|
|
||||||
|
log4j.logger.org.hibernate.tool.hbm2ddl=debug
|
||||||
|
log4j.logger.org.hibernate.testing.cache=debug
|
Loading…
Reference in New Issue