use of org.mule.tck.probe.JUnitProbe 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.";
}
});
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class ArtifactAwareContextSelectorTestCase method assertStopped.
private void assertStopped(final MuleLoggerContext context) {
final Reference<Boolean> contextWasAccessibleDuringShutdown = new Reference<>(true);
PollingProber pollingProber = new PollingProber(1000, 10);
pollingProber.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
if (context.getState().equals(LifeCycle.State.STOPPED)) {
return true;
} else {
LoggerContext currentContext = getContext();
if (currentContext != null && currentContext != context) {
contextWasAccessibleDuringShutdown.set(false);
}
return false;
}
}
@Override
public String describeFailure() {
return "context was not stopped";
}
});
assertThat(context, not(getContext()));
assertThat(contextWasAccessibleDuringShutdown.get(), is(true));
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class MuleObjectStoreManagerIntegrationTestCase method onlySizeBoundedObjectStore.
@Test
public void onlySizeBoundedObjectStore() throws Exception {
final int maxEntries = 5;
final int entryTTL = UNBOUNDED;
final ObjectStore os = objectStoreFactory.createObjectStore("myOs", maxEntries, entryTTL, 1000);
os.store("0", 0);
ensureMilisecondChanged();
for (int i = 1; i < maxEntries + 1; i++) {
os.store(valueOf(i), i);
}
PollingProber prober = new PollingProber(5000, 1000);
prober.check(new JUnitProbe() {
@Override
public boolean test() throws Exception {
assertThat(os.allKeys().size(), is(maxEntries));
for (int i = 1; i < maxEntries + 1; i++) {
assertThat(os.contains(valueOf(i)), is(true));
}
return true;
}
@Override
public String describeFailure() {
return "objectStore was not trimmed";
}
});
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class DefaultMuleApplicationStatusTestCase method assertStatus.
private void assertStatus(final ApplicationStatus status) {
PollingProber prober = new PollingProber(PROBER_TIMEOUT, PROBER_INTERVAL);
prober.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
assertThat(application.getStatus(), is(status));
return true;
}
@Override
public String describeFailure() {
return String.format("Application remained at status %s instead of moving to %s", application.getStatus().name(), status.name());
}
});
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class AbstractDeploymentTestCase method assertStatus.
protected void assertStatus(final Application application, final ApplicationStatus status) {
Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
prober.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
assertThat(application.getStatus(), is(status));
return true;
}
@Override
public String describeFailure() {
return String.format("Application %s was expected to be in status %s but was %s instead", application.getArtifactName(), status.name(), application.getStatus().name());
}
});
}
Aggregations