p.setProperty("hibernate.cache.infinispan.com.acme.Person.addresses.expiration.max_idle", "35000");
p.setProperty("hibernate.cache.infinispan.collection.cfg", "mycollection-cache");
p.setProperty("hibernate.cache.infinispan.collection.eviction.strategy", "LRU");
p.setProperty("hibernate.cache.infinispan.collection.eviction.wake_up_interval", "3500");
p.setProperty("hibernate.cache.infinispan.collection.eviction.max_entries", "25000");
InfinispanRegionFactory factory = new InfinispanRegionFactory();
factory.start(null, p);
EmbeddedCacheManager manager = factory.getCacheManager();
manager.getGlobalConfiguration().setTransportClass(null);
try {
assertFalse(manager.getGlobalConfiguration().isExposeGlobalJmxStatistics());
assertNotNull(factory.getTypeOverrides().get(person));
assertFalse(factory.getDefinedConfigurations().contains(person));
assertNotNull(factory.getTypeOverrides().get(addresses));
assertFalse(factory.getDefinedConfigurations().contains(addresses));
CacheAdapter cache = null;
EntityRegionImpl region = (EntityRegionImpl) factory.buildEntityRegion(person, p, null);
assertNotNull(factory.getTypeOverrides().get(person));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(address));
cache = region.getCacheAdapter();
Configuration cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(2000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(5000, cacheCfg.getEvictionMaxEntries());
assertEquals(60000, cacheCfg.getExpirationLifespan());
assertEquals(30000, cacheCfg.getExpirationMaxIdle());
assertFalse(cacheCfg.isExposeJmxStatistics());
region = (EntityRegionImpl) factory.buildEntityRegion(address, p, null);
assertNotNull(factory.getTypeOverrides().get(person));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(address));
cache = region.getCacheAdapter();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(20000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
region = (EntityRegionImpl) factory.buildEntityRegion(car, p, null);
assertNotNull(factory.getTypeOverrides().get(person));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(address));
cache = region.getCacheAdapter();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(3000, cacheCfg.getEvictionWakeUpInterval());
assertEquals(20000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
CollectionRegionImpl collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(addresses, p, null);
assertNotNull(factory.getTypeOverrides().get(addresses));
assertTrue(factory.getDefinedConfigurations().contains(person));
assertNull(factory.getTypeOverrides().get(parts));
cache = collectionRegion .getCacheAdapter();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.FIFO, cacheCfg.getEvictionStrategy());
assertEquals(2500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(5500, cacheCfg.getEvictionMaxEntries());
assertEquals(65000, cacheCfg.getExpirationLifespan());
assertEquals(35000, cacheCfg.getExpirationMaxIdle());
assertFalse(cacheCfg.isExposeJmxStatistics());
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
assertNotNull(factory.getTypeOverrides().get(addresses));
assertTrue(factory.getDefinedConfigurations().contains(addresses));
assertNull(factory.getTypeOverrides().get(parts));
cache = collectionRegion.getCacheAdapter();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(25000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
collectionRegion = (CollectionRegionImpl) factory.buildCollectionRegion(parts, p, null);
assertNotNull(factory.getTypeOverrides().get(addresses));
assertTrue(factory.getDefinedConfigurations().contains(addresses));
assertNull(factory.getTypeOverrides().get(parts));
cache = collectionRegion.getCacheAdapter();
cacheCfg = cache.getConfiguration();
assertEquals(EvictionStrategy.LRU, cacheCfg.getEvictionStrategy());
assertEquals(3500, cacheCfg.getEvictionWakeUpInterval());
assertEquals(25000, cacheCfg.getEvictionMaxEntries());
assertFalse(cacheCfg.isExposeJmxStatistics());
} finally {
factory.stop();
}
}