Search in sources :

Example 41 with Description

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

the class DefaultEventContextTestCase method componentData.

@Test
@Description("Verify that a location produces connector and source data.")
public void componentData() throws Exception {
    TypedComponentIdentifier typedComponentIdentifier = TypedComponentIdentifier.builder().type(SOURCE).identifier(buildFromStringRepresentation("http:listener")).build();
    ComponentLocation location = mock(ComponentLocation.class);
    when(location.getComponentIdentifier()).thenReturn(typedComponentIdentifier);
    when(location.getParts()).thenReturn(asList(new DefaultLocationPart("flow", empty(), empty(), empty())));
    BaseEventContext context = contextWithComponentLocation.apply(location);
    assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getNamespace(), is("http"));
    assertThat(context.getOriginatingLocation().getComponentIdentifier().getIdentifier().getName(), is("listener"));
}
Also used : ComponentLocation(org.mule.runtime.api.component.location.ComponentLocation) BaseEventContext(org.mule.runtime.core.privileged.event.BaseEventContext) DefaultLocationPart(org.mule.runtime.dsl.api.component.config.DefaultComponentLocation.DefaultLocationPart) TypedComponentIdentifier(org.mule.runtime.api.component.TypedComponentIdentifier) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 42 with Description

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

the class DefaultEventContextTestCase method childSuccessWithResultForPublisherFreesChild.

@Test
@Description("Once a child context is completed, its event is not kept in memory after the response publisher is consumed.")
public void childSuccessWithResultForPublisherFreesChild() throws Exception {
    child = addChild(parent);
    CoreEvent eventChild = getEventBuilder().message(Message.of(TEST_PAYLOAD)).build();
    CoreEvent eventParent = getEventBuilder().message(Message.of(TEST_PAYLOAD)).build();
    PhantomReference<CoreEvent> childRef = new PhantomReference<>(eventChild, new ReferenceQueue<>());
    Publisher<CoreEvent> responsePublisher = child.getResponsePublisher();
    child.success(eventChild);
    eventChild = null;
    childResultValue.set(null);
    // Force finalization of the response publisher
    from(responsePublisher).block();
    responsePublisher = null;
    new PollingProber(GC_POLLING_TIMEOUT, DEFAULT_POLLING_INTERVAL).check(new JUnitLambdaProbe(() -> {
        System.gc();
        assertThat(childRef.isEnqueued(), is(true));
        return true;
    }, "A hard reference is being mantained to the child event."));
    parent.success(eventParent);
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) PhantomReference(java.lang.ref.PhantomReference) PollingProber(org.mule.tck.probe.PollingProber) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 43 with Description

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

the class DefaultEventContextTestCase method externalCompletionSuccess.

@Test
@Description("EventContext response publisher completes with value of result but the completion publisher only completes once the external publisher completes.")
public void externalCompletionSuccess() throws Exception {
    CompletableFuture<Void> externalCompletion = new CompletableFuture<>();
    parent = contextWithCompletion.apply(externalCompletion);
    setupParentListeners(parent);
    CoreEvent event = testEvent();
    assertThat(parent.isTerminated(), is(false));
    parent.success(event);
    assertParent(is(event), is(nullValue()), true, false);
    externalCompletion.complete(null);
    assertThat(parent.isTerminated(), is(true));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 44 with Description

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

the class DefaultEventContextTestCase method childDelayedSuccessWithResult.

@Test
@Description("Parent EventContext only completes once response publisher completes with a value and all child contexts are complete, even when child context completes after parent context response.")
public void childDelayedSuccessWithResult() throws Exception {
    child = addChild(parent);
    CoreEvent event = testEvent();
    parent.success(event);
    assertParent(is(event), is(nullValue()), false, false);
    child.success(event);
    assertChild(is(event), is(nullValue()), true);
    assertParent(is(event), is(nullValue()), true, true);
}
Also used : CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 45 with Description

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

the class DefaultEventContextTestCase method externalCompletionWithChild.

@Test
@Description("Parent EventContext only completes once response publisher completes with a value and all child contexts are complete and external completion completes.")
public void externalCompletionWithChild() throws Exception {
    CompletableFuture<Void> externalCompletion = new CompletableFuture<>();
    parent = contextWithCompletion.apply(externalCompletion);
    setupParentListeners(parent);
    child = addChild(parent);
    CoreEvent event = testEvent();
    child.success(event);
    assertChild(is(event), is(nullValue()), true);
    assertThat(parent.isTerminated(), is(false));
    parent.success(event);
    assertParent(is(event), is(nullValue()), true, false);
    externalCompletion.complete(null);
    assertThat(parent.isTerminated(), is(true));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Description(io.qameta.allure.Description) Test(org.junit.Test)

Aggregations

Description (io.qameta.allure.Description)123 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 Issue (io.qameta.allure.Issue)10 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 PlainCommand (com.axibase.tsd.api.model.command.PlainCommand)6 PropertyCommand (com.axibase.tsd.api.model.command.PropertyCommand)6 Property (com.axibase.tsd.api.model.property.Property)6 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