use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class BytesMessageTranslatorTest method testBytesMessageToAdaptrisMessage_StreamFailure.
@Test
public void testBytesMessageToAdaptrisMessage_StreamFailure() throws Exception {
MessageTypeTranslatorImp trans = createTranslator();
try {
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
BytesMessage jmsMsg = createMessage(session);
jmsMsg.writeBytes(TEXT.getBytes());
start(trans, session);
trans.registerMessageFactory(new DefectiveMessageFactory());
jmsMsg.reset();
try {
trans.translate(jmsMsg);
fail();
} catch (JMSException expected) {
}
} finally {
stop(trans);
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class BytesMessageTranslatorTest method testAdaptrisMessageToBytesMessage_StreamFailure.
@Test
public void testAdaptrisMessageToBytesMessage_StreamFailure() throws Exception {
BytesMessageTranslator trans = new BytesMessageTranslator() {
@Override
long streamThreshold() {
return TEXT.length() - 1;
}
};
try {
Session session = activeMqBroker.createConnection().createSession(false, Session.CLIENT_ACKNOWLEDGE);
start(trans, session);
AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(TEXT);
addMetadata(msg);
try {
trans.translate(msg);
fail();
} catch (JMSException expected) {
}
} finally {
stop(trans);
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class GzipServiceTest method testZipServiceFailure.
@Test
public void testZipServiceFailure() throws Exception {
AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(LINE, "UTF-8");
try {
execute(new GzipService(), msg);
fail();
} catch (ServiceException expected) {
;
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class InputOutputServiceTest method testService_BrokenInput.
@Test
public void testService_BrokenInput() throws Exception {
AdaptrisMessage msg = new DefectiveMessageFactory(DefectiveMessageFactory.WhenToBreak.INPUT).newMessage("hello world");
try {
execute(new InputOutputService(), msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class RemoveKeyFromCacheTest 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();
RemoveKeyFromCache service = new RemoveKeyFromCache().withKey("%message{metadataKey}").withConnection(new CacheConnection().withCacheInstance(cache));
try {
start(service);
service.doService(msg);
fail();
} catch (ServiceException expected) {
} finally {
stop(service);
}
}
Aggregations