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"));
}
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);
}
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));
}
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);
}
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));
}
Aggregations