HHH-11516 : Make corrections to run test on 4.2 branch
This commit is contained in:
parent
d60c664695
commit
f6ce2fde99
|
@ -6,21 +6,24 @@
|
|||
*/
|
||||
package org.hibernate.jpa.test.persistenceunit;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import javax.persistence.Cacheable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.SharedCacheMode;
|
||||
|
||||
import org.hibernate.cache.internal.NoCachingRegionFactory;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.ejb.EntityManagerFactoryImpl;
|
||||
import org.hibernate.ejb.test.ejb3configuration.PersistenceUnitInfoAdapter;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.jpa.boot.spi.Bootstrap;
|
||||
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
|
||||
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.service.BootstrapServiceRegistryBuilder;
|
||||
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.cache.CachingRegionFactory;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -36,23 +39,27 @@ public class TwoPersistenceUnits2LCDisabledEnabled {
|
|||
@TestForIssue( jiraKey = "HHH-11516" )
|
||||
public void testDisabledEnabled() {
|
||||
final Map<Object, Object> config = Environment.getProperties();
|
||||
config.put( org.hibernate.jpa.AvailableSettings.LOADED_CLASSES, Collections.singletonList( AnEntity.class ) );
|
||||
config.put( "javax.persistence.sharedCache.mode", SharedCacheMode.ENABLE_SELECTIVE );
|
||||
config.put( AvailableSettings.CACHE_REGION_FACTORY, NoCachingRegionFactory.class.getName() );
|
||||
config.put( org.hibernate.ejb.AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE );
|
||||
config.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "false" );
|
||||
|
||||
testIt( config );
|
||||
|
||||
config.put( AvailableSettings.CACHE_REGION_FACTORY, CachingRegionFactory.class.getName() );
|
||||
config.put( AvailableSettings.USE_SECOND_LEVEL_CACHE, "true" );
|
||||
|
||||
testIt( config );
|
||||
}
|
||||
|
||||
private void testIt(Map config) {
|
||||
EntityManagerFactoryBuilder entityManagerFactoryBuilder = Bootstrap.getEntityManagerFactoryBuilder(
|
||||
new BaseEntityManagerFunctionalTestCase.TestingPersistenceUnitDescriptorImpl( getClass().getSimpleName() ),
|
||||
config
|
||||
Ejb3Configuration ejb3Configuration = new Ejb3Configuration();
|
||||
ejb3Configuration.addAnnotatedClass( AnEntity.class );
|
||||
ejb3Configuration.configure( new PersistenceUnitInfoAdapter(), config );
|
||||
EntityManagerFactoryImpl entityManagerFactory = (EntityManagerFactoryImpl) ejb3Configuration.buildEntityManagerFactory(
|
||||
new BootstrapServiceRegistryBuilder()
|
||||
);
|
||||
SessionFactoryImplementor sf = entityManagerFactoryBuilder.build().unwrap( SessionFactoryImplementor.class );
|
||||
|
||||
SessionFactoryImplementor sf = entityManagerFactory.getSessionFactory();
|
||||
final EntityPersister persister = sf.getEntityPersister( AnEntity.class.getName() );
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue