use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class AbstractDeploymentTestCase method assertRedeploymentSuccess.
private void assertRedeploymentSuccess(DeploymentListener listener, String artifactName) {
Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
prober.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
verify(listener, times(1)).onRedeploymentSuccess(artifactName);
return true;
}
@Override
public String describeFailure() {
return "Failed to redeploy artifact: " + artifactName + System.lineSeparator() + super.describeFailure();
}
});
}
use of org.mule.tck.probe.PollingProber 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.PollingProber 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.PollingProber in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method expirationIntervalWithLowTTL.
@Test
public void expirationIntervalWithLowTTL() throws Exception {
int maxEntries = 5;
int entryTTL = 10;
int expirationInterval = 100;
final ObjectStore os = objectStoreFactory.createObjectStore("myOs", maxEntries, entryTTL, expirationInterval);
for (int i = 0; i < maxEntries; i++) {
os.store(valueOf(i), i);
}
PollingProber prober = new PollingProber(1000, expirationInterval);
prober.check(new JUnitProbe() {
@Override
public boolean test() throws Exception {
return os.allKeys().isEmpty();
}
@Override
public String describeFailure() {
return "not all entries were evicted";
}
});
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method maxEntriesIsHonored.
@Test
public void maxEntriesIsHonored() throws Exception {
final int expirationInterval = 1000;
final int maxEntries = 5;
final ObjectStore os = objectStoreFactory.createObjectStore("myOs", 5, 0, expirationInterval);
os.store("0", 0);
ensureMilisecondChanged();
for (int i = 1; i < maxEntries + 1; i++) {
os.store(valueOf(i), i);
}
PollingProber prober = new PollingProber(expirationInterval * 5, expirationInterval);
prober.check(new JUnitProbe() {
@Override
public boolean test() throws Exception {
assertThat(os.contains("0"), is(false));
for (int i = 1; i < maxEntries + 1; i++) {
assertThat(os.contains(valueOf(i)), is(true));
}
return true;
}
@Override
public String describeFailure() {
return "max entries were not honoured";
}
});
}
Aggregations