use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class MetadataDocumentCopierTest method testSplit_IOException.
@Test
public void testSplit_IOException() throws Exception {
final int expectedSplitCount = 10;
AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(LINE);
msg.addMetadata(METADATA_KEY, String.valueOf(expectedSplitCount));
MetadataDocumentCopier splitter = new MetadataDocumentCopier(METADATA_KEY, METADATA_KEY_INDEX);
try (CloseableIterable<AdaptrisMessage> result = splitter.splitMessage(msg)) {
for (AdaptrisMessage m : result) {
fail();
}
} catch (RuntimeException expected) {
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class XpathSplitterTest method testSplitThrowsException.
@Test
public void testSplitThrowsException() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_MESSAGE);
msg.setContent(XML_MESSAGE, msg.getContentEncoding());
XpathMessageSplitter splitter = new XpathMessageSplitter(ENVELOPE_DOCUMENT, ENCODING_UTF8);
splitter.setMessageFactory(new DefectiveMessageFactory());
try (CloseableIterable<AdaptrisMessage> closeable = splitter.splitMessage(msg)) {
int count = 0;
for (AdaptrisMessage m : closeable) {
count++;
}
} catch (RuntimeException expected) {
}
}
use of com.adaptris.core.stubs.DefectiveMessageFactory 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.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class RequestReplyProducerBaseTest method testCopyReplyContents_Failure.
@Test(expected = ProduceException.class)
public void testCopyReplyContents_Failure() throws Exception {
AdaptrisMessage reply = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
AdaptrisMessage original = new DefaultMessageFactory().newMessage();
copyReplyContents(reply, original);
}
use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.
the class AggregatingFtpConsumeServiceTest method testService_SingleFile_Failure.
@Test
public void testService_SingleFile_Failure() throws Exception {
int count = 1;
EmbeddedFtpServer helper = new EmbeddedFtpServer();
MockMessageListener listener = new MockMessageListener();
FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
try {
// should be ftp://localhost/home/user/work/file0 which is created when you
// create the filesystem.
String ftpConsumeUrl = "ftp://localhost" + DEFAULT_WORK_DIR_CANONICAL + SLASH + DEFAULT_FILENAME + 0;
FtpConnection conn = createConnection(server);
AggregatingFtpConsumer consumer = createConsumer(ftpConsumeUrl, null, new ReplaceWithFirstMessage());
AggregatingFtpConsumeService service = new AggregatingFtpConsumeService(conn, consumer);
AdaptrisMessage msg = new DefectiveMessageFactory().newMessage();
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
} finally {
server.stop();
}
}
Aggregations