HHH-8203 HHH-8204 Hibernate 4.x can't work with proxool 0.9.1

This commit is contained in:
Strong Liu 2013-04-25 22:37:21 +08:00
parent dc6d2555ec
commit 2e90658116
2 changed files with 11 additions and 12 deletions

View File

@ -27,7 +27,6 @@ import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Map;
import java.util.Properties;
import org.jboss.logging.Logger;
import org.logicalcobwebs.proxool.ProxoolException;

View File

@ -29,10 +29,11 @@ import java.util.List;
import org.junit.Test;
import org.logicalcobwebs.proxool.ProxoolFacade;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cfg.Environment;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.service.internal.StandardServiceRegistryImpl;
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.testing.junit4.BaseUnitTestCase;
import static org.junit.Assert.assertEquals;
@ -50,19 +51,18 @@ public class ProxoolConnectionProviderTest extends BaseUnitTestCase {
@Test
public void testPoolsClosed() {
assertDefinedPools(); // zero-length-vararg used as parameter
StandardServiceRegistry serviceRegistry = buildServiceRegistry( "pool-one" );
StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl)buildServiceRegistry( "pool-one" );
ConnectionProvider providerOne = serviceRegistry.getService( ConnectionProvider.class );
assertDefinedPools( "pool-one" );
StandardServiceRegistry serviceRegistryTwo = buildServiceRegistry( "pool-two" );
StandardServiceRegistryImpl serviceRegistryTwo = (StandardServiceRegistryImpl)buildServiceRegistry( "pool-two" );
ConnectionProvider providerTwo = serviceRegistryTwo.getService( ConnectionProvider.class );
assertDefinedPools( "pool-one", "pool-two" );
StandardServiceRegistryBuilder.destroy( serviceRegistry );
serviceRegistry.destroy();
assertDefinedPools( "pool-two" );
StandardServiceRegistryBuilder.destroy( serviceRegistryTwo );
serviceRegistryTwo.destroy();
assertDefinedPools();
}
@ -75,13 +75,13 @@ public class ProxoolConnectionProviderTest extends BaseUnitTestCase {
}
private StandardServiceRegistry buildServiceRegistry(String poolName){
private ServiceRegistry buildServiceRegistry(String poolName){
return new StandardServiceRegistryBuilder( )
return new ServiceRegistryBuilder( )
.applySetting( Environment.PROXOOL_POOL_ALIAS, poolName )
.applySetting( Environment.PROXOOL_PROPERTIES, poolName + ".properties" )
.applySetting( Environment.CONNECTION_PROVIDER, ProxoolConnectionProvider.class.getName() )
.build();
.buildServiceRegistry();
}
}