use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class DataTypeBuilderTestCase method cacheClean.
@Test
public void cacheClean() throws InterruptedException, ClassNotFoundException {
ClassLoader custom = new ClassLoader(this.getClass().getClassLoader()) {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
if (Message.class.getName().equals(name)) {
byte[] classBytes;
try {
classBytes = toByteArray(this.getClass().getResourceAsStream("/org/mule/runtime/api/message/Message.class"));
return this.defineClass(null, classBytes, 0, classBytes.length);
} catch (Exception e) {
return super.loadClass(name);
}
} else {
return super.loadClass(name);
}
}
};
PhantomReference<ClassLoader> clRef = new PhantomReference<>(custom, new ReferenceQueue<>());
DataType.builder().type(custom.loadClass(Message.class.getName())).build();
custom = null;
new PollingProber(GC_POLLING_TIMEOUT, DEFAULT_POLLING_INTERVAL).check(new JUnitLambdaProbe(() -> {
System.gc();
assertThat(clRef.isEnqueued(), is(true));
return true;
}, "A hard reference is being mantained to the type of the DataType."));
}
use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class AbstractStreamingExtensionTestCase method assertAllStreamingResourcesClosed.
private void assertAllStreamingResourcesClosed() {
StreamingStatistics stats = streamingManager.getStreamingStatistics();
new PollingProber(10000, 100).check(new JUnitLambdaProbe(() -> {
assertThat("There're still open cursor providers", stats.getOpenCursorProvidersCount(), is(0));
assertThat("There're still open cursors", stats.getOpenCursorsCount(), is(0));
return true;
}));
}
use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class BytesStreamingExtensionTestCase method startSourceAndListenSpell.
private void startSourceAndListenSpell(Flow flow, Predicate<String> predicate) throws Exception {
flow.start();
new PollingProber(4000, 100).check(new JUnitLambdaProbe(() -> {
synchronized (CASTED_SPELLS) {
return CASTED_SPELLS.stream().anyMatch(predicate);
}
}));
}
use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class PetStoreSourceRetryPolicyProviderTestCase method retryPolicySourceFailWithConnectionException.
@Test
public void retryPolicySourceFailWithConnectionException() throws Exception {
startFlow("source-fail-with-connection-exception");
new PollingProber(TIMEOUT_MILLIS, POLL_DELAY_MILLIS).check(new JUnitLambdaProbe(() -> {
assertThat(PetStoreConnector.timesStarted, is(3));
return true;
}));
}
use of org.mule.tck.probe.JUnitLambdaProbe in project mule by mulesoft.
the class LifecycleAwareConfigurationInstanceAsyncRetryTestCase method testConnectivityUponStart.
@Override
@Test
public void testConnectivityUponStart() throws Exception {
if (connectionProvider.isPresent()) {
valueStarted();
new PollingProber().check(new JUnitLambdaProbe(() -> {
verify(connectionManager).testConnectivity(interceptable);
return true;
}));
}
}
Aggregations