use of org.mule.tck.probe.PollingProber 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.PollingProber 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.PollingProber 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;
}));
}
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class LifecycleAwareConfigurationInstanceAsyncRetryTestCase method stopWhileConnectivityTestingExecuting.
@Test
public void stopWhileConnectivityTestingExecuting() throws Throwable {
if (connectionProvider.isPresent()) {
final Latch testConnectivityInvokedLatch = new Latch();
final Latch interceptableShutdownLatch = new Latch();
reset(connectionManager);
AtomicBoolean stopped = new AtomicBoolean();
AtomicReference<Throwable> thrownByTestConnectivity = new AtomicReference<>();
AtomicBoolean testConnectivityFinished = new AtomicBoolean();
when(connectionManager.getRetryTemplateFor(connectionProvider.get())).thenReturn(retryPolicyTemplate);
when(connectionManager.testConnectivity(Mockito.any(ConfigurationInstance.class))).then(inv -> {
testConnectivityInvokedLatch.countDown();
try {
interceptableShutdownLatch.await(10, SECONDS);
assertThat(stopped.get(), is(false));
} catch (Throwable t) {
thrownByTestConnectivity.set(t);
}
testConnectivityFinished.set(true);
return success();
});
interceptable.initialise();
interceptable.start();
assertThat(testConnectivityInvokedLatch.await(10, SECONDS), is(true));
interceptable.stop();
stopped.set(true);
interceptableShutdownLatch.countDown();
new PollingProber(15000, 1000).check(new JUnitLambdaProbe(() -> {
return testConnectivityFinished.get();
}));
if (thrownByTestConnectivity.get() != null) {
throw thrownByTestConnectivity.get();
}
}
}
use of org.mule.tck.probe.PollingProber in project mule by mulesoft.
the class LifecycleAwareConfigurationInstanceAsyncRetryTestCase method testConnectivityFailsUponStart.
@Override
@Test
public void testConnectivityFailsUponStart() throws Exception {
if (connectionProvider.isPresent()) {
Exception connectionException = new ConnectionException("Oops!");
when(connectionManager.testConnectivity(interceptable)).thenReturn(failure(connectionException.getMessage(), connectionException));
interceptable.initialise();
interceptable.start();
new PollingProber().check(new JUnitLambdaProbe(() -> {
verify(connectionManager, times(RECONNECTION_MAX_ATTEMPTS + 1)).testConnectivity(interceptable);
return true;
}));
}
}
Aggregations