Search in sources :

Example 16 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class AggregatingFtpConsumeServiceTest method testService_MultipleFiles_Failure.

@Test
public void testService_MultipleFiles_Failure() throws Exception {
    int count = 5;
    EmbeddedFtpServer helper = new EmbeddedFtpServer();
    MockMessageListener listener = new MockMessageListener();
    FakeFtpServer server = helper.createAndStart(helper.createFilesystem(count));
    try {
        // should be ftp://localhost/home/user/work/ which is created when you
        // create the filesystem.
        String ftpConsumeUrl = "ftp://localhost" + DEFAULT_WORK_DIR_CANONICAL;
        FtpConnection conn = createConnection(server);
        AggregatingFtpConsumer consumer = createConsumer(ftpConsumeUrl, ".*", new IgnoreOriginalMimeAggregator());
        AggregatingFtpConsumeService service = new AggregatingFtpConsumeService(conn, consumer);
        AdaptrisMessage msg = new DefectiveMessageFactory().newMessage();
        try {
            execute(service, msg);
            fail();
        } catch (ServiceException expected) {
        }
    } finally {
        server.stop();
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) FakeFtpServer(org.mockftpserver.fake.FakeFtpServer) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) IgnoreOriginalMimeAggregator(com.adaptris.core.services.aggregator.IgnoreOriginalMimeAggregator) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) Test(org.junit.Test)

Example 17 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class MessageHelperTest method testCopyPayload_Failure.

@Test(expected = IOException.class)
public void testCopyPayload_Failure() throws Exception {
    AdaptrisMessage reply = new DefectiveMessageFactory(WhenToBreak.BOTH).newMessage();
    AdaptrisMessage original = new DefaultMessageFactory().newMessage();
    MessageHelper.copyPayload(reply, original);
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) DefaultMessageFactory(com.adaptris.core.DefaultMessageFactory) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 18 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class FormDataFromMetadataTest method testService_Failure.

@Test
public void testService_Failure() throws Exception {
    AdaptrisMessage msg = new DefectiveMessageFactory(WhenToBreak.METADATA_GET).newMessage();
    msg.addMetadata("param1", "this is a field");
    msg.addMetadata("param3", "was it clear (already)?");
    FormDataToMetadata service = new FormDataToMetadata();
    try {
        execute(createService(), msg);
        fail();
    } catch (ServiceException expected) {
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 19 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class IgnoreOriginalXmlAggregatorTest method testJoinMessage_NoTemplate.

@Test
public void testJoinMessage_NoTemplate() throws Exception {
    XmlDocumentAggregator aggr = new IgnoreOriginalXmlDocumentAggregator();
    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) {
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InsertNode(com.adaptris.util.text.xml.InsertNode) Test(org.junit.Test)

Example 20 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory in project interlok by adaptris.

the class MimeAggregatorCase method testJoinMessage_Fails.

@Test
public void testJoinMessage_Fails() throws Exception {
    MimeAggregator aggr = createAggregatorForTests();
    AdaptrisMessage original = new DefectiveMessageFactory().newMessage("<envelope/>");
    AdaptrisMessage splitMsg1 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>hello</document>");
    AdaptrisMessage splitMsg2 = AdaptrisMessageFactory.getDefaultInstance().newMessage("<document>world</document>");
    try {
        aggr.joinMessage(original, Arrays.asList(new AdaptrisMessage[] { splitMsg1, splitMsg2 }));
        fail();
    } catch (CoreException expected) {
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) CoreException(com.adaptris.core.CoreException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)26 Test (org.junit.Test)26 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)24 ServiceException (com.adaptris.core.ServiceException)13 CoreException (com.adaptris.core.CoreException)4 AdaptrisMessageFactory (com.adaptris.core.AdaptrisMessageFactory)2 Cache (com.adaptris.core.cache.Cache)2 ExpiringMapCache (com.adaptris.core.cache.ExpiringMapCache)2 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)2 InsertNode (com.adaptris.util.text.xml.InsertNode)2 JMSException (javax.jms.JMSException)2 Session (javax.jms.Session)2 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)2 Channel (com.adaptris.core.Channel)1 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)1 IgnoreOriginalMimeAggregator (com.adaptris.core.services.aggregator.IgnoreOriginalMimeAggregator)1 ReplaceWithFirstMessage (com.adaptris.core.services.aggregator.ReplaceWithFirstMessage)1 CacheConnection (com.adaptris.core.services.cache.CacheConnection)1 StringPayloadCacheTranslator (com.adaptris.core.services.cache.translators.StringPayloadCacheTranslator)1 XpathMetadataServiceTest (com.adaptris.core.services.metadata.XpathMetadataServiceTest)1