Search in sources :

Example 6 with DefectiveMessageFactory

use of com.adaptris.core.stubs.DefectiveMessageFactory 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) {
    }
}
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 7 with DefectiveMessageFactory

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

the class AppendinglMessageAggregatorTest method testJoin_WithException.

@Test
public void testJoin_WithException() {
    AppendingMessageAggregator aggr = createAggregatorForTests();
    AdaptrisMessage original = new DefectiveMessageFactory(EnumSet.of(WhenToBreak.INPUT, WhenToBreak.OUTPUT)).newMessage("Goodbye");
    AdaptrisMessage splitMsg1 = AdaptrisMessageFactory.getDefaultInstance().newMessage(" Cruel ");
    AdaptrisMessage splitMsg2 = AdaptrisMessageFactory.getDefaultInstance().newMessage("World");
    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)

Example 8 with DefectiveMessageFactory

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

the class FormDataToMetadataTest method testService_Failure.

@Test
public void testService_Failure() throws Exception {
    String payload = formatAsFormData(createProperties());
    AdaptrisMessage msg = new DefectiveMessageFactory(WhenToBreak.METADATA_GET).newMessage(payload);
    msg.addMetadata(Http.CONTENT_TYPE, "application/x-www-form-urlencoded");
    FormDataToMetadata service = new FormDataToMetadata();
    try {
        execute(service, 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 9 with DefectiveMessageFactory

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

the class PayloadHashingServiceTest method testServiceException.

@Test
public void testServiceException() throws Exception {
    PayloadHashingService service = new PayloadHashingService(SHA256, METADATA_KEY);
    AdaptrisMessage msg = new DefectiveMessageFactory().newMessage(PAYLOAD);
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException e) {
        ;
    }
}
Also used : DefectiveMessageFactory(com.adaptris.core.stubs.DefectiveMessageFactory) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 10 with DefectiveMessageFactory

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

the class MultipartMessageBuilderTest method testService_Exception.

@Test
public void testService_Exception() throws Exception {
    AdaptrisMessage msg = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage("Hello World");
    MultipartMessageBuilder service = new MultipartMessageBuilder().withMimeParts(new InlineMimePartBuilder());
    try {
        ExampleServiceCase.execute(service, 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)

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