Search in sources :

Example 46 with Description

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

the class DefaultEventContextTestCase method asyncChild.

@Test
@Description("Parent EventContext only completes once response publisher completes with a value and all child contexts are complete, even when child is run async with a delay.")
public void asyncChild() throws Exception {
    child = addChild(parent);
    CoreEvent event = testEvent();
    Scheduler testScheduler = muleContext.getSchedulerService().ioScheduler();
    Latch latch1 = new Latch();
    try {
        testScheduler.submit(() -> {
            child.success(event);
            latch1.countDown();
            return null;
        });
        assertParent(is(nullValue()), is(nullValue()), false, false);
        parent.success(event);
        latch1.await();
        assertChild(is(event), is(nullValue()), true);
        assertParent(is(event), is(nullValue()), true, true);
    } finally {
        testScheduler.stop();
    }
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Scheduler(org.mule.runtime.api.scheduler.Scheduler) Latch(org.mule.runtime.api.util.concurrent.Latch) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 47 with Description

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

the class DefaultEventContextTestCase method multipleBranches.

@Test
@Description("Parent EventContext only completes once response publisher completes with a value and all child contexts are complete, even if one branch of the tree completes.")
public void multipleBranches() throws Exception {
    BaseEventContext parent = context.get();
    BaseEventContext child1 = child(parent, empty());
    BaseEventContext child2 = child(parent, empty());
    BaseEventContext grandchild1 = child(child1, empty());
    BaseEventContext grandchild2 = child(child1, empty());
    BaseEventContext grandchild3 = child(child2, empty());
    BaseEventContext grandchild4 = child(child2, empty());
    grandchild1.success();
    grandchild2.success();
    assertThat(grandchild1.isTerminated(), is(true));
    assertThat(grandchild2.isTerminated(), is(true));
    assertThat(child1.isTerminated(), is(false));
    assertThat(parent.isTerminated(), is(false));
    child1.success();
    assertThat(child1.isTerminated(), is(true));
    assertThat(parent.isTerminated(), is(false));
    grandchild3.success();
    grandchild4.success();
    child2.success();
    assertThat(grandchild3.isTerminated(), is(true));
    assertThat(grandchild4.isTerminated(), is(true));
    assertThat(child2.isTerminated(), is(true));
    assertThat(parent.isTerminated(), is(false));
    parent.success();
    assertThat(parent.isTerminated(), is(true));
}
Also used : BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 48 with Description

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

the class TransactionAwareWorkQueueProcessingStrategyTestCase method tx.

@Test
@Override
@Description("Unlike with the MultiReactorProcessingStrategy, the TransactionAwareWorkQueueProcessingStrategy does not fail if a transaction " + "is active, but rather executes these events synchronously in the caller thread transparently.")
public void tx() throws Exception {
    flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build();
    flow.initialise();
    flow.start();
    TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext));
    processFlow(testEvent());
    assertThat(threads, hasSize(equalTo(1)));
    assertThat(threads, not(hasItem(startsWith(CPU_LIGHT))));
    assertThat(threads, not(hasItem(startsWith(IO))));
    assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE))));
    assertThat(threads, not(hasItem(startsWith(CUSTOM))));
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 49 with Description

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

the class TransactionAwareWorkQueueStreamProcessingStrategyTestCase method tx.

@Override
@Description("Unlike with the MultiReactorProcessingStrategy, the TransactionAwareWorkQueueProcessingStrategy does not fail if a transaction " + "is active, but rather executes these events synchronously in the caller thread transparently.")
public void tx() throws Exception {
    flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build();
    flow.initialise();
    flow.start();
    TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext));
    processFlow(testEvent());
    assertThat(threads, hasSize(equalTo(1)));
    assertThat(threads, not(hasItem(startsWith(CPU_LIGHT))));
    assertThat(threads, not(hasItem(startsWith(IO))));
    assertThat(threads, not(hasItem(startsWith(CPU_INTENSIVE))));
    assertThat(threads, not(hasItem(startsWith(CUSTOM))));
}
Also used : TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Description(io.qameta.allure.Description)

Example 50 with Description

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

the class WorkQueueProcessingStrategyTestCase method tx.

@Override
@Description("When the WorkQueueProcessingStrategy is configured and a transaction is active processing fails with an error")
public void tx() throws Exception {
    flow = flowBuilder.get().processors(cpuLightProcessor, cpuIntensiveProcessor, blockingProcessor).build();
    flow.initialise();
    flow.start();
    TransactionCoordination.getInstance().bindTransaction(new TestTransaction(muleContext));
    expectedException.expect(MessagingException.class);
    expectedException.expectCause(instanceOf(DefaultMuleException.class));
    expectedException.expectCause(hasMessage(equalTo(TRANSACTIONAL_ERROR_MESSAGE)));
    processFlow(testEvent());
}
Also used : DefaultMuleException(org.mule.runtime.api.exception.DefaultMuleException) TestTransaction(org.mule.tck.testmodels.mule.TestTransaction) Description(io.qameta.allure.Description)

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