use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class AsyncRequestReplyRequesterTestCase method testMultiple.
@Test
@Ignore("See MULE-8830")
public void testMultiple() throws Exception {
asyncReplyMP = new TestAsyncRequestReplyRequester(muleContext);
SensingNullMessageProcessor target = getSensingNullMessageProcessor();
target.setWaitTime(50);
AsyncDelegateMessageProcessor asyncMP = createAsyncMessageProcessor(target);
asyncMP.initialise();
asyncReplyMP.setListener(asyncMP);
asyncReplyMP.setReplySource(target.getMessageSource());
final AtomicInteger count = new AtomicInteger();
for (int i = 0; i < 500; i++) {
scheduler.execute(() -> {
try {
CoreEvent resultEvent = asyncReplyMP.process(testEvent());
// Can't assert same because we copy event for async currently
assertEquals(((PrivilegedEvent) testEvent()).getMessageAsString(muleContext), ((PrivilegedEvent) resultEvent).getMessageAsString(muleContext));
count.incrementAndGet();
LOGGER.debug("Finished " + count.get());
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
new PollingProber().check(new JUnitLambdaProbe(() -> {
assertThat(count.get(), greaterThanOrEqualTo(500));
return true;
}));
}
use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class DynamicConfigExpirationTestCase method assertExpired.
private void assertExpired(HeisenbergExtension config, long timeoutMilis, long pollDelayMillis) {
PollingProber prober = new PollingProber(timeoutMilis, pollDelayMillis);
prober.check(new JUnitLambdaProbe(() -> {
assertThat(config.getStop(), is(1));
assertThat(config.getDispose(), is(1));
return true;
}, "config was not stopped or disposed"));
}
use of org.mule.tck.probe.JUnitLambdaProbe 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 org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class MuleObjectStoreManagerTestCase method expireTwoStoresInParallel.
@Test
public void expireTwoStoresInParallel() throws ObjectStoreException, InitialisationException, InterruptedException {
when(muleContext.isPrimaryPollingInstance()).thenReturn(true);
expireDelayLatch = new CountDownLatch(1);
addJavaSerializerToMockMuleContext(muleContext);
storeManager.initialise();
storeManager.createObjectStore(TEST_PARTITION_NAME + "_1", ObjectStoreSettings.builder().persistent(false).entryTtl(10L).expirationInterval(10L).build());
storeManager.createObjectStore(TEST_PARTITION_NAME + "_2", ObjectStoreSettings.builder().persistent(false).entryTtl(10L).expirationInterval(10L).build());
new PollingProber(POLLING_TIMEOUT, POLLING_DELAY).check(new JUnitLambdaProbe(() -> {
assertThat(expires.get(), is(2));
return true;
}));
expireDelayLatch.countDown();
}
use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class ExpiryMonitorTestCase method testExpiryWithReset.
@Test
public void testExpiryWithReset() throws InterruptedException {
Expirable e = () -> expire();
monitor.addExpirable(EXPIRE_TIME, MILLISECONDS, e);
monitor.run();
assertThat(expired, is(false));
long startTime = currentTimeMillis();
monitor.resetExpirable(e);
monitor.run();
assertTrue(!expired);
new PollingProber(EXPIRE_TIMEOUT, 50).check(new JUnitLambdaProbe(() -> {
assertThat(monitor.isRegistered(e), is(false));
assertThat(expired, is(true));
return true;
}, ae -> {
ae.printStackTrace();
return "" + currentTimeMillis() + " - " + monitor.toString();
}));
assertThat(expiredTime - startTime, greaterThanOrEqualTo(EXPIRE_TIME - DELTA_TIME));
}
Aggregations