use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class DefaultSchedulerMessageSourceTestCase method simplePoll.
@Test
public void simplePoll() throws Exception {
DefaultSchedulerMessageSource schedulerMessageSource = createMessageSource();
SensingNullMessageProcessor flow = getSensingNullMessageProcessor();
schedulerMessageSource.setListener(flow);
schedulerMessageSource.setAnnotations(singletonMap(LOCATION_KEY, TEST_CONNECTOR_LOCATION));
schedulerMessageSource.trigger();
new PollingProber(RECEIVE_TIMEOUT, 100).check(new Probe() {
@Override
public boolean isSatisfied() {
return flow.event != null;
}
@Override
public String describeFailure() {
return "flow event never set by the source flow";
}
});
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class ManagedStoresTestCase method testObjectStoreExpiry.
private void testObjectStoreExpiry(ObjectStoreManager manager, String storeName, ObjectStoreSettings settings) throws ObjectStoreException, InterruptedException {
ObjectStore<String> objectStore = manager.createObjectStore(storeName, settings);
try {
objectStore.store("key1", "value1");
assertEquals("value1", objectStore.retrieve("key1"));
new PollingProber(2000, 50).check(new JUnitLambdaProbe(() -> {
try {
assertFalse("Object with key1 still exists.", objectStore.contains("key1"));
} catch (Exception e) {
fail(e.getMessage());
}
return true;
}));
} finally {
manager.disposeStore(storeName);
}
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class ManagedStoresTestCase method testObjectStoreMaxEntries.
private void testObjectStoreMaxEntries(ObjectStoreManager manager, String storeName, ObjectStoreSettings settings) throws ObjectStoreException, InterruptedException {
ObjectStore<String> objectStore = manager.createObjectStore(storeName, settings);
try {
storeObjects(objectStore, 0, 90);
ensureMillisecondChanged();
storeObjects(objectStore, 90, 100);
new PollingProber(2000, 50).check(new JUnitLambdaProbe(() -> {
try {
assertEquals(10, objectStore.allKeys().size());
for (int i = 90; i < 100; i++) {
assertTrue("Checking that key" + i + " exists", objectStore.contains("key" + i));
}
} catch (Exception e) {
fail(e.getMessage());
}
return true;
}));
} finally {
manager.disposeStore(storeName);
}
}
use of org.mule.tck.probe.PollingProber 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.PollingProber in project mule by mulesoft.
the class ExpiryMonitorTestCase method testNotExpiry.
@Test
public void testNotExpiry() throws InterruptedException {
Expirable e = () -> expire();
long startTime = currentTimeMillis();
monitor.addExpirable(EXPIRE_TIME, MILLISECONDS, e);
monitor.run();
assertThat(expired, is(false));
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