Search in sources :

Example 11 with PayloadFromTemplateService

use of com.adaptris.core.services.metadata.PayloadFromTemplateService in project interlok by adaptris.

the class MultiProducerWorkflowTest method testToString.

@Test
public void testToString() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
    MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
    assertNotNull(workflow.toString());
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) Test(org.junit.Test)

Example 12 with PayloadFromTemplateService

use of com.adaptris.core.services.metadata.PayloadFromTemplateService in project interlok by adaptris.

the class MultiProducerWorkflowTest method testHandleAdditionalProducerProduceException.

@Test
public void testHandleAdditionalProducerProduceException() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer() {

        @Override
        protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
            throw new ProduceException();
        }
    };
    MockMessageProducer mock2 = new MockMessageProducer();
    MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
    try {
        MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
        workflow.setUseProcessedMessage(false);
        channel.prepare();
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
        workflow.onAdaptrisMessage(msg);
        assertEquals(0, mock1.getMessages().size());
        assertEquals(1, mock2.getMessages().size());
        assertEquals(ORIGINAL_PAYLOAD, mock2.getMessages().get(0).getContent());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) Test(org.junit.Test)

Example 13 with PayloadFromTemplateService

use of com.adaptris.core.services.metadata.PayloadFromTemplateService in project interlok by adaptris.

the class MultiProducerWorkflowTest method testUseOriginalMessage.

@Test
public void testUseOriginalMessage() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
    try {
        MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
        workflow.setUseProcessedMessage(false);
        channel.prepare();
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
        workflow.onAdaptrisMessage(msg);
        assertEquals(1, mock1.getMessages().size());
        assertEquals(ORIGINAL_PAYLOAD, mock1.getMessages().get(0).getContent());
        assertEquals(1, mock2.getMessages().size());
        assertEquals(ORIGINAL_PAYLOAD, mock2.getMessages().get(0).getContent());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) Test(org.junit.Test)

Example 14 with PayloadFromTemplateService

use of com.adaptris.core.services.metadata.PayloadFromTemplateService in project interlok by adaptris.

the class MultiProducerWorkflowTest method testHandleProduceException.

@Test
public void testHandleProduceException() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    MockMessageProducer meh = new MockMessageProducer();
    MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
    channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
    try {
        MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
        workflow.setProducer(new MockMessageProducer() {

            @Override
            protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
                throw new ProduceException();
            }
        });
        workflow.setUseProcessedMessage(false);
        channel.prepare();
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
        workflow.onAdaptrisMessage(msg);
        assertEquals(0, mock1.getMessages().size());
        assertEquals(0, mock2.getMessages().size());
        assertEquals(1, meh.getMessages().size());
        assertEquals(ORIGINAL_PAYLOAD, meh.getMessages().get(0).getContent());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) ArrayList(java.util.ArrayList) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) Test(org.junit.Test)

Example 15 with PayloadFromTemplateService

use of com.adaptris.core.services.metadata.PayloadFromTemplateService in project interlok by adaptris.

the class MultiProducerWorkflowTest method testHandleRuntimeException.

@Test
public void testHandleRuntimeException() throws Exception {
    MockMessageProducer mock1 = new MockMessageProducer();
    MockMessageProducer mock2 = new MockMessageProducer();
    MockMessageProducer meh = new MockMessageProducer();
    MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
    channel.setMessageErrorHandler(new StandardProcessingExceptionHandler(new ServiceList(new ArrayList(Arrays.asList(new Service[] { new StandaloneProducer(meh) })))));
    try {
        MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
        workflow.setUseProcessedMessage(false);
        workflow.setProducer(new MockMessageProducer() {

            @Override
            protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
                throw new RuntimeException();
            }
        });
        channel.prepare();
        channel.requestStart();
        AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
        workflow.onAdaptrisMessage(msg);
        assertEquals(0, mock1.getMessages().size());
        assertEquals(0, mock2.getMessages().size());
        assertEquals(1, meh.getMessages().size());
        assertEquals(ORIGINAL_PAYLOAD, meh.getMessages().get(0).getContent());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) ArrayList(java.util.ArrayList) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) MockSkipProducerService(com.adaptris.core.stubs.MockSkipProducerService) ThrowExceptionService(com.adaptris.core.services.exception.ThrowExceptionService) PayloadFromTemplateService(com.adaptris.core.services.metadata.PayloadFromTemplateService) Test(org.junit.Test)

Aggregations

PayloadFromTemplateService (com.adaptris.core.services.metadata.PayloadFromTemplateService)43 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)42 Test (org.junit.Test)42 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)26 MockChannel (com.adaptris.core.stubs.MockChannel)26 MockSkipProducerService (com.adaptris.core.stubs.MockSkipProducerService)23 StandaloneProducer (com.adaptris.core.StandaloneProducer)20 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)19 AddMetadataService (com.adaptris.core.services.metadata.AddMetadataService)18 Channel (com.adaptris.core.Channel)17 ServiceList (com.adaptris.core.ServiceList)17 FailFirstMockMessageProducer (com.adaptris.core.stubs.FailFirstMockMessageProducer)15 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)14 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)12 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)12 StandardResponseProducer (com.adaptris.core.http.jetty.StandardResponseProducer)12 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)11 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)11 Iterator (java.util.Iterator)10 EventHandlerAwareService (com.adaptris.core.stubs.EventHandlerAwareService)9