use of com.adaptris.core.cache.ExpiringMapCache in project interlok by adaptris.
the class CheckCacheServiceTest method testDoService_InCache.
@Test
public void testDoService_InCache() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(LOOKUP_VALUE, LOOKUP_VALUE) }));
ExpiringMapCache cache = createCacheInstanceForTests();
CheckCacheService service = createServiceForTests();
try {
service.setConnection(new CacheConnection(cache));
service.setKeysFoundServiceId(FOUND);
service.setKeysNotFoundServiceId(NOT_FOUND);
start(service);
cache.put(LOOKUP_VALUE, LOOKED_UP_VALUE);
service.doService(msg);
assertEquals(FOUND, msg.getNextServiceId());
} finally {
stop(service);
}
}
use of com.adaptris.core.cache.ExpiringMapCache in project interlok by adaptris.
the class CheckCacheServiceTest method testDoService_NotInCache.
@Test
public void testDoService_NotInCache() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(LOOKUP_VALUE, LOOKUP_VALUE) }));
ExpiringMapCache cache = createCacheInstanceForTests();
CheckCacheService service = createServiceForTests();
try {
service.setConnection(new CacheConnection(cache));
service.setKeysFoundServiceId(FOUND);
service.setKeysNotFoundServiceId(NOT_FOUND);
start(service);
service.doService(msg);
assertEquals(NOT_FOUND, msg.getNextServiceId());
} finally {
stop(service);
}
}
use of com.adaptris.core.cache.ExpiringMapCache in project interlok by adaptris.
the class ServiceFromCacheTest method createCache.
private CacheConnection createCache(String key) throws Exception {
ExpiringMapCache cacheInstance = new ExpiringMapCache();
CacheConnection conn = new CacheConnection();
conn.setCacheInstance(cacheInstance);
LifecycleHelper.initAndStart(conn);
conn.retrieveCache().put(key, DynamicServiceExecutorTest.createMessage(new ServiceList(new LogMessageService())).getContent());
return conn;
}
use of com.adaptris.core.cache.ExpiringMapCache in project interlok by adaptris.
the class BasicSchemaValidationTest method testBasicSchemaValidator_Exception.
@Test(expected = ServiceException.class)
public void testBasicSchemaValidator_Exception() throws Exception {
String schemaUrl = PROPERTIES.getProperty(KEY_WILL_VALIDATE_SCHEMA);
BasicXmlSchemaValidator validator = new BasicXmlSchemaValidator().withSchema(schemaUrl).withSchemaCache(new CacheConnection().withCacheInstance(new ExpiringMapCache()));
XmlValidationService service = new XmlValidationService(validator);
try {
LifecycleHelper.initAndStart(service);
AdaptrisMessage m1 = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
service.doService(m1);
} finally {
LifecycleHelper.stopAndClose(service);
}
}
use of com.adaptris.core.cache.ExpiringMapCache in project interlok by adaptris.
the class XmlSchemaValidatorImpl method prepare.
@Override
public void prepare() throws CoreException {
schemaCacheConnection = ObjectUtils.defaultIfNull(getSchemaCache(), new CacheConnection(new ExpiringMapCache().withExpiration(DEFAULT_CACHE_TTL).withMaxEntries(DEFAULT_CACHE_SIZE)));
LifecycleHelper.prepare(schemaCacheConnection);
}
Aggregations