Search in sources :

Example 51 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class WorkQueueProcessingStrategyTestCase method rejectedExecution.

@Test
@Description("If IO pool is busy OVERLOAD error is thrown")
public void rejectedExecution() throws Exception {
    flow = flowBuilder.get().processors(blockingProcessor).processingStrategyFactory((context, prefix) -> new WorkQueueProcessingStrategy(() -> new RejectingScheduler(blocking))).build();
    flow.initialise();
    flow.start();
    expectRejected();
    processFlow(testEvent());
}
Also used : WorkQueueProcessingStrategy(org.mule.runtime.core.internal.processor.strategy.WorkQueueProcessingStrategyFactory.WorkQueueProcessingStrategy) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 52 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class CompositeProcessorChainRouterTestCase method asyncDelegateChain.

@Test
@Description("Ensure that when an async scope is used as part of the execution of one of the composite chains then the chain does not complete and the next chains is not executed until the child context completes.")
public void asyncDelegateChain() throws Exception {
    Latch latch = new Latch();
    Latch asyncLatch = new Latch();
    DefaultMessageProcessorChainBuilder delegateBuilder = new DefaultMessageProcessorChainBuilder();
    delegateBuilder.chain(event -> {
        try {
            asyncLatch.countDown();
            latch.await();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        return event;
    });
    async = new AsyncDelegateMessageProcessor(delegateBuilder);
    muleContext.getInjector().inject(async);
    async.setAnnotations(getAppleFlowComponentLocationAnnotations());
    chainRouter = createCompositeProcessorChainRouter(newChain(empty(), async), newChain(empty(), event -> event));
    chainRouter.start();
    // CompletableFuture is not returned immediately because simply invoking CompositeProcessorChainRouter there is no async
    // hand-off and so this blocks until child context completes.
    Future<CompletableFuture<Event>> future = scheduler.submit(() -> chainRouter.execute(testEvent()));
    asyncLatch.await();
    try {
        future.get(BLOCK_TIMEOUT, MILLISECONDS);
        fail("Timeout expected");
    } catch (TimeoutException te) {
    }
    latch.countDown();
    assertThat(future.get(BLOCK_TIMEOUT, MILLISECONDS).get().getMessage(), equalTo(testEvent().getMessage()));
}
Also used : DefaultMessageProcessorChainBuilder(org.mule.runtime.core.privileged.processor.chain.DefaultMessageProcessorChainBuilder) CompletableFuture(java.util.concurrent.CompletableFuture) Latch(org.mule.runtime.api.util.concurrent.Latch) AsyncDelegateMessageProcessor(org.mule.runtime.core.internal.processor.AsyncDelegateMessageProcessor) TimeoutException(java.util.concurrent.TimeoutException) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 53 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class CompositeProcessorChainRouterTestCase method childContextChain.

@Test
@Description("Ensure that when a child context is created as part of the execution of one of the composite chains then the chain does not complete and the next chains is not executed until the child context completes.")
public void childContextChain() throws Exception {
    Latch latch = new Latch();
    AtomicReference<BaseEventContext> childEventContext = new AtomicReference<>();
    MessageProcessorChain chainUsingChildContext = newChain(empty(), event -> {
        latch.release();
        childEventContext.set(child((BaseEventContext) event.getContext(), empty()));
        return event;
    });
    chainRouter = createCompositeProcessorChainRouter(chainUsingChildContext, newChain(empty(), event -> event));
    // CompletableFuture is not returned immediately because simply invoking CompositeProcessorChainRouter there is no async
    // hand-off and so this blocks until child context completes.
    Future<CompletableFuture<Event>> future = scheduler.submit(() -> chainRouter.execute(testEvent()));
    latch.await();
    try {
        future.get(BLOCK_TIMEOUT, MILLISECONDS);
        fail("Timeout expected");
    } catch (TimeoutException te) {
    }
    childEventContext.get().success();
    assertThat(future.get(BLOCK_TIMEOUT, MILLISECONDS).get().getMessage(), equalTo(testEvent().getMessage()));
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) MessageProcessorChain(org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain) CompletableFuture(java.util.concurrent.CompletableFuture) Latch(org.mule.runtime.api.util.concurrent.Latch) AtomicReference(java.util.concurrent.atomic.AtomicReference) TimeoutException(java.util.concurrent.TimeoutException) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 54 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class BytesStreamingExtensionTestCase method nonRepeatableStreamClosesAsync.

@Test
@Description("A non repeatable stream is not automatically closed when event completes async")
public void nonRepeatableStreamClosesAsync() throws Exception {
    InputStream stream = (InputStream) flowRunner("toNonRepeatableStream").keepStreamsOpen().withPayload(data).run().getMessage().getPayload().getValue();
    byte[] bytes = new byte[data.length()];
    assertThat(stream.read(bytes), is(data.length()));
    assertThat(stream.read(), is(-1));
    assertThat(new String(bytes), equalTo(data));
}
Also used : InputStream(java.io.InputStream) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 55 with Description

use of io.qameta.allure.Description in project mule by mulesoft.

the class BytesStreamingExtensionTestCase method nonRepeatableStreamIsAutomaticallyClosed.

@Test
@Description("A non repeatable stream is closed automatically when flow completes")
public void nonRepeatableStreamIsAutomaticallyClosed() throws Exception {
    InputStream stream = (InputStream) flowRunner("toNonRepeatableStream").withPayload(data).run().getMessage().getPayload().getValue();
    // Stream will close on terminate but flowRunner will be done on response
    new PollingProber(TIMEOUT, DELAY).check(new JUnitProbe() {

        @Override
        protected boolean test() throws Exception {
            assertThat(stream.read(), is(-1));
            return true;
        }

        @Override
        public String describeFailure() {
            return "Stream was not automatically closed.";
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) InputStream(java.io.InputStream) PollingProber(org.mule.tck.probe.PollingProber) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)117 Test (org.junit.Test)111 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)41 Matchers.containsString (org.hamcrest.Matchers.containsString)15 Message (org.mule.runtime.api.message.Message)13 TypedValue (org.mule.runtime.api.metadata.TypedValue)13 RoutingPair (org.mule.runtime.core.internal.routing.ForkJoinStrategy.RoutingPair)12 MessageProcessorChain (org.mule.runtime.core.privileged.processor.chain.MessageProcessorChain)12 OperationParameters (org.mule.runtime.extension.api.client.OperationParameters)12 Matchers.anyString (org.mockito.Matchers.anyString)8 List (java.util.List)7 MavenConfiguration (org.mule.maven.client.api.model.MavenConfiguration)7 Processor (org.mule.runtime.core.api.processor.Processor)7 RemoteRepository (org.mule.maven.client.api.model.RemoteRepository)6 Event (org.mule.runtime.api.event.Event)6 ReactiveProcessor (org.mule.runtime.core.api.processor.ReactiveProcessor)6 BaseEventContext (org.mule.runtime.core.privileged.event.BaseEventContext)6 InternalProcessor (org.mule.runtime.core.privileged.processor.InternalProcessor)6 SmallTest (org.mule.tck.size.SmallTest)6 TestTransaction (org.mule.tck.testmodels.mule.TestTransaction)6