Search in sources :

Example 1 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method testExceptionInResponse.

@Test
public void testExceptionInResponse() throws Exception {
    DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
    builder.chain(new ResponseMessageProcessorAdapter(new ExceptionThrowingMessageProcessor(illegalStateException)), getAppendingMP("1"));
    expectedException.expect(is(illegalStateException));
    process(builder.build(), getTestEventUsingFlow("0"));
}
Also used : ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 2 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method testResponseProcessorInNestedChain.

@Test
public void testResponseProcessorInNestedChain() throws Exception {
    DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
    final ResponseMessageProcessorAdapter responseMessageProcessorAdapter = new ResponseMessageProcessorAdapter(getAppendingMP("c"));
    responseMessageProcessorAdapter.setMuleContext(muleContext);
    builder.chain(getAppendingMP("1"), newChain(empty(), getAppendingMP("a"), responseMessageProcessorAdapter, getAppendingMP("b")), getAppendingMP("2"));
    assertThat(process(builder.build(), getTestEventUsingFlow("0")).getMessage().getPayload().getValue(), equalTo("01abc2"));
}
Also used : ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 3 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method testResponseProcessor.

@Test
public void testResponseProcessor() throws Exception {
    DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
    final ResponseMessageProcessorAdapter responseMessageProcessorAdapter = new ResponseMessageProcessorAdapter(getAppendingMP("3"));
    responseMessageProcessorAdapter.setMuleContext(muleContext);
    builder.chain(getAppendingMP("1"), responseMessageProcessorAdapter, getAppendingMP("2"));
    assertThat(process(builder.build(), getTestEventUsingFlow("0")).getMessage().getPayload().getValue(), equalTo("0123"));
}
Also used : ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 4 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class DefaultMessageProcessorChainTestCase method testNestedResponseProcessor.

@Test
public void testNestedResponseProcessor() throws Exception {
    DefaultMessageProcessorChainBuilder builder = new DefaultMessageProcessorChainBuilder();
    final ResponseMessageProcessorAdapter innerResponseMessageProcessorAdapter = new ResponseMessageProcessorAdapter(getAppendingMP("4"));
    final ResponseMessageProcessorAdapter responseMessageProcessorAdapter = new ResponseMessageProcessorAdapter(newChain(empty(), innerResponseMessageProcessorAdapter, getAppendingMP("3")));
    builder.chain(getAppendingMP("1"), responseMessageProcessorAdapter, getAppendingMP("2"));
    process(builder.build(), getTestEventUsingFlow("0"));
    assertThat(process(builder.build(), getTestEventUsingFlow("0")).getMessage().getPayload().getValue(), equalTo("01234"));
}
Also used : ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 5 with ResponseMessageProcessorAdapter

use of org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter in project mule by mulesoft.

the class DefaultFlowTestCase method doSetUp.

@Override
protected void doSetUp() throws Exception {
    super.doSetUp();
    sensingMessageProcessor = getSensingNullMessageProcessor();
    List<Processor> processors = new ArrayList<>();
    processors.add(new ResponseMessageProcessorAdapter(new StringAppendTransformer("f")));
    processors.add(new ResponseMessageProcessorAdapter(new StringAppendTransformer("e")));
    processors.add(new ResponseMessageProcessorAdapter(new StringAppendTransformer("d")));
    processors.add(new StringAppendTransformer("a"));
    processors.add(new StringAppendTransformer("b"));
    processors.add(new StringAppendTransformer("c"));
    processors.add(event -> CoreEvent.builder(event).addVariable("thread", currentThread()).build());
    processors.add(sensingMessageProcessor);
    flow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext).source(directInboundMessageSource).processors(processors).build();
    stoppedFlow = (DefaultFlow) Flow.builder(FLOW_NAME, muleContext).source(directInboundMessageSource).processors(processors).initialState(INITIAL_STATE_STOPPED).build();
}
Also used : ResponseMessageProcessorAdapter(org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) ReactiveProcessor(org.mule.runtime.core.api.processor.ReactiveProcessor) LifecycleTrackerProcessor(org.mule.tck.core.lifecycle.LifecycleTrackerProcessor) Processor(org.mule.runtime.core.api.processor.Processor) ArrayList(java.util.ArrayList) StringAppendTransformer(org.mule.runtime.core.internal.transformer.simple.StringAppendTransformer)

Aggregations

ResponseMessageProcessorAdapter (org.mule.runtime.core.internal.processor.ResponseMessageProcessorAdapter)7 Test (org.junit.Test)5 SmallTest (org.mule.tck.size.SmallTest)5 Processor (org.mule.runtime.core.api.processor.Processor)2 ArrayList (java.util.ArrayList)1 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)1 StringAppendTransformer (org.mule.runtime.core.internal.transformer.simple.StringAppendTransformer)1 MessageProcessorBuilder (org.mule.runtime.core.privileged.processor.MessageProcessorBuilder)1 DefaultMessageProcessorChainBuilder (org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder)1 SensingNullMessageProcessor (org.mule.tck.SensingNullMessageProcessor)1 LifecycleTrackerProcessor (org.mule.tck.core.lifecycle.LifecycleTrackerProcessor)1