use of com.adaptris.core.CoreException 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);
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ClearCacheServiceTest method testDoService_Exception.
@Test(expected = ServiceException.class)
public void testDoService_Exception() throws Exception {
Cache mockCache = Mockito.mock(Cache.class);
Mockito.doThrow(new CoreException()).when(mockCache).clear();
CacheConnection cache = new CacheConnection(mockCache);
ClearCacheService service = new ClearCacheService().withIgnoreUnsupported(true).withConnection(cache);
ExampleServiceCase.execute(service, AdaptrisMessageFactory.getDefaultInstance().newMessage());
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class XmlAggregatorCase method testJoinMessage_Fails.
@Test
public void testJoinMessage_Fails() throws Exception {
XmlDocumentAggregator aggr = createAggregatorForTests();
aggr.setMergeImplementation(new InsertNode(XPATH_ENVELOPE));
AdaptrisMessage original = AdaptrisMessageFactory.getDefaultInstance().newMessage("<envelope/>");
AdaptrisMessage splitMsg1 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>hello</document>");
AdaptrisMessage splitMsg2 = new DefectiveMessageFactory().newMessage("<document>world</document>");
try {
aggr.joinMessage(original, Arrays.asList(new AdaptrisMessage[] { splitMsg1, splitMsg2 }));
fail();
} catch (CoreException expected) {
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class StatelessServiceWrapperTest method testServiceThatFailsToStart.
@Test
public void testServiceThatFailsToStart() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABC");
StatelessServiceWrapper service = new StatelessServiceWrapper(new NullService() {
@Override
public void start() throws CoreException {
throw new CoreException("testServiceThatFailsToStart");
}
});
try {
execute(service, msg);
fail();
} catch (ServiceException e) {
assertNotNull(e.getCause());
assertEquals(CoreException.class, e.getCause().getClass());
assertEquals("testServiceThatFailsToStart", e.getCause().getMessage());
}
}
use of com.adaptris.core.CoreException in project interlok by adaptris.
the class ReadFileServiceTest method testServiceFailedInit.
@Test
public void testServiceFailedInit() throws Exception {
try {
final AdaptrisMessage message = AdaptrisMessageFactory.getDefaultInstance().newMessage();
final ReadFileService service = new ReadFileService();
execute(service, message);
fail();
} catch (@SuppressWarnings("unused") final CoreException expected) {
/* expected result */
}
}
Aggregations