HHH-8203 HHH-8204 Hibernate 4.x can't work with proxool 0.9.1
This commit is contained in:
parent
dc6d2555ec
commit
2e90658116
|
@ -27,7 +27,6 @@ import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.logicalcobwebs.proxool.ProxoolException;
|
import org.logicalcobwebs.proxool.ProxoolException;
|
||||||
|
|
|
@ -29,10 +29,11 @@ import java.util.List;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.logicalcobwebs.proxool.ProxoolFacade;
|
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.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 org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
@ -50,19 +51,18 @@ public class ProxoolConnectionProviderTest extends BaseUnitTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testPoolsClosed() {
|
public void testPoolsClosed() {
|
||||||
assertDefinedPools(); // zero-length-vararg used as parameter
|
assertDefinedPools(); // zero-length-vararg used as parameter
|
||||||
StandardServiceRegistry serviceRegistry = buildServiceRegistry( "pool-one" );
|
StandardServiceRegistryImpl serviceRegistry = (StandardServiceRegistryImpl)buildServiceRegistry( "pool-one" );
|
||||||
ConnectionProvider providerOne = serviceRegistry.getService( ConnectionProvider.class );
|
ConnectionProvider providerOne = serviceRegistry.getService( ConnectionProvider.class );
|
||||||
assertDefinedPools( "pool-one" );
|
assertDefinedPools( "pool-one" );
|
||||||
|
|
||||||
|
|
||||||
StandardServiceRegistry serviceRegistryTwo = buildServiceRegistry( "pool-two" );
|
StandardServiceRegistryImpl serviceRegistryTwo = (StandardServiceRegistryImpl)buildServiceRegistry( "pool-two" );
|
||||||
ConnectionProvider providerTwo = serviceRegistryTwo.getService( ConnectionProvider.class );
|
ConnectionProvider providerTwo = serviceRegistryTwo.getService( ConnectionProvider.class );
|
||||||
assertDefinedPools( "pool-one", "pool-two" );
|
assertDefinedPools( "pool-one", "pool-two" );
|
||||||
|
serviceRegistry.destroy();
|
||||||
StandardServiceRegistryBuilder.destroy( serviceRegistry );
|
|
||||||
assertDefinedPools( "pool-two" );
|
assertDefinedPools( "pool-two" );
|
||||||
|
|
||||||
StandardServiceRegistryBuilder.destroy( serviceRegistryTwo );
|
serviceRegistryTwo.destroy();
|
||||||
assertDefinedPools();
|
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_POOL_ALIAS, poolName )
|
||||||
.applySetting( Environment.PROXOOL_PROPERTIES, poolName + ".properties" )
|
.applySetting( Environment.PROXOOL_PROPERTIES, poolName + ".properties" )
|
||||||
.applySetting( Environment.CONNECTION_PROVIDER, ProxoolConnectionProvider.class.getName() )
|
.applySetting( Environment.CONNECTION_PROVIDER, ProxoolConnectionProvider.class.getName() )
|
||||||
.build();
|
.buildServiceRegistry();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue