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