use of net.sf.ehcache.CacheManager in project joynr by bmwcarit.
the class ProvisionedDomainAccessControlStoreTest method testGetDomainRoles.
@Test
public void testGetDomainRoles() throws Exception {
Properties customProperties = new Properties();
customProperties.put(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_DOMAIN_ROLES, domainRoleEntryString);
Injector injector = getInjector(customProperties);
DomainAccessControlStore store = injector.getInstance(DomainAccessControlStore.class);
assertEquals("DRE for UID1 should be the same as expectedOwnerAccessControlEntry", expectedUserDomainRoleEntry, store.getDomainRoles(UID1).get(0));
assertEquals("DRE for UID1 and Role.OWNER should be the same as expectedOwnerAccessControlEntry", expectedUserDomainRoleEntry, store.getDomainRole(UID1, Role.OWNER));
CacheManager cacheManager = injector.getInstance(CacheManager.class);
cacheManager.removeAllCaches();
}
use of net.sf.ehcache.CacheManager in project joynr by bmwcarit.
the class ProvisionedDomainAccessControlStoreTest method testGetMasterAce.
@Test
public void testGetMasterAce() throws Exception {
Properties customProperties = new Properties();
customProperties.put(StaticDomainAccessControlProvisioning.PROPERTY_PROVISIONED_MASTER_ACCESSCONTROLENTRIES, masterAccessControlEntryString);
Injector injector = getInjector(customProperties);
DomainAccessControlStore store = injector.getInstance(DomainAccessControlStore.class);
assertEquals("Master ACE associated to UID1 from Master ACL should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, store.getMasterAccessControlEntries(UID1).get(0));
assertEquals("Master ACE associated to DOMAIN1 and INTERFACE1 should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, store.getMasterAccessControlEntries(DOMAIN1, INTERFACE1).get(0));
assertEquals("Master ACE associated to UID1, DOMAIN1 and INTERFACE1 should be the same as expectedMasterAccessControlEntry", expectedMasterAccessControlEntry, store.getMasterAccessControlEntries(UID1, DOMAIN1, INTERFACE1).get(0));
CacheManager cacheManager = injector.getInstance(CacheManager.class);
cacheManager.removeAllCaches();
}
use of net.sf.ehcache.CacheManager in project coastal-hazards by USGS-CIDA.
the class CacheResource method clearCache.
boolean clearCache() {
boolean cleared = false;
try {
CacheConfiguration ehConfig = new CacheConfiguration().name(cacheName).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU).persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP)).maxBytesLocalDisk(10, MemoryUnit.MEGABYTES).maxBytesLocalHeap(1, MemoryUnit.MEGABYTES).clearOnFlush(true);
Configuration managerConfig = new Configuration().diskStore(new DiskStoreConfiguration().path(cacheLocation)).dynamicConfig(false).cache(ehConfig);
CacheManager cacheManager = CacheManager.create(managerConfig);
Ehcache ehcache = cacheManager.getEhcache(cacheName);
if (ehcache != null) {
ehcache.flush();
ehcache.removeAll();
cleared = true;
} else {
cleared = false;
}
} catch (Exception e) {
log.debug("Unable to clear cache", e);
cleared = false;
}
return cleared;
}
use of net.sf.ehcache.CacheManager in project coastal-hazards by USGS-CIDA.
the class CacheResourceTest method testClearCache.
/**
* Test of clearCache method, of class CacheResource.
*/
@Test
public void testClearCache() {
CacheConfiguration ehConfig = new CacheConfiguration().name(CACHE_NAME).memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LRU).persistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP)).timeToLiveSeconds(1000).timeToIdleSeconds(1000).clearOnFlush(true);
Configuration managerConfig = new Configuration().diskStore(new DiskStoreConfiguration().path(CACHE_LOCATION)).maxBytesLocalHeap(1, MemoryUnit.MEGABYTES).maxBytesLocalDisk(100, MemoryUnit.MEGABYTES).dynamicConfig(false).cache(ehConfig);
CacheManager cacheManager = CacheManager.create(managerConfig);
Ehcache ehcache = cacheManager.getEhcache(CACHE_NAME);
for (int i = 0; i < 100; i++) {
Element e = new Element(i, "value" + i);
ehcache.put(e);
}
assertThat(ehcache.getSize(), is(equalTo(100)));
CacheResource instance = new CacheResource();
boolean cleared = instance.clearCache();
assertThat(cleared, is(equalTo(true)));
assertThat(ehcache.getSize(), is(equalTo(0)));
}
use of net.sf.ehcache.CacheManager in project onebusaway-application-modules by camsys.
the class CacheableMethodManagerTest method test.
@Test
public void test() throws Throwable {
CacheableMethodKeyFactoryManager factoryManager = new CacheableMethodKeyFactoryManager();
CacheManager cacheManager = new CacheManager(getClass().getResource("ehcache-test.xml"));
CacheableMethodManager manager = new CacheableMethodManager();
manager.setCacheableMethodKeyFactoryManager(factoryManager);
manager.setCacheManager(cacheManager);
MockServiceImpl impl = new MockServiceImpl();
Method method = MockServiceImpl.class.getMethod("evalauteBeanWithParameterAnnotation", MockBean.class, Boolean.TYPE);
MockBean bean = new MockBean();
bean.setId("id");
ProceedingJoinPoint pjp = ProceedingJoinPointFactory.create(impl, impl, MockService.class, method, bean, false);
Object value = manager.evaluate(pjp);
assertEquals("test", value);
assertEquals(1, impl.getEvalauteBeanWithParameterAnnotationCount());
value = manager.evaluate(pjp);
assertEquals("test", value);
assertEquals(1, impl.getEvalauteBeanWithParameterAnnotationCount());
/**
* This time we indicate we want a cache refresh
*/
ProceedingJoinPoint pjp2 = ProceedingJoinPointFactory.create(impl, impl, MockService.class, method, bean, true);
value = manager.evaluate(pjp2);
assertEquals("test", value);
assertEquals(2, impl.getEvalauteBeanWithParameterAnnotationCount());
}
Aggregations