use of org.hibernate.jpa.test.PersistenceUnitInfoAdapter in project hibernate-orm by hibernate.
the class ConfigurationObjectSettingTest method testContainerBootstrapSharedCacheMode.
@Test
public void testContainerBootstrapSharedCacheMode() {
// first, via the integration vars
PersistenceUnitInfoAdapter empty = new PersistenceUnitInfoAdapter();
{
// as object
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(empty, Collections.singletonMap(AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.DISABLE_SELECTIVE));
assertEquals(SharedCacheMode.DISABLE_SELECTIVE, builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
{
// as string
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(empty, Collections.singletonMap(AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.DISABLE_SELECTIVE.name()));
assertEquals(SharedCacheMode.DISABLE_SELECTIVE.name(), builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
// next, via the PUI
PersistenceUnitInfoAdapter adapter = new PersistenceUnitInfoAdapter() {
@Override
public SharedCacheMode getSharedCacheMode() {
return SharedCacheMode.ENABLE_SELECTIVE;
}
};
{
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, null);
assertEquals(SharedCacheMode.ENABLE_SELECTIVE, builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
// via both, integration vars should take precedence
{
EntityManagerFactoryBuilderImpl builder = (EntityManagerFactoryBuilderImpl) Bootstrap.getEntityManagerFactoryBuilder(adapter, Collections.singletonMap(AvailableSettings.SHARED_CACHE_MODE, SharedCacheMode.DISABLE_SELECTIVE));
assertEquals(SharedCacheMode.DISABLE_SELECTIVE, builder.getConfigurationValues().get(AvailableSettings.SHARED_CACHE_MODE));
}
}
Aggregations