Search in sources :

Example 1 with SensingNullMessageProcessor

use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.

the class ForeachTestCase method failingExpressionInChain.

@Test
public void failingExpressionInChain() throws Exception {
    Foreach foreach = createForeach();
    foreach.setCollectionExpression("!@INVALID");
    SensingNullMessageProcessor firstProcessor = new SensingNullMessageProcessor();
    List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
    processors.add(0, firstProcessor);
    foreach.setMessageProcessors(processors);
    initialiseIfNeeded(foreach, muleContext);
    try {
        expectExpressionException(foreach);
        processInChain(foreach, eventBuilder(muleContext).message(of(new DummyNestedIterableClass().iterator())).build());
    } finally {
        assertThat(firstProcessor.invocations, equalTo(0));
    }
}
Also used : InternalProcessor(org.mule.runtime.core.privileged.processor.InternalProcessor) Processor(org.mule.runtime.core.api.processor.Processor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) Test(org.junit.Test)

Example 2 with SensingNullMessageProcessor

use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.

the class ForeachTestCase method failingExpression.

@Test
public void failingExpression() throws Exception {
    Foreach foreach = createForeach();
    foreach.setCollectionExpression("!@INVALID");
    SensingNullMessageProcessor firstProcessor = new SensingNullMessageProcessor();
    List<Processor> processors = getSimpleMessageProcessors(new TestMessageProcessor("zas"));
    processors.add(0, firstProcessor);
    foreach.setMessageProcessors(processors);
    initialiseIfNeeded(foreach, muleContext);
    try {
        expectExpressionException(foreach);
        process(foreach, eventBuilder(muleContext).message(of(new DummyNestedIterableClass().iterator())).build(), false);
    } finally {
        assertThat(firstProcessor.invocations, equalTo(0));
    }
}
Also used : InternalProcessor(org.mule.runtime.core.privileged.processor.InternalProcessor) Processor(org.mule.runtime.core.api.processor.Processor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) TestMessageProcessor(org.mule.tck.testmodels.mule.TestMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) Test(org.junit.Test)

Example 3 with SensingNullMessageProcessor

use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.

the class AsyncRequestReplyRequesterTestCase method testSingleEventNoTimeout.

@Test
public void testSingleEventNoTimeout() throws Exception {
    asyncReplyMP = new TestAsyncRequestReplyRequester(muleContext);
    SensingNullMessageProcessor target = getSensingNullMessageProcessor();
    asyncReplyMP.setListener(target);
    asyncReplyMP.setReplySource(target.getMessageSource());
    asyncReplyMP.setMuleContext(muleContext);
    CoreEvent resultEvent = asyncReplyMP.process(testEvent());
    // Can't assert same because we copy event when we receive async reply
    assertEquals(((PrivilegedEvent) testEvent()).getMessageAsString(muleContext), ((PrivilegedEvent) resultEvent).getMessageAsString(muleContext));
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) Test(org.junit.Test)

Example 4 with SensingNullMessageProcessor

use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.

the class AsyncRequestReplyRequesterTestCase method testMultiple.

@Test
@Ignore("See MULE-8830")
public void testMultiple() throws Exception {
    asyncReplyMP = new TestAsyncRequestReplyRequester(muleContext);
    SensingNullMessageProcessor target = getSensingNullMessageProcessor();
    target.setWaitTime(50);
    AsyncDelegateMessageProcessor asyncMP = createAsyncMessageProcessor(target);
    asyncMP.initialise();
    asyncReplyMP.setListener(asyncMP);
    asyncReplyMP.setReplySource(target.getMessageSource());
    final AtomicInteger count = new AtomicInteger();
    for (int i = 0; i < 500; i++) {
        scheduler.execute(() -> {
            try {
                CoreEvent resultEvent = asyncReplyMP.process(testEvent());
                // Can't assert same because we copy event for async currently
                assertEquals(((PrivilegedEvent) testEvent()).getMessageAsString(muleContext), ((PrivilegedEvent) resultEvent).getMessageAsString(muleContext));
                count.incrementAndGet();
                LOGGER.debug("Finished " + count.get());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
    }
    new PollingProber().check(new JUnitLambdaProbe(() -> {
        assertThat(count.get(), greaterThanOrEqualTo(500));
        return true;
    }));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) PollingProber(org.mule.tck.probe.PollingProber) AsyncDelegateMessageProcessor(org.mule.runtime.core.internal.processor.AsyncDelegateMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ResponseTimeoutException(org.mule.runtime.core.privileged.routing.ResponseTimeoutException) MuleException(org.mule.runtime.api.exception.MuleException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with SensingNullMessageProcessor

use of org.mule.tck.SensingNullMessageProcessor in project mule by mulesoft.

the class ResponseAssertionMessageProcessorTestCase method createAssertionMessageProcessor.

@Override
protected ResponseAssertionMessageProcessor createAssertionMessageProcessor() {
    ResponseAssertionMessageProcessor mp = new ResponseAssertionMessageProcessor();
    mp.setListener(new SensingNullMessageProcessor());
    return mp;
}
Also used : ResponseAssertionMessageProcessor(org.mule.functional.api.component.ResponseAssertionMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor)

Aggregations

SensingNullMessageProcessor (org.mule.tck.SensingNullMessageProcessor)14 Test (org.junit.Test)13 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)9 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Collectors.toList (java.util.stream.Collectors.toList)4 MuleException (org.mule.runtime.api.exception.MuleException)4 Message (org.mule.runtime.api.message.Message)4 Processor (org.mule.runtime.core.api.processor.Processor)4 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)4 ExpressionRuntimeException (org.mule.runtime.core.api.expression.ExpressionRuntimeException)3 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)3 BufferOverflowException (java.nio.BufferOverflowException)2 Arrays.asList (java.util.Arrays.asList)2 Collections.emptyList (java.util.Collections.emptyList)2 Collections.singletonMap (java.util.Collections.singletonMap)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Optional (java.util.Optional)2 BaseMatcher (org.hamcrest.BaseMatcher)2