HHH-13138 By default, pass the class loader of the test to the EMF
Not doing it causes issues when using the BytecodeEnhancerRunner which introduces an enhancing class loader. We could do it on a per test basis but it's easier to do it once and for all. And it can still be overridden anyway.
This commit is contained in:
parent
2dd008adb7
commit
bae98ffacc
|
@ -14,6 +14,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.persistence.EntityManager;
|
import javax.persistence.EntityManager;
|
||||||
import javax.persistence.SharedCacheMode;
|
import javax.persistence.SharedCacheMode;
|
||||||
import javax.persistence.ValidationMode;
|
import javax.persistence.ValidationMode;
|
||||||
|
@ -21,20 +22,17 @@ import javax.persistence.spi.PersistenceUnitTransactionType;
|
||||||
|
|
||||||
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
|
||||||
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
|
import org.hibernate.bytecode.enhance.spi.EnhancementContext;
|
||||||
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.jpa.AvailableSettings;
|
|
||||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||||
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
||||||
|
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for all ejb tests.
|
* A base class for all ejb tests.
|
||||||
*
|
*
|
||||||
|
@ -209,6 +207,8 @@ public abstract class BaseEntityManagerFunctionalTestCase extends BaseUnitTestCa
|
||||||
Map<Object, Object> config = Environment.getProperties();
|
Map<Object, Object> config = Environment.getProperties();
|
||||||
ArrayList<Class> classes = new ArrayList<Class>();
|
ArrayList<Class> classes = new ArrayList<Class>();
|
||||||
|
|
||||||
|
config.put( AvailableSettings.CLASSLOADERS, getClass().getClassLoader() );
|
||||||
|
|
||||||
classes.addAll( Arrays.asList( getAnnotatedClasses() ) );
|
classes.addAll( Arrays.asList( getAnnotatedClasses() ) );
|
||||||
config.put( AvailableSettings.LOADED_CLASSES, classes );
|
config.put( AvailableSettings.LOADED_CLASSES, classes );
|
||||||
for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
|
for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
|
||||||
|
|
Loading…
Reference in New Issue