use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_EnforceSerializable_NotSerializable.
@Test
public void testDoService_EnforceSerializable_NotSerializable() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
try {
service.setConnection(new CacheConnection(cache));
service.setEnforceSerializable(true);
start(service);
service.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_NoErrorOnEmpty_NoKeyValue.
@Test
public void testDoService_NoErrorOnEmpty_NoKeyValue() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0);
eval.setErrorOnEmptyKey(false);
eval.setKeyTranslator(new MetadataCacheValueTranslator(SRC_KEY));
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
assertNull(cache.get(SRC_VALUE));
} finally {
stop(service);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_ErrorOnEmpty.
@Test
public void testDoService_ErrorOnEmpty() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0);
eval.setValueTranslator(new MetadataCacheValueTranslator(SRC_KEY));
eval.setKeyTranslator(new MetadataCacheValueTranslator(SRC_KEY));
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class AddToCacheServiceTest method testDoService_NoErrorOnEmpty_NoValue.
@Test
public void testDoService_NoErrorOnEmpty_NoValue() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(JmsConstants.JMS_CORRELATION_ID, CORRELATION_ID) }));
Cache cache = createCacheInstanceForTests();
AddToCacheService service = createServiceForTests();
CacheEntryEvaluator eval = service.getCacheEntryEvaluators().get(0);
eval.setErrorOnEmptyValue(false);
eval.setValueTranslator(new MetadataCacheValueTranslator(SRC_KEY));
try {
service.setConnection(new CacheConnection(cache));
start(service);
service.doService(msg);
assertNull(cache.get(SRC_VALUE));
} finally {
stop(service);
}
}
use of com.adaptris.core.MetadataElement in project interlok by adaptris.
the class CheckCacheServiceTest method testDoService_Error.
@Test
public void testDoService_Error() throws Exception {
AdaptrisMessage msg = createMessage("Hello World", Arrays.asList(new MetadataElement[] { new MetadataElement(LOOKUP_VALUE, LOOKUP_VALUE) }));
ExpiringMapCache cache = new KeysSizeUnsupportedCache().withMaxEntries(10).withExpiration(new TimeInterval(10L, TimeUnit.SECONDS));
CheckCacheService service = new CheckCacheService() {
@Override
protected boolean eval(AdaptrisMessage msg, FoundInCache callback) throws CoreException {
throw new CoreException();
}
};
try {
service.withConnection(new CacheConnection().withCacheInstance(cache));
service.setKeysFoundServiceId(FOUND);
service.setKeysNotFoundServiceId(NOT_FOUND);
start(service);
cache.put(LOOKUP_VALUE, LOOKED_UP_VALUE);
service.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
Aggregations