use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class PetStoreDefaultEncodingTestCase method listen.
private Message listen() {
PollingProber prober = new PollingProber(TIMEOUT_MILLIS, POLL_DELAY_MILLIS);
prober.check(new JUnitLambdaProbe(() -> messageHolder.get() != null));
return messageHolder.get();
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class MuleLoggerContextTestCase method assertLogged.
private void assertLogged() {
PollingProber pollingProber = new PollingProber(5000, 500);
pollingProber.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
testAppender.ensure(new TestAppender.Expectation(LEVEL.name(), CATEGORY, MESSAGE));
return true;
}
@Override
public String describeFailure() {
return "message was not logged";
}
});
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class NonBlockingOperationsTestCase method voidNonBlockingOperation.
@Test
public void voidNonBlockingOperation() throws Exception {
IronMan ironMan = getIronMan("ironMan");
final String payload = "take me to the avengers tower";
Event event = flowRunner("computeFlightPlan").withPayload(payload).run();
assertThat(event.getMessage().getPayload().getValue().toString(), equalTo(payload));
new PollingProber().probe(1000, 1000, () -> FLIGHT_PLAN.equals(ironMan.getFlightPlan()));
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class ReactiveInterceptorAdapterTestCase method interceptorErrorResumeAround.
@Test
@io.qameta.allure.Description("Simulates the error handling scenario for XML SDK operations")
public void interceptorErrorResumeAround() throws Exception {
Exception thrown = new Exception();
ProcessorInterceptor interceptor = prepareInterceptor(new ProcessorInterceptor() {
@Override
public CompletableFuture<InterceptionEvent> around(ComponentLocation location, Map<String, ProcessorParameterValue> parameters, InterceptionEvent event, InterceptionAction action) {
Mono<InterceptionEvent> errorMono = Mono.error(thrown);
return Mono.from(((BaseEventContext) event.getContext()).error(thrown)).then(errorMono).toFuture();
}
@Override
public void after(ComponentLocation location, InterceptionEvent event, Optional<Throwable> thrown) {
}
});
startFlowWithInterceptors(interceptor);
expected.expectCause(sameInstance(thrown));
try {
process(flow, eventBuilder(muleContext).message(Message.of("")).build());
} finally {
if (useMockInterceptor) {
new PollingProber().probe(() -> {
verify(interceptor).after(any(), any(), eq(Optional.of(thrown)));
return true;
});
}
}
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class AbstractProcessingStrategyTestCase method testBackPressure.
protected void testBackPressure(BackPressureStrategy backPressureStrategy, Matcher<Integer> processedAssertion, Matcher<Integer> rejectedAssertion, Matcher<Integer> totalAssertion) throws MuleException {
if (mode.equals(SOURCE)) {
triggerableMessageSource = new TriggerableMessageSource(backPressureStrategy);
flow = flowBuilder.get().source(triggerableMessageSource).processors(asList(cpuLightProcessor, new ThreadTrackingProcessor() {
@Override
public CoreEvent process(CoreEvent event) throws MuleException {
try {
sleep(3);
} catch (InterruptedException e) {
currentThread().interrupt();
throw new RuntimeException(e);
}
return super.process(event);
}
@Override
public ProcessingType getProcessingType() {
return BLOCKING;
}
})).maxConcurrency(2).build();
flow.initialise();
flow.start();
AtomicInteger rejected = new AtomicInteger();
AtomicInteger processed = new AtomicInteger();
for (int i = 0; i < STREAM_ITERATIONS; i++) {
cachedThreadPool.submit(() -> Flux.just(newEvent()).cast(CoreEvent.class).transform(triggerableMessageSource.getListener()).doOnNext(event -> processed.getAndIncrement()).doOnError(e -> rejected.getAndIncrement()).subscribe());
}
new PollingProber(DEFAULT_TIMEOUT * 10, DEFAULT_POLLING_INTERVAL).check(new JUnitLambdaProbe(() -> {
LOGGER.info("DONE " + processed.get() + " , REJECTED " + rejected.get() + ", ");
assertThat(rejected.get() + processed.get(), totalAssertion);
assertThat(processed.get(), processedAssertion);
assertThat(rejected.get(), rejectedAssertion);
return true;
}));
}
}
Aggregations