HHH-5765 - Replaced ServiceRegistryHolder with ServiceRegistryBuilder
This commit is contained in:
parent
e9ec8ef587
commit
0c5526f724
|
@ -23,6 +23,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.dialect.resolver;
|
package org.hibernate.dialect.resolver;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -46,11 +47,13 @@ import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||||
import org.hibernate.dialect.SybaseAnywhereDialect;
|
import org.hibernate.dialect.SybaseAnywhereDialect;
|
||||||
import org.hibernate.dialect.TestingDialects;
|
import org.hibernate.dialect.TestingDialects;
|
||||||
|
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||||
import org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl;
|
import org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl;
|
||||||
import org.hibernate.service.jdbc.dialect.internal.DialectResolverSet;
|
import org.hibernate.service.jdbc.dialect.internal.DialectResolverSet;
|
||||||
import org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver;
|
import org.hibernate.service.jdbc.dialect.internal.StandardDialectResolver;
|
||||||
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
|
import org.hibernate.service.jdbc.dialect.spi.DialectResolver;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* TODO : javadoc
|
||||||
|
@ -58,19 +61,21 @@ import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class DialectFactoryTest extends TestCase {
|
public class DialectFactoryTest extends TestCase {
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
public DialectFactoryTest(String name) {
|
public DialectFactoryTest(String name) {
|
||||||
super( name );
|
super( name );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setUp() {
|
@Override
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
protected void setUp() {
|
||||||
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() {
|
@Override
|
||||||
if ( serviceRegistryHolder != null ) {
|
protected void tearDown() {
|
||||||
serviceRegistryHolder.destroy();
|
if ( serviceRegistry != null ) {
|
||||||
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +126,7 @@ public class DialectFactoryTest extends TestCase {
|
||||||
|
|
||||||
private DialectFactoryImpl getDialectFactoryImpl(DialectResolver dialectResolver) {
|
private DialectFactoryImpl getDialectFactoryImpl(DialectResolver dialectResolver) {
|
||||||
DialectFactoryImpl dialectFactoryImpl = new DialectFactoryImpl();
|
DialectFactoryImpl dialectFactoryImpl = new DialectFactoryImpl();
|
||||||
dialectFactoryImpl.setClassLoaderService( serviceRegistryHolder.getClassLoaderService() );
|
dialectFactoryImpl.setClassLoaderService( serviceRegistry.getService( ClassLoaderService.class ) );
|
||||||
dialectFactoryImpl.setDialectResolver( dialectResolver );
|
dialectFactoryImpl.setDialectResolver( dialectResolver );
|
||||||
return dialectFactoryImpl;
|
return dialectFactoryImpl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.impl.SessionImpl;
|
import org.hibernate.impl.SessionImpl;
|
||||||
import org.hibernate.jdbc.Work;
|
import org.hibernate.jdbc.Work;
|
||||||
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
||||||
|
@ -54,7 +55,7 @@ public class SequenceHiLoGeneratorNoIncrementTest extends TestCase {
|
||||||
private static final String TEST_SEQUENCE = "test_sequence";
|
private static final String TEST_SEQUENCE = "test_sequence";
|
||||||
|
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactoryImplementor sessionFactory;
|
private SessionFactoryImplementor sessionFactory;
|
||||||
private SequenceHiLoGenerator generator;
|
private SequenceHiLoGenerator generator;
|
||||||
|
|
||||||
|
@ -94,8 +95,8 @@ public class SequenceHiLoGeneratorNoIncrementTest extends TestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -103,8 +104,8 @@ public class SequenceHiLoGeneratorNoIncrementTest extends TestCase {
|
||||||
if ( sessionFactory != null ) {
|
if ( sessionFactory != null ) {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.id;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -41,7 +42,8 @@ import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.impl.SessionImpl;
|
import org.hibernate.impl.SessionImpl;
|
||||||
import org.hibernate.jdbc.Work;
|
import org.hibernate.jdbc.Work;
|
||||||
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
||||||
|
@ -54,7 +56,7 @@ public class SequenceHiLoGeneratorTest extends TestCase {
|
||||||
private static final String TEST_SEQUENCE = "test_sequence";
|
private static final String TEST_SEQUENCE = "test_sequence";
|
||||||
|
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactoryImplementor sessionFactory;
|
private SessionFactoryImplementor sessionFactory;
|
||||||
private SequenceHiLoGenerator generator;
|
private SequenceHiLoGenerator generator;
|
||||||
|
|
||||||
|
@ -93,10 +95,8 @@ public class SequenceHiLoGeneratorTest extends TestCase {
|
||||||
generator.sqlDropStrings( dialect )[0]
|
generator.sqlDropStrings( dialect )[0]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
|
sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
sessionFactory =
|
|
||||||
(SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -104,8 +104,8 @@ public class SequenceHiLoGeneratorTest extends TestCase {
|
||||||
if ( sessionFactory != null ) {
|
if ( sessionFactory != null ) {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.id;
|
package org.hibernate.id;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -41,7 +42,8 @@ import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.impl.SessionImpl;
|
import org.hibernate.impl.SessionImpl;
|
||||||
import org.hibernate.jdbc.Work;
|
import org.hibernate.jdbc.Work;
|
||||||
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
import org.hibernate.mapping.SimpleAuxiliaryDatabaseObject;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
* I went back to 3.3 source and grabbed the code/logic as it existed back then and crafted this
|
||||||
|
@ -55,7 +57,7 @@ public class TableHiLoGeneratorTest extends TestCase {
|
||||||
private static final String GEN_COLUMN = TableHiLoGenerator.DEFAULT_COLUMN_NAME;
|
private static final String GEN_COLUMN = TableHiLoGenerator.DEFAULT_COLUMN_NAME;
|
||||||
|
|
||||||
private Configuration cfg;
|
private Configuration cfg;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactoryImplementor sessionFactory;
|
private SessionFactoryImplementor sessionFactory;
|
||||||
private TableHiLoGenerator generator;
|
private TableHiLoGenerator generator;
|
||||||
|
|
||||||
|
@ -64,8 +66,8 @@ public class TableHiLoGeneratorTest extends TestCase {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
properties.setProperty( TableHiLoGenerator.TABLE, GEN_TABLE );
|
properties.setProperty( TableGenerator.TABLE, GEN_TABLE );
|
||||||
properties.setProperty( TableHiLoGenerator.COLUMN, GEN_COLUMN );
|
properties.setProperty( TableGenerator.COLUMN, GEN_COLUMN );
|
||||||
properties.setProperty( TableHiLoGenerator.MAX_LO, "3" );
|
properties.setProperty( TableHiLoGenerator.MAX_LO, "3" );
|
||||||
properties.put(
|
properties.put(
|
||||||
PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
|
PersistentIdentifierGenerator.IDENTIFIER_NORMALIZER,
|
||||||
|
@ -103,9 +105,8 @@ public class TableHiLoGeneratorTest extends TestCase {
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
sessionFactory =
|
sessionFactory = (SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistry );
|
||||||
(SessionFactoryImplementor) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,8 +114,8 @@ public class TableHiLoGeneratorTest extends TestCase {
|
||||||
if ( sessionFactory != null ) {
|
if ( sessionFactory != null ) {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
|
|
|
@ -26,7 +26,8 @@ import junit.framework.TestCase;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.H2Dialect;
|
import org.hibernate.dialect.H2Dialect;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* TODO : javadoc
|
||||||
|
@ -36,10 +37,10 @@ import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
public class SubclassProxyInterfaceTest extends TestCase {
|
public class SubclassProxyInterfaceTest extends TestCase {
|
||||||
public void testSubclassProxyInterfaces() {
|
public void testSubclassProxyInterfaces() {
|
||||||
final Configuration cfg = new Configuration()
|
final Configuration cfg = new Configuration()
|
||||||
.setProperty( Environment.DIALECT, H2Dialect.class.getName() );
|
.setProperty( Environment.DIALECT, H2Dialect.class.getName() )
|
||||||
cfg.addClass( Person.class );
|
.addClass( Person.class );
|
||||||
ServiceRegistryHolder serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
ServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() ).close();
|
cfg.buildSessionFactory( serviceRegistry ).close();
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,21 +7,22 @@ import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.Transaction;
|
import org.hibernate.Transaction;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
*/
|
*/
|
||||||
public class ConfigurationTest extends junit.framework.TestCase {
|
public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||||
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactory sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
assertNotNull( sf );
|
assertNotNull( sf );
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
@ -47,7 +48,7 @@ public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
cfg.setProperty( AnnotationConfiguration.ARTEFACT_PROCESSING_ORDER, "class" );
|
cfg.setProperty( AnnotationConfiguration.ARTEFACT_PROCESSING_ORDER, "class" );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactory sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
assertNotNull( sf );
|
assertNotNull( sf );
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
@ -71,7 +72,7 @@ public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
cfg.addAnnotatedClass( Boat.class );
|
cfg.addAnnotatedClass( Boat.class );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactory sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
assertNotNull( sf );
|
assertNotNull( sf );
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
@ -97,7 +98,7 @@ public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
cfg.setProperty( AnnotationConfiguration.ARTEFACT_PROCESSING_ORDER, "class, hbm" );
|
cfg.setProperty( AnnotationConfiguration.ARTEFACT_PROCESSING_ORDER, "class, hbm" );
|
||||||
cfg.addAnnotatedClass( Boat.class );
|
cfg.addAnnotatedClass( Boat.class );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactory sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
assertNotNull( sf );
|
assertNotNull( sf );
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
s.getTransaction().begin();
|
s.getTransaction().begin();
|
||||||
|
@ -121,7 +122,7 @@ public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
||||||
cfg.addClass( Ferry.class );
|
cfg.addClass( Ferry.class );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactory sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
assertNotNull( sf );
|
assertNotNull( sf );
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
@ -139,7 +140,7 @@ public class ConfigurationTest extends junit.framework.TestCase {
|
||||||
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
cfg.configure( "org/hibernate/test/annotations/hibernate.cfg.xml" );
|
||||||
cfg.addAnnotatedClass( Port.class );
|
cfg.addAnnotatedClass( Port.class );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactory sf = cfg.buildSessionFactory( serviceRegistry );
|
||||||
assertNotNull( sf );
|
assertNotNull( sf );
|
||||||
Session s = sf.openSession();
|
Session s = sf.openSession();
|
||||||
Transaction tx = s.beginTransaction();
|
Transaction tx = s.beginTransaction();
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations;
|
package org.hibernate.test.annotations;
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -14,18 +14,18 @@ public class SafeMappingTest extends junit.framework.TestCase {
|
||||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||||
cfg.addAnnotatedClass( IncorrectEntity.class );
|
cfg.addAnnotatedClass( IncorrectEntity.class );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
ServiceRegistryHolder serviceRegistryHolder = null;
|
ServiceRegistry serviceRegistry = null;
|
||||||
try {
|
try {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
cfg.buildSessionFactory( serviceRegistry );
|
||||||
fail( "Entity wo id should fail" );
|
fail( "Entity wo id should fail" );
|
||||||
}
|
}
|
||||||
catch (AnnotationException e) {
|
catch (AnnotationException e) {
|
||||||
//success
|
//success
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations;
|
package org.hibernate.test.annotations;
|
||||||
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -29,22 +31,25 @@ public class SecuredBindingTest extends TestCase {
|
||||||
ac.setProperties( p );
|
ac.setProperties( p );
|
||||||
ac.addAnnotatedClass( Plane.class );
|
ac.addAnnotatedClass( Plane.class );
|
||||||
SessionFactory sf;
|
SessionFactory sf;
|
||||||
ServiceRegistryHolder serviceRegistryHolder = null;
|
ServiceRegistry serviceRegistry = null;
|
||||||
try {
|
try {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( p );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( p );
|
||||||
sf = ac.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sf = ac.buildSessionFactory( serviceRegistry );
|
||||||
|
try {
|
||||||
|
sf.close();
|
||||||
|
}
|
||||||
|
catch (Exception ignore) {
|
||||||
|
}
|
||||||
fail( "Driver property overriding should work" );
|
fail( "Driver property overriding should work" );
|
||||||
sf.close();
|
|
||||||
}
|
}
|
||||||
catch (HibernateException he) {
|
catch (HibernateException he) {
|
||||||
//success
|
//success
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,14 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations;
|
package org.hibernate.test.annotations;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.Interceptor;
|
import org.hibernate.Interceptor;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
|
import org.hibernate.testing.junit.functional.annotations.HibernateTestCase;
|
||||||
|
@ -78,7 +80,7 @@ public abstract class TestCase extends HibernateTestCase {
|
||||||
return (SessionFactoryImplementor) getSessions();
|
return (SessionFactoryImplementor) getSessions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void buildConfiguration() throws Exception {
|
protected void buildConfiguration() throws Exception {
|
||||||
if ( sessions != null ) {
|
if ( sessions != null ) {
|
||||||
sessions.close();
|
sessions.close();
|
||||||
|
@ -86,7 +88,7 @@ public abstract class TestCase extends HibernateTestCase {
|
||||||
try {
|
try {
|
||||||
setCfg( new AnnotationConfiguration() );
|
setCfg( new AnnotationConfiguration() );
|
||||||
// by default use the new id generator scheme...
|
// by default use the new id generator scheme...
|
||||||
cfg.setProperty( AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
cfg.setProperty( Configuration.USE_NEW_ID_GENERATOR_MAPPINGS, "true" );
|
||||||
configure( cfg );
|
configure( cfg );
|
||||||
if ( recreateSchema() ) {
|
if ( recreateSchema() ) {
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
|
|
|
@ -31,7 +31,8 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.property.BasicPropertyAccessor;
|
import org.hibernate.property.BasicPropertyAccessor;
|
||||||
import org.hibernate.property.DirectPropertyAccessor;
|
import org.hibernate.property.DirectPropertyAccessor;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||||
import org.hibernate.tuple.entity.PojoEntityTuplizer;
|
import org.hibernate.tuple.entity.PojoEntityTuplizer;
|
||||||
|
|
||||||
|
@ -43,15 +44,15 @@ import org.hibernate.tuple.entity.PojoEntityTuplizer;
|
||||||
*/
|
*/
|
||||||
public class AccessMappingTest extends TestCase {
|
public class AccessMappingTest extends TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
cfg.addAnnotatedClass( Course1.class );
|
cfg.addAnnotatedClass( Course1.class );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
try {
|
try {
|
||||||
cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
cfg.buildSessionFactory( serviceRegistry );
|
||||||
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -73,7 +74,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
Class<?> classUnderTest = Course6.class;
|
Class<?> classUnderTest = Course6.class;
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -88,7 +89,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
Class<?> classUnderTest = Course7.class;
|
Class<?> classUnderTest = Course7.class;
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -103,7 +104,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
Class<?> classUnderTest = Course2.class;
|
Class<?> classUnderTest = Course2.class;
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -118,7 +119,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
cfg.addAnnotatedClass( Course4.class );
|
cfg.addAnnotatedClass( Course4.class );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
try {
|
try {
|
||||||
cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
cfg.buildSessionFactory( serviceRegistry );
|
||||||
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
fail( "@Id and @OneToMany are not placed consistently in test entities. SessionFactory creation should fail." );
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -131,7 +132,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
Class<?> classUnderTest = Course3.class;
|
Class<?> classUnderTest = Course3.class;
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -151,7 +152,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
Class<?> classUnderTest = Course5.class;
|
Class<?> classUnderTest = Course5.class;
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -172,7 +173,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
cfg.addAnnotatedClass( classUnderTest );
|
cfg.addAnnotatedClass( classUnderTest );
|
||||||
cfg.addAnnotatedClass( Person.class );
|
cfg.addAnnotatedClass( Person.class );
|
||||||
cfg.addAnnotatedClass( Being.class );
|
cfg.addAnnotatedClass( Being.class );
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( classUnderTest.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -187,7 +188,7 @@ public class AccessMappingTest extends TestCase {
|
||||||
cfg.addAnnotatedClass( Horse.class );
|
cfg.addAnnotatedClass( Horse.class );
|
||||||
cfg.addAnnotatedClass( Animal.class );
|
cfg.addAnnotatedClass( Animal.class );
|
||||||
|
|
||||||
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
SessionFactoryImplementor factory = ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
EntityMetamodel metaModel = factory.getEntityPersister( Animal.class.getName() )
|
EntityMetamodel metaModel = factory.getEntityPersister( Animal.class.getName() )
|
||||||
.getEntityMetamodel();
|
.getEntityMetamodel();
|
||||||
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
PojoEntityTuplizer tuplizer = ( PojoEntityTuplizer ) metaModel.getTuplizer( EntityMode.POJO );
|
||||||
|
@ -212,6 +213,6 @@ public class AccessMappingTest extends TestCase {
|
||||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||||
cfg.addAnnotatedClass( Course8.class );
|
cfg.addAnnotatedClass( Course8.class );
|
||||||
cfg.addAnnotatedClass( Student.class );
|
cfg.addAnnotatedClass( Student.class );
|
||||||
cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -23,6 +23,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.annotations.access.xml;
|
package org.hibernate.test.annotations.access.xml;
|
||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -35,7 +36,8 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.property.BasicPropertyAccessor;
|
import org.hibernate.property.BasicPropertyAccessor;
|
||||||
import org.hibernate.property.DirectPropertyAccessor;
|
import org.hibernate.property.DirectPropertyAccessor;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.tuple.entity.EntityMetamodel;
|
import org.hibernate.tuple.entity.EntityMetamodel;
|
||||||
import org.hibernate.tuple.entity.PojoEntityTuplizer;
|
import org.hibernate.tuple.entity.PojoEntityTuplizer;
|
||||||
|
|
||||||
|
@ -47,15 +49,17 @@ import org.hibernate.tuple.entity.PojoEntityTuplizer;
|
||||||
*/
|
*/
|
||||||
public class XmlAccessTest extends TestCase {
|
public class XmlAccessTest extends TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
protected void setUp() {
|
@Override
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
protected void setUp() {
|
||||||
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() {
|
@Override
|
||||||
if ( serviceRegistryHolder != null ) {
|
protected void tearDown() {
|
||||||
serviceRegistryHolder.destroy();
|
if ( serviceRegistry != null ) {
|
||||||
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +185,7 @@ public class XmlAccessTest extends TestCase {
|
||||||
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile );
|
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( configFile );
|
||||||
cfg.addInputStream( is );
|
cfg.addInputStream( is );
|
||||||
}
|
}
|
||||||
return ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
return ( SessionFactoryImplementor ) cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
// uses the first getter of the tupelizer for the assertions
|
// uses the first getter of the tupelizer for the assertions
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.backquotes;
|
package org.hibernate.test.annotations.backquotes;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -7,7 +8,8 @@ import junit.framework.TestCase;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Testcase for ANN-718 - @JoinTable / @JoinColumn fail when using backquotes in PK field name.
|
* Testcase for ANN-718 - @JoinTable / @JoinColumn fail when using backquotes in PK field name.
|
||||||
|
@ -17,18 +19,16 @@ import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
*/
|
*/
|
||||||
public class BackquoteTest extends TestCase {
|
public class BackquoteTest extends TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
serviceRegistryHolder.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBackquotes() {
|
public void testBackquotes() {
|
||||||
|
@ -36,7 +36,7 @@ public class BackquoteTest extends TestCase {
|
||||||
AnnotationConfiguration config = new AnnotationConfiguration();
|
AnnotationConfiguration config = new AnnotationConfiguration();
|
||||||
config.addAnnotatedClass(Bug.class);
|
config.addAnnotatedClass(Bug.class);
|
||||||
config.addAnnotatedClass(Category.class);
|
config.addAnnotatedClass(Category.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
catch( Exception e ) {
|
catch( Exception e ) {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
@ -58,7 +58,7 @@ public class BackquoteTest extends TestCase {
|
||||||
AnnotationConfiguration config = new AnnotationConfiguration();
|
AnnotationConfiguration config = new AnnotationConfiguration();
|
||||||
config.addAnnotatedClass(Printer.class);
|
config.addAnnotatedClass(Printer.class);
|
||||||
config.addAnnotatedClass(PrinterCable.class);
|
config.addAnnotatedClass(PrinterCable.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
fail("expected MappingException to be thrown");
|
fail("expected MappingException to be thrown");
|
||||||
}
|
}
|
||||||
//we WANT MappingException to be thrown
|
//we WANT MappingException to be thrown
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.duplicatedgenerator;
|
package org.hibernate.test.annotations.duplicatedgenerator;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -13,22 +15,22 @@ public class DuplicateTest extends TestCase {
|
||||||
public void testDuplicateEntityName() throws Exception {
|
public void testDuplicateEntityName() throws Exception {
|
||||||
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
AnnotationConfiguration cfg = new AnnotationConfiguration();
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
ServiceRegistryHolder serviceRegistryHolder = null;
|
ServiceRegistry serviceRegistry = null;
|
||||||
try {
|
try {
|
||||||
cfg.addAnnotatedClass( Flight.class );
|
cfg.addAnnotatedClass( Flight.class );
|
||||||
cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class );
|
cfg.addAnnotatedClass( org.hibernate.test.annotations.Flight.class );
|
||||||
cfg.addResource( "org/hibernate/test/annotations/orm.xml" );
|
cfg.addResource( "org/hibernate/test/annotations/orm.xml" );
|
||||||
cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/orm.xml" );
|
cfg.addResource( "org/hibernate/test/annotations/duplicatedgenerator/orm.xml" );
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
cfg.buildSessionFactory( serviceRegistry );
|
||||||
fail( "Should not be able to map the same entity name twice" );
|
fail( "Should not be able to map the same entity name twice" );
|
||||||
}
|
}
|
||||||
catch (AnnotationException ae) {
|
catch (AnnotationException ae) {
|
||||||
//success
|
//success
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,9 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.hibernate.test.annotations.fetchprofile;
|
package org.hibernate.test.annotations.fetchprofile;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
@ -31,7 +33,8 @@ import org.hibernate.MappingException;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionFactoryImplementor;
|
import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case for HHH-4812
|
* Test case for HHH-4812
|
||||||
|
@ -40,18 +43,16 @@ import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
*/
|
*/
|
||||||
public class FetchProfileTest extends TestCase {
|
public class FetchProfileTest extends TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
serviceRegistryHolder.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFetchProfileConfigured() {
|
public void testFetchProfileConfigured() {
|
||||||
|
@ -61,7 +62,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
config.addAnnotatedClass( SupportTickets.class );
|
config.addAnnotatedClass( SupportTickets.class );
|
||||||
config.addAnnotatedClass( Country.class );
|
config.addAnnotatedClass( Country.class );
|
||||||
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
||||||
serviceRegistryHolder.getServiceRegistry()
|
serviceRegistry
|
||||||
);
|
);
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
@ -81,7 +82,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
config.addAnnotatedClass( Country.class );
|
config.addAnnotatedClass( Country.class );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -96,7 +97,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
config.addAnnotatedClass( Country.class );
|
config.addAnnotatedClass( Country.class );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -111,7 +112,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
config.addAnnotatedClass( Country.class );
|
config.addAnnotatedClass( Country.class );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -129,7 +130,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
.getResourceAsStream( "org/hibernate/test/annotations/fetchprofile/mappings.hbm.xml" );
|
.getResourceAsStream( "org/hibernate/test/annotations/fetchprofile/mappings.hbm.xml" );
|
||||||
config.addInputStream( is );
|
config.addInputStream( is );
|
||||||
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
||||||
serviceRegistryHolder.getServiceRegistry()
|
serviceRegistry
|
||||||
);
|
);
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
@ -143,7 +144,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
config.addAnnotatedClass( Order.class );
|
config.addAnnotatedClass( Order.class );
|
||||||
config.addAnnotatedClass( Country.class );
|
config.addAnnotatedClass( Country.class );
|
||||||
try {
|
try {
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -159,7 +160,7 @@ public class FetchProfileTest extends TestCase {
|
||||||
config.addAnnotatedClass( Country.class );
|
config.addAnnotatedClass( Country.class );
|
||||||
config.addPackage( Customer.class.getPackage().getName() );
|
config.addPackage( Customer.class.getPackage().getName() );
|
||||||
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
SessionFactoryImplementor sessionImpl = ( SessionFactoryImplementor ) config.buildSessionFactory(
|
||||||
serviceRegistryHolder.getServiceRegistry()
|
serviceRegistry
|
||||||
);
|
);
|
||||||
|
|
||||||
assertTrue(
|
assertTrue(
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
package org.hibernate.test.annotations.fkcircularity;
|
package org.hibernate.test.annotations.fkcircularity;
|
||||||
import static org.hibernate.TestLogger.LOG;
|
|
||||||
import java.io.PrintWriter;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.io.StringWriter;
|
import java.io.PrintWriter;
|
||||||
import junit.framework.TestCase;
|
import java.io.StringWriter;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import junit.framework.TestCase;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.dialect.HSQLDialect;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.HSQLDialect;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case for ANN-722 and ANN-730.
|
* Test case for ANN-722 and ANN-730.
|
||||||
|
@ -17,18 +19,16 @@ import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
*/
|
*/
|
||||||
public class FkCircularityTest extends TestCase {
|
public class FkCircularityTest extends TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
serviceRegistryHolder.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testJoinedSublcassesInPK() {
|
public void testJoinedSublcassesInPK() {
|
||||||
|
@ -38,7 +38,7 @@ public class FkCircularityTest extends TestCase {
|
||||||
config.addAnnotatedClass(B.class);
|
config.addAnnotatedClass(B.class);
|
||||||
config.addAnnotatedClass(C.class);
|
config.addAnnotatedClass(C.class);
|
||||||
config.addAnnotatedClass(D.class);
|
config.addAnnotatedClass(D.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
String[] schema = config
|
String[] schema = config
|
||||||
.generateSchemaCreationScript(new SQLServerDialect());
|
.generateSchemaCreationScript(new SQLServerDialect());
|
||||||
for (String s : schema) {
|
for (String s : schema) {
|
||||||
|
@ -60,7 +60,7 @@ public class FkCircularityTest extends TestCase {
|
||||||
config.addAnnotatedClass(ClassB.class);
|
config.addAnnotatedClass(ClassB.class);
|
||||||
config.addAnnotatedClass(ClassC.class);
|
config.addAnnotatedClass(ClassC.class);
|
||||||
config.addAnnotatedClass(ClassD.class);
|
config.addAnnotatedClass(ClassD.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
String[] schema = config
|
String[] schema = config
|
||||||
.generateSchemaCreationScript(new HSQLDialect());
|
.generateSchemaCreationScript(new HSQLDialect());
|
||||||
for (String s : schema) {
|
for (String s : schema) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// $Id$
|
// $Id$
|
||||||
package org.hibernate.test.annotations.namingstrategy;
|
package org.hibernate.test.annotations.namingstrategy;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
|
@ -10,7 +11,8 @@ import org.hibernate.cfg.EJB3NamingStrategy;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.cfg.Mappings;
|
import org.hibernate.cfg.Mappings;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test harness for ANN-716.
|
* Test harness for ANN-716.
|
||||||
|
@ -19,18 +21,16 @@ import org.hibernate.test.common.ServiceRegistryHolder;
|
||||||
*/
|
*/
|
||||||
public class NamingStrategyTest extends TestCase {
|
public class NamingStrategyTest extends TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() {
|
protected void tearDown() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if (serviceRegistry != null) ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
serviceRegistryHolder.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testWithCustomNamingStrategy() throws Exception {
|
public void testWithCustomNamingStrategy() throws Exception {
|
||||||
|
@ -39,7 +39,7 @@ public class NamingStrategyTest extends TestCase {
|
||||||
config.setNamingStrategy(new DummyNamingStrategy());
|
config.setNamingStrategy(new DummyNamingStrategy());
|
||||||
config.addAnnotatedClass(Address.class);
|
config.addAnnotatedClass(Address.class);
|
||||||
config.addAnnotatedClass(Person.class);
|
config.addAnnotatedClass(Person.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
catch( Exception e ) {
|
catch( Exception e ) {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
@ -55,7 +55,7 @@ public class NamingStrategyTest extends TestCase {
|
||||||
config.setNamingStrategy(EJB3NamingStrategy.INSTANCE);
|
config.setNamingStrategy(EJB3NamingStrategy.INSTANCE);
|
||||||
config.addAnnotatedClass(A.class);
|
config.addAnnotatedClass(A.class);
|
||||||
config.addAnnotatedClass(AddressEntry.class);
|
config.addAnnotatedClass(AddressEntry.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
Mappings mappings = config.createMappings();
|
Mappings mappings = config.createMappings();
|
||||||
boolean foundIt = false;
|
boolean foundIt = false;
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ public class NamingStrategyTest extends TestCase {
|
||||||
AnnotationConfiguration config = new AnnotationConfiguration();
|
AnnotationConfiguration config = new AnnotationConfiguration();
|
||||||
config.addAnnotatedClass(Address.class);
|
config.addAnnotatedClass(Address.class);
|
||||||
config.addAnnotatedClass(Person.class);
|
config.addAnnotatedClass(Person.class);
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
catch( Exception e ) {
|
catch( Exception e ) {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
//$Id$
|
//$Id$
|
||||||
package org.hibernate.test.annotations.onetoone;
|
package org.hibernate.test.annotations.onetoone;
|
||||||
|
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Emmanuel Bernard
|
* @author Emmanuel Bernard
|
||||||
|
@ -15,19 +16,19 @@ public class OneToOneErrorTest extends junit.framework.TestCase {
|
||||||
cfg.addAnnotatedClass( Show.class )
|
cfg.addAnnotatedClass( Show.class )
|
||||||
.addAnnotatedClass( ShowDescription.class );
|
.addAnnotatedClass( ShowDescription.class );
|
||||||
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
cfg.setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
ServiceRegistryHolder serviceRegistryHolder = null;
|
ServiceRegistry serviceRegistry = null;
|
||||||
try {
|
try {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
SessionFactory sf = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
cfg.buildSessionFactory( serviceRegistry );
|
||||||
fail( "Wrong mappedBy does not fail property" );
|
fail( "Wrong mappedBy does not fail property" );
|
||||||
}
|
}
|
||||||
catch (AnnotationException e) {
|
catch (AnnotationException e) {
|
||||||
//success
|
//success
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,13 @@
|
||||||
//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
|
//$Id: A320.java 14736 2008-06-04 14:23:42Z hardy.ferentschik $
|
||||||
package org.hibernate.test.annotations.onetoone.primarykey;
|
package org.hibernate.test.annotations.onetoone.primarykey;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.hibernate.cfg.AnnotationConfiguration;
|
import org.hibernate.cfg.AnnotationConfiguration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.SQLServerDialect;
|
import org.hibernate.dialect.SQLServerDialect;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test harness for ANN-742.
|
* Test harness for ANN-742.
|
||||||
|
@ -17,13 +19,13 @@ public class NullablePrimaryKeyTest extends TestCase {
|
||||||
|
|
||||||
public void testGeneratedSql() {
|
public void testGeneratedSql() {
|
||||||
|
|
||||||
ServiceRegistryHolder serviceRegistryHolder = null;
|
ServiceRegistry serviceRegistry = null;
|
||||||
try {
|
try {
|
||||||
AnnotationConfiguration config = new AnnotationConfiguration();
|
AnnotationConfiguration config = new AnnotationConfiguration();
|
||||||
config.addAnnotatedClass(Address.class);
|
config.addAnnotatedClass(Address.class);
|
||||||
config.addAnnotatedClass(Person.class);
|
config.addAnnotatedClass(Person.class);
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
config.buildSessionFactory( serviceRegistry );
|
||||||
String[] schema = config
|
String[] schema = config
|
||||||
.generateSchemaCreationScript(new SQLServerDialect());
|
.generateSchemaCreationScript(new SQLServerDialect());
|
||||||
for (String s : schema) {
|
for (String s : schema) {
|
||||||
|
@ -36,8 +38,8 @@ public class NullablePrimaryKeyTest extends TestCase {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,13 +20,15 @@
|
||||||
* Boston, MA 02110-1301 USA\
|
* Boston, MA 02110-1301 USA\
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.cfg;
|
package org.hibernate.test.cfg;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Id;
|
import javax.persistence.Id;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.testing.junit.UnitTestCase;
|
import org.hibernate.testing.junit.UnitTestCase;
|
||||||
import org.hibernate.util.SerializationHelper;
|
import org.hibernate.util.SerializationHelper;
|
||||||
|
|
||||||
|
@ -102,18 +104,18 @@ public class ConfigurationSerializationTest extends UnitTestCase {
|
||||||
cfg = ( Configuration ) SerializationHelper.deserialize( bytes );
|
cfg = ( Configuration ) SerializationHelper.deserialize( bytes );
|
||||||
|
|
||||||
SessionFactory factory = null;
|
SessionFactory factory = null;
|
||||||
ServiceRegistryHolder serviceRegistryHolder = null;
|
ServiceRegistry serviceRegistry = null;
|
||||||
try {
|
try {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
// try to build SF
|
// try to build SF
|
||||||
factory = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry());
|
factory = cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( factory != null ) {
|
if ( factory != null ) {
|
||||||
factory.close();
|
factory.close();
|
||||||
}
|
}
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,12 +20,11 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.cfg.persister;
|
package org.hibernate.test.cfg.persister;
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
|
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.testing.junit.UnitTestCase;
|
import org.hibernate.testing.junit.UnitTestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,9 +39,9 @@ public class PersisterClassProviderTest extends UnitTestCase {
|
||||||
|
|
||||||
Configuration cfg = new Configuration();
|
Configuration cfg = new Configuration();
|
||||||
cfg.addAnnotatedClass( Gate.class );
|
cfg.addAnnotatedClass( Gate.class );
|
||||||
ServiceRegistryHolder serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
ServiceRegistry serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
//no exception as the GoofyPersisterClassProvider is not set
|
//no exception as the GoofyPersisterClassProvider is not set
|
||||||
SessionFactory sessionFactory = cfg.buildSessionFactory(serviceRegistryHolder.getServiceRegistry());
|
SessionFactory sessionFactory = cfg.buildSessionFactory( serviceRegistry );
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ public class PersisterClassProviderTest extends UnitTestCase {
|
||||||
cfg.addAnnotatedClass( Gate.class );
|
cfg.addAnnotatedClass( Gate.class );
|
||||||
cfg.setPersisterClassProvider( new GoofyPersisterClassProvider() );
|
cfg.setPersisterClassProvider( new GoofyPersisterClassProvider() );
|
||||||
try {
|
try {
|
||||||
sessionFactory = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = cfg.buildSessionFactory( serviceRegistry );
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -66,7 +65,7 @@ public class PersisterClassProviderTest extends UnitTestCase {
|
||||||
cfg.addAnnotatedClass( Window.class );
|
cfg.addAnnotatedClass( Window.class );
|
||||||
cfg.setPersisterClassProvider( new GoofyPersisterClassProvider() );
|
cfg.setPersisterClassProvider( new GoofyPersisterClassProvider() );
|
||||||
try {
|
try {
|
||||||
sessionFactory = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = cfg.buildSessionFactory( serviceRegistry );
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
catch ( MappingException e ) {
|
catch ( MappingException e ) {
|
||||||
|
@ -76,8 +75,8 @@ public class PersisterClassProviderTest extends UnitTestCase {
|
||||||
( (GoofyException) e.getCause() ).getValue() );
|
( (GoofyException) e.getCause() ).getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,25 +1,27 @@
|
||||||
package org.hibernate.test.instrument.cases;
|
package org.hibernate.test.instrument.cases;
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractExecutable implements Executable {
|
public abstract class AbstractExecutable implements Executable {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactory factory;
|
private SessionFactory factory;
|
||||||
|
|
||||||
public final void prepare() {
|
public final void prepare() {
|
||||||
Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
Configuration cfg = new Configuration().setProperty( Environment.HBM2DDL_AUTO, "create-drop" );
|
||||||
String[] resources = getResources();
|
String[] resources = getResources();
|
||||||
for ( int i = 0; i < resources.length; i++ ) {
|
for ( String resource : resources ) {
|
||||||
cfg.addResource( resources[i] );
|
cfg.addResource( resource );
|
||||||
}
|
}
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( cfg.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( cfg.getProperties() );
|
||||||
factory = cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
factory = cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void complete() {
|
public final void complete() {
|
||||||
|
@ -28,9 +30,9 @@ public abstract class AbstractExecutable implements Executable {
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
factory.close();
|
factory.close();
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
*
|
*
|
||||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||||
* indicated by the @author tags or express copyright attribution
|
* indicated by the @author tags or express copyright attribution
|
||||||
* statements applied by the authors. All third-party contributions are
|
* statements applied by the authors. All third-party contributions are
|
||||||
* distributed under license by Red Hat Inc.
|
* distributed under license by Red Hat Inc.
|
||||||
|
@ -21,57 +21,28 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.common;
|
package org.hibernate.testing;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.jdbc.internal.JdbcServicesImpl;
|
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
|
||||||
import org.hibernate.internal.util.config.ConfigurationHelper;
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
||||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
|
||||||
import org.hibernate.service.internal.ServiceRegistryImpl;
|
import org.hibernate.service.internal.ServiceRegistryImpl;
|
||||||
import org.hibernate.service.spi.ServiceRegistry;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Gail Badner
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class ServiceRegistryHolder {
|
public class ServiceRegistryBuilder {
|
||||||
private final ServiceRegistryImpl serviceRegistry;
|
public static ServiceRegistryImpl buildServiceRegistry(Map serviceRegistryConfig) {
|
||||||
private final Properties properties;
|
Properties properties = new Properties();
|
||||||
|
properties.putAll( serviceRegistryConfig );
|
||||||
public ServiceRegistryHolder(Map props) {
|
|
||||||
properties = new Properties();
|
|
||||||
properties.putAll( props );
|
|
||||||
Environment.verifyProperties( properties );
|
Environment.verifyProperties( properties );
|
||||||
ConfigurationHelper.resolvePlaceHolders( properties );
|
ConfigurationHelper.resolvePlaceHolders( properties );
|
||||||
serviceRegistry = new ServiceRegistryImpl( properties );
|
return new ServiceRegistryImpl( properties );
|
||||||
properties.putAll( serviceRegistry.getService( JdbcServices.class ).getDialect().getDefaultProperties() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Properties getProperties() {
|
public static void destroy(ServiceRegistry serviceRegistry) {
|
||||||
return properties;
|
( (ServiceRegistryImpl) serviceRegistry ).destroy();
|
||||||
}
|
|
||||||
|
|
||||||
public ServiceRegistry getServiceRegistry() {
|
|
||||||
return serviceRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JdbcServices getJdbcServices() {
|
|
||||||
return serviceRegistry.getService( JdbcServices.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
public JdbcServicesImpl getJdbcServicesImpl() {
|
|
||||||
return ( JdbcServicesImpl ) getJdbcServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassLoaderService getClassLoaderService() {
|
|
||||||
return serviceRegistry.getService( ClassLoaderService.class );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void destroy() {
|
|
||||||
if ( serviceRegistry != null ) {
|
|
||||||
serviceRegistry.destroy();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,12 +20,12 @@
|
||||||
* Free Software Foundation, Inc.
|
* Free Software Foundation, Inc.
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.testing.junit;
|
package org.hibernate.testing.junit;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import junit.framework.AssertionFailedError;
|
import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -36,7 +36,7 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.service.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.service.spi.ServiceRegistry;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,7 @@ import org.jboss.logging.Logger;
|
||||||
*/
|
*/
|
||||||
public abstract class UnitTestCase extends junit.framework.TestCase {
|
public abstract class UnitTestCase extends junit.framework.TestCase {
|
||||||
|
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
public UnitTestCase(String string) {
|
public UnitTestCase(String string) {
|
||||||
super( string );
|
super( string );
|
||||||
|
@ -87,17 +87,17 @@ public abstract class UnitTestCase extends junit.framework.TestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void tearDown() throws Exception {
|
protected void tearDown() throws Exception {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
serviceRegistryHolder = null;
|
serviceRegistry = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServiceRegistry getServiceRegistry() {
|
protected ServiceRegistry getServiceRegistry() {
|
||||||
if ( serviceRegistryHolder == null ) {
|
if ( serviceRegistry == null ) {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
return serviceRegistryHolder.getServiceRegistry();
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JdbcServices getJdbcServices() {
|
protected JdbcServices getJdbcServices() {
|
||||||
|
@ -121,9 +121,8 @@ public abstract class UnitTestCase extends junit.framework.TestCase {
|
||||||
// additional assertions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// additional assertions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
public static void assertElementTypeAssignability(java.util.Collection collection, Class clazz) throws AssertionFailedError {
|
public static void assertElementTypeAssignability(java.util.Collection collection, Class clazz) throws AssertionFailedError {
|
||||||
Iterator itr = collection.iterator();
|
for ( Object aCollection : collection ) {
|
||||||
while ( itr.hasNext() ) {
|
assertClassAssignability( aCollection.getClass(), clazz );
|
||||||
assertClassAssignability( itr.next().getClass(), clazz );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.testing.junit.functional;
|
package org.hibernate.testing.junit.functional;
|
||||||
|
|
||||||
import java.sql.Blob;
|
import java.sql.Blob;
|
||||||
import java.sql.Clob;
|
import java.sql.Clob;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -39,7 +40,7 @@ import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.mapping.SimpleValue;
|
import org.hibernate.mapping.SimpleValue;
|
||||||
import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
|
import org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator;
|
||||||
import org.hibernate.service.spi.ServiceRegistry;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
|
@ -53,8 +54,8 @@ public class ExecutionEnvironment {
|
||||||
private final ExecutionEnvironment.Settings settings;
|
private final ExecutionEnvironment.Settings settings;
|
||||||
|
|
||||||
private Map conectionProviderInjectionProperties;
|
private Map conectionProviderInjectionProperties;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
|
||||||
private Configuration configuration;
|
private Configuration configuration;
|
||||||
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
private boolean allowRebuild;
|
private boolean allowRebuild;
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ public class ExecutionEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServiceRegistry getServiceRegistry() {
|
public ServiceRegistry getServiceRegistry() {
|
||||||
return serviceRegistryHolder.getServiceRegistry();
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionFactory getSessionFactory() {
|
public SessionFactory getSessionFactory() {
|
||||||
|
@ -115,8 +116,8 @@ public class ExecutionEnvironment {
|
||||||
|
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( getServiceRegistryProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( getServiceRegistryProperties() );
|
||||||
sessionFactory = configuration.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = configuration.buildSessionFactory( serviceRegistry );
|
||||||
|
|
||||||
settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
|
settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
|
||||||
}
|
}
|
||||||
|
@ -184,12 +185,11 @@ public class ExecutionEnvironment {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
sessionFactory = null;
|
sessionFactory = null;
|
||||||
}
|
}
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
serviceRegistryHolder = null;
|
|
||||||
}
|
}
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( getServiceRegistryProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( getServiceRegistryProperties() );
|
||||||
sessionFactory = configuration.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = configuration.buildSessionFactory( serviceRegistry );
|
||||||
settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
|
settings.afterSessionFactoryBuilt( ( SessionFactoryImplementor ) sessionFactory );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,9 +198,9 @@ public class ExecutionEnvironment {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
sessionFactory = null;
|
sessionFactory = null;
|
||||||
}
|
}
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
serviceRegistryHolder = null;
|
serviceRegistry = null;
|
||||||
}
|
}
|
||||||
configuration = null;
|
configuration = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// $Id$
|
// $Id$
|
||||||
|
|
||||||
package org.hibernate.testing.junit.functional.annotations;
|
package org.hibernate.testing.junit.functional.annotations;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
@ -39,7 +39,7 @@ import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.jdbc.Work;
|
import org.hibernate.jdbc.Work;
|
||||||
import org.hibernate.service.spi.ServiceRegistry;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.testing.junit.DialectChecks;
|
import org.hibernate.testing.junit.DialectChecks;
|
||||||
import org.hibernate.testing.junit.FailureExpected;
|
import org.hibernate.testing.junit.FailureExpected;
|
||||||
import org.hibernate.testing.junit.RequiresDialect;
|
import org.hibernate.testing.junit.RequiresDialect;
|
||||||
|
@ -58,7 +58,7 @@ public abstract class HibernateTestCase extends TestCase {
|
||||||
|
|
||||||
protected static Configuration cfg;
|
protected static Configuration cfg;
|
||||||
private static Class<?> lastTestClass;
|
private static Class<?> lastTestClass;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
public HibernateTestCase() {
|
public HibernateTestCase() {
|
||||||
super();
|
super();
|
||||||
|
@ -146,10 +146,10 @@ public abstract class HibernateTestCase extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServiceRegistry getServiceRegistry() {
|
protected ServiceRegistry getServiceRegistry() {
|
||||||
if ( serviceRegistryHolder == null ) {
|
if ( serviceRegistry == null ) {
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
}
|
}
|
||||||
return serviceRegistryHolder.getServiceRegistry();
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected JdbcServices getJdbcServices() {
|
protected JdbcServices getJdbcServices() {
|
||||||
|
@ -275,9 +275,9 @@ public abstract class HibernateTestCase extends TestCase {
|
||||||
protected abstract void handleUnclosedResources();
|
protected abstract void handleUnclosedResources();
|
||||||
|
|
||||||
protected void closeResources() {
|
protected void closeResources() {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
serviceRegistryHolder = null;
|
serviceRegistry = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package org.hibernate.envers.test;
|
package org.hibernate.envers.test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -9,7 +10,8 @@ import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.AuditReaderFactory;
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -19,20 +21,20 @@ import org.testng.annotations.Parameters;
|
||||||
/**
|
/**
|
||||||
* Base class for testing envers with Session when the same session and
|
* Base class for testing envers with Session when the same session and
|
||||||
* auditReader must be used for the hole test.
|
* auditReader must be used for the hole test.
|
||||||
*
|
*
|
||||||
* @author Hernán Chanfreau
|
* @author Hernán Chanfreau
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractOneSessionTest {
|
public abstract class AbstractOneSessionTest {
|
||||||
|
|
||||||
|
|
||||||
protected Configuration config;
|
protected Configuration config;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
private Session session ;
|
private Session session ;
|
||||||
private AuditReader auditReader;
|
private AuditReader auditReader;
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@Parameters("auditStrategy")
|
@Parameters("auditStrategy")
|
||||||
public void init(@Optional String auditStrategy) throws URISyntaxException {
|
public void init(@Optional String auditStrategy) throws URISyntaxException {
|
||||||
|
@ -45,35 +47,35 @@ public abstract class AbstractOneSessionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initMappings();
|
this.initMappings();
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
sessionFactory = config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = config.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
||||||
|
|
||||||
protected String getHibernateConfigurationFileName(){
|
protected String getHibernateConfigurationFileName(){
|
||||||
return "hibernate.test.session-cfg.xml";
|
return "hibernate.test.session-cfg.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SessionFactory getSessionFactory(){
|
private SessionFactory getSessionFactory(){
|
||||||
return sessionFactory;
|
return sessionFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void closeSessionFactory() {
|
public void closeSessionFactory() {
|
||||||
try {
|
try {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
serviceRegistryHolder = null;
|
serviceRegistry = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new session and auditReader only if there is nothing created
|
* Creates a new session and auditReader only if there is nothing created
|
||||||
* before
|
* before
|
||||||
|
@ -92,8 +94,8 @@ public abstract class AbstractOneSessionTest {
|
||||||
public void forceNewSession() {
|
public void forceNewSession() {
|
||||||
session = getSessionFactory().openSession();
|
session = getSessionFactory().openSession();
|
||||||
auditReader = AuditReaderFactory.get(session);
|
auditReader = AuditReaderFactory.get(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Session getSession() {
|
protected Session getSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
@ -103,7 +105,7 @@ public abstract class AbstractOneSessionTest {
|
||||||
protected AuditReader getAuditReader() {
|
protected AuditReader getAuditReader() {
|
||||||
return auditReader;
|
return auditReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
package org.hibernate.envers.test;
|
package org.hibernate.envers.test;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -9,7 +10,8 @@ import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.envers.AuditReader;
|
import org.hibernate.envers.AuditReader;
|
||||||
import org.hibernate.envers.AuditReaderFactory;
|
import org.hibernate.envers.AuditReaderFactory;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.testng.annotations.AfterClass;
|
import org.testng.annotations.AfterClass;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.BeforeMethod;
|
import org.testng.annotations.BeforeMethod;
|
||||||
|
@ -18,24 +20,24 @@ import org.testng.annotations.Parameters;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for testing envers with Session.
|
* Base class for testing envers with Session.
|
||||||
*
|
*
|
||||||
* @author Hernán Chanfreau
|
* @author Hernán Chanfreau
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractSessionTest {
|
public abstract class AbstractSessionTest {
|
||||||
|
|
||||||
protected Configuration config;
|
protected Configuration config;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
private SessionFactory sessionFactory;
|
private SessionFactory sessionFactory;
|
||||||
private Session session ;
|
private Session session ;
|
||||||
private AuditReader auditReader;
|
private AuditReader auditReader;
|
||||||
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@Parameters("auditStrategy")
|
@Parameters("auditStrategy")
|
||||||
public void init(@Optional String auditStrategy) throws URISyntaxException {
|
public void init(@Optional String auditStrategy) throws URISyntaxException {
|
||||||
config = new Configuration();
|
config = new Configuration();
|
||||||
URL url = Thread.currentThread().getContextClassLoader().getResource(getHibernateConfigurationFileName());
|
URL url = Thread.currentThread().getContextClassLoader().getResource(getHibernateConfigurationFileName());
|
||||||
config.configure(new File(url.toURI()));
|
config.configure(new File(url.toURI()));
|
||||||
|
|
||||||
if (auditStrategy != null && !"".equals(auditStrategy)) {
|
if (auditStrategy != null && !"".equals(auditStrategy)) {
|
||||||
|
@ -43,16 +45,16 @@ public abstract class AbstractSessionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initMappings();
|
this.initMappings();
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
sessionFactory = config.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
sessionFactory = config.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
protected abstract void initMappings() throws MappingException, URISyntaxException ;
|
||||||
|
|
||||||
protected String getHibernateConfigurationFileName(){
|
protected String getHibernateConfigurationFileName(){
|
||||||
return "hibernate.test.session-cfg.xml";
|
return "hibernate.test.session-cfg.xml";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private SessionFactory getSessionFactory(){
|
private SessionFactory getSessionFactory(){
|
||||||
|
@ -65,21 +67,21 @@ public abstract class AbstractSessionTest {
|
||||||
session = getSessionFactory().openSession();
|
session = getSessionFactory().openSession();
|
||||||
auditReader = AuditReaderFactory.get(session);
|
auditReader = AuditReaderFactory.get(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public void closeSessionFactory() {
|
public void closeSessionFactory() {
|
||||||
try {
|
try {
|
||||||
sessionFactory.close();
|
sessionFactory.close();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
serviceRegistryHolder = null;
|
serviceRegistry = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Session getSession() {
|
protected Session getSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.cache.infinispan.collection;
|
package org.hibernate.test.cache.infinispan.collection;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
|
@ -48,10 +49,12 @@ import org.hibernate.cache.infinispan.util.CacheAdapter;
|
||||||
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
|
import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
|
||||||
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl;
|
import org.hibernate.test.cache.infinispan.functional.cluster.DualNodeJtaTransactionManagerImpl;
|
||||||
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.util.ComparableComparator;
|
import org.hibernate.util.ComparableComparator;
|
||||||
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
||||||
|
|
||||||
|
@ -513,7 +516,7 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
|
||||||
private final String configResource;
|
private final String configResource;
|
||||||
private final String configName;
|
private final String configName;
|
||||||
private String preferIPv4Stack;
|
private String preferIPv4Stack;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
public AccessStrategyTestSetup( Test test,
|
public AccessStrategyTestSetup( Test test,
|
||||||
String configName ) {
|
String configName ) {
|
||||||
|
@ -536,13 +539,13 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
|
||||||
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
|
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
|
||||||
System.setProperty(PREFER_IPV4STACK, "true");
|
System.setProperty(PREFER_IPV4STACK, "true");
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder(Environment.getProperties());
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(Environment.getProperties());
|
||||||
|
|
||||||
localCfg = createConfiguration(configName, configResource);
|
localCfg = createConfiguration(configName, configResource);
|
||||||
localRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistryHolder.getJdbcServicesImpl(), localCfg);
|
localRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistry.getService(JdbcServices.class), localCfg);
|
||||||
|
|
||||||
remoteCfg = createConfiguration(configName, configResource);
|
remoteCfg = createConfiguration(configName, configResource);
|
||||||
remoteRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistryHolder.getJdbcServicesImpl(), remoteCfg);
|
remoteRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistry.getService(JdbcServices.class), remoteCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -559,8 +562,8 @@ public abstract class AbstractCollectionRegionAccessStrategyTestCase extends Abs
|
||||||
|
|
||||||
if (remoteRegionFactory != null) remoteRegionFactory.stop();
|
if (remoteRegionFactory != null) remoteRegionFactory.stop();
|
||||||
} finally {
|
} finally {
|
||||||
if (serviceRegistryHolder != null) {
|
if (serviceRegistry != null) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
|
* Copyright (c) 2007, Red Hat, Inc. and/or it's affiliates or third-party contributors as
|
||||||
* indicated by the @author tags or express copyright attribution
|
* indicated by the @author tags or express copyright attribution
|
||||||
* statements applied by the authors. All third-party contributions are
|
* statements applied by the authors. All third-party contributions are
|
||||||
* distributed under license by Red Hat, Inc. and/or it's affiliates.
|
* distributed under license by Red Hat, Inc. and/or it's affiliates.
|
||||||
*
|
*
|
||||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.cache.infinispan.entity;
|
package org.hibernate.test.cache.infinispan.entity;
|
||||||
|
|
||||||
import static org.hibernate.TestLogger.LOG;
|
import static org.hibernate.TestLogger.LOG;
|
||||||
import java.util.concurrent.CountDownLatch;
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -40,9 +41,11 @@ import org.hibernate.cache.infinispan.util.CacheAdapter;
|
||||||
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
import org.hibernate.cache.infinispan.util.FlagAdapter;
|
||||||
import org.hibernate.cfg.Configuration;
|
import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
|
import org.hibernate.test.cache.infinispan.AbstractNonFunctionalTestCase;
|
||||||
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
import org.hibernate.test.cache.infinispan.util.CacheTestUtil;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.hibernate.util.ComparableComparator;
|
import org.hibernate.util.ComparableComparator;
|
||||||
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
import org.infinispan.transaction.tm.BatchModeTransactionManager;
|
||||||
|
|
||||||
|
@ -631,7 +634,7 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
|
||||||
private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
|
private static final String PREFER_IPV4STACK = "java.net.preferIPv4Stack";
|
||||||
private final String configName;
|
private final String configName;
|
||||||
private String preferIPv4Stack;
|
private String preferIPv4Stack;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
public AccessStrategyTestSetup( Test test,
|
public AccessStrategyTestSetup( Test test,
|
||||||
String configName ) {
|
String configName ) {
|
||||||
|
@ -652,13 +655,13 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
|
||||||
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
|
preferIPv4Stack = System.getProperty(PREFER_IPV4STACK);
|
||||||
System.setProperty(PREFER_IPV4STACK, "true");
|
System.setProperty(PREFER_IPV4STACK, "true");
|
||||||
|
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder(Environment.getProperties());
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry(Environment.getProperties());
|
||||||
|
|
||||||
localCfg = createConfiguration(configName);
|
localCfg = createConfiguration(configName);
|
||||||
localRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistryHolder.getJdbcServicesImpl(), localCfg);
|
localRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistry.getService(JdbcServices.class), localCfg);
|
||||||
|
|
||||||
remoteCfg = createConfiguration(configName);
|
remoteCfg = createConfiguration(configName);
|
||||||
remoteRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistryHolder.getJdbcServicesImpl(), remoteCfg);
|
remoteRegionFactory = CacheTestUtil.startRegionFactory(serviceRegistry.getService(JdbcServices.class), remoteCfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -670,8 +673,8 @@ public abstract class AbstractEntityRegionAccessStrategyTestCase extends Abstrac
|
||||||
|
|
||||||
if (remoteRegionFactory != null) remoteRegionFactory.stop();
|
if (remoteRegionFactory != null) remoteRegionFactory.stop();
|
||||||
} finally {
|
} finally {
|
||||||
if (serviceRegistryHolder != null) {
|
if (serviceRegistry != null) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy(serviceRegistry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.cache.infinispan.tm;
|
package org.hibernate.test.cache.infinispan.tm;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -43,9 +44,10 @@ import org.hibernate.cfg.Configuration;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
|
import org.hibernate.service.spi.ServiceRegistry;
|
||||||
import org.hibernate.stat.Statistics;
|
import org.hibernate.stat.Statistics;
|
||||||
import org.hibernate.test.cache.infinispan.functional.Item;
|
import org.hibernate.test.cache.infinispan.functional.Item;
|
||||||
import org.hibernate.test.common.ServiceRegistryHolder;
|
import org.hibernate.testing.ServiceRegistryBuilder;
|
||||||
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
|
import org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup;
|
||||||
import org.infinispan.util.logging.Log;
|
import org.infinispan.util.logging.Log;
|
||||||
import org.infinispan.util.logging.LogFactory;
|
import org.infinispan.util.logging.LogFactory;
|
||||||
|
@ -69,12 +71,12 @@ public class JBossStandaloneJtaExampleTest extends TestCase {
|
||||||
private static final JBossStandaloneJTAManagerLookup lookup = new JBossStandaloneJTAManagerLookup();
|
private static final JBossStandaloneJTAManagerLookup lookup = new JBossStandaloneJTAManagerLookup();
|
||||||
Context ctx;
|
Context ctx;
|
||||||
Main jndiServer;
|
Main jndiServer;
|
||||||
private ServiceRegistryHolder serviceRegistryHolder;
|
private ServiceRegistry serviceRegistry;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
serviceRegistryHolder = new ServiceRegistryHolder( Environment.getProperties() );
|
serviceRegistry = ServiceRegistryBuilder.buildServiceRegistry( Environment.getProperties() );
|
||||||
jndiServer = startJndiServer();
|
jndiServer = startJndiServer();
|
||||||
ctx = createJndiContext();
|
ctx = createJndiContext();
|
||||||
bindTransactionManager();
|
bindTransactionManager();
|
||||||
|
@ -90,8 +92,8 @@ public class JBossStandaloneJtaExampleTest extends TestCase {
|
||||||
jndiServer.stop();
|
jndiServer.stop();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
if ( serviceRegistryHolder != null ) {
|
if ( serviceRegistry != null ) {
|
||||||
serviceRegistryHolder.destroy();
|
ServiceRegistryBuilder.destroy( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -270,7 +272,7 @@ public class JBossStandaloneJtaExampleTest extends TestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SessionFactory buildSessionFactory() {
|
private SessionFactory buildSessionFactory() {
|
||||||
// Extra options located in src/test/resources/hibernate.properties
|
// Extra options located in src/test/resources/hibernate.properties
|
||||||
Configuration cfg = new Configuration();
|
Configuration cfg = new Configuration();
|
||||||
cfg.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
|
cfg.setProperty(Environment.DIALECT, "org.hibernate.dialect.HSQLDialect");
|
||||||
cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
|
cfg.setProperty(Environment.HBM2DDL_AUTO, "create-drop");
|
||||||
|
@ -298,6 +300,6 @@ public class JBossStandaloneJtaExampleTest extends TestCase {
|
||||||
Collection coll = (Collection) iter.next();
|
Collection coll = (Collection) iter.next();
|
||||||
cfg.setCollectionCacheConcurrencyStrategy(coll.getRole(), "transactional");
|
cfg.setCollectionCacheConcurrencyStrategy(coll.getRole(), "transactional");
|
||||||
}
|
}
|
||||||
return cfg.buildSessionFactory( serviceRegistryHolder.getServiceRegistry() );
|
return cfg.buildSessionFactory( serviceRegistry );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue