use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class ZipAggregatorTest method testAggregate_BrokenOutput.
@Test(expected = CoreException.class)
public void testAggregate_BrokenOutput() throws Exception {
ZipAggregator aggr = new ZipAggregator();
AdaptrisMessage original = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage();
AdaptrisMessageFactory fac = AdaptrisMessageFactory.getDefaultInstance();
AdaptrisMessage splitMsg1 = fac.newMessage("<document>hello</document>");
splitMsg1.addMetadata(DEFAULT_FILENAME_METADATA, "xfile1.xml");
AdaptrisMessage splitMsg2 = fac.newMessage("<document>world2</document>");
splitMsg2.addMetadata(DEFAULT_FILENAME_METADATA, "file2.xml");
AdaptrisMessage splitMsg3 = fac.newMessage("<document>world3</document>");
splitMsg3.addMetadata(DEFAULT_FILENAME_METADATA, "xfile3.xml");
AdaptrisMessage splitMsg4 = fac.newMessage("<document>world4</document>");
splitMsg4.addMetadata(DEFAULT_FILENAME_METADATA, "file4.xml");
AdaptrisMessage willBeIgnoredMsg = fac.newMessage("<document>world4</document>");
aggr.joinMessage(original, Arrays.asList(splitMsg1, splitMsg2, splitMsg3, splitMsg4, willBeIgnoredMsg));
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class AddValueToCacheTest method testDoService_WithError.
@Test
public void testDoService_WithError() throws Exception {
AdaptrisMessage msg = new DefectiveMessageFactory(EnumSet.of(WhenToBreak.METADATA_GET)).newMessage("Hello World");
msg.addMetadata("metadataKey", "value");
Cache cache = createCacheInstanceForTests();
AddValueToCache service = new AddValueToCache().withValueTranslator(new StringPayloadCacheTranslator()).withKey("%message{metadataKey}").withConnection(new CacheConnection().withCacheInstance(cache));
try {
start(service);
service.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class ReplaceFirstAggregatorTest method testAggregate_BrokenOutput.
@Test(expected = CoreException.class)
public void testAggregate_BrokenOutput() throws Exception {
ReplaceWithFirstMessage aggr = createAggregatorForTests();
aggr.setOverwriteMetadata(true);
AdaptrisMessageFactory fac = AdaptrisMessageFactory.getDefaultInstance();
AdaptrisMessage original = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage("Goodbye");
AdaptrisMessage splitMsg1 = fac.newMessage("short");
AdaptrisMessage splitMsg2 = fac.newMessage("justShort");
AdaptrisMessage splitMsg3 = fac.newMessage("ofSufficientLength");
AdaptrisMessage splitMsg4 = fac.newMessage("tooSmall");
aggr.joinMessage(original, Arrays.asList(splitMsg1, splitMsg2, splitMsg3, splitMsg4));
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class BranchingHttpRequestServiceTest method testService_Error.
@Test
public void testService_Error() throws Exception {
MockMessageProducer mock = new MockMessageProducer();
Channel c = HttpHelper.createAndStartChannel(mock);
BranchingHttpRequestService service = new BranchingHttpRequestService(HttpHelper.createURL(c)).withContentType("text/complicated");
AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(TEXT);
try {
c.requestStart();
execute(service, msg);
fail();
} catch (ServiceException expected) {
} finally {
HttpHelper.stopChannelAndRelease(c);
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class InputOutputServiceTest method testService_BrokenOutput.
@Test
public void testService_BrokenOutput() throws Exception {
AdaptrisMessage msg = new DefectiveMessageFactory(DefectiveMessageFactory.WhenToBreak.OUTPUT).newMessage("hello world");
try {
execute(new InputOutputService(), msg);
fail();
} catch (ServiceException expected) {
}
}
Aggregations