use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class AbstractDeploymentTestCase method assertMuleContextCreated.
protected void assertMuleContextCreated(final DeploymentListener listener, final String appName) {
Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
prober.check(new JUnitProbe() {
@Override
public boolean test() {
verify(listener, times(1)).onArtifactCreated(eq(appName), any(CustomizationService.class));
return true;
}
@Override
public String describeFailure() {
return String.format("Did not received notification '%s' for app '%s'", "onArtifactCreated", appName) + System.lineSeparator() + super.describeFailure();
}
});
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class AbstractDeploymentTestCase method assertArtifactRedeploymentFailure.
private void assertArtifactRedeploymentFailure(DeploymentListener listener, String artifactName) {
Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
prober.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
verify(listener).onRedeploymentFailure(eq(artifactName), any(Throwable.class));
return true;
}
@Override
public String describeFailure() {
return "Failed to redeploy application: " + artifactName + System.lineSeparator() + super.describeFailure();
}
});
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class ApplicationPolicyDeploymentTestCase method appliesApplicationPolicyWithNotificationListener.
@Test
public void appliesApplicationPolicyWithNotificationListener() throws Exception {
policyManager.registerPolicyTemplate(fooPolicyFileBuilder.getArtifactFile());
ApplicationFileBuilder applicationFileBuilder = createExtensionApplicationWithServices(APP_WITH_EXTENSION_PLUGIN_CONFIG, helloExtensionV1Plugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertApplicationDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
List<Integer> notificationListenerActionIds = new ArrayList<>();
PolicyNotificationListener<PolicyNotification> notificationListener = notification -> notificationListenerActionIds.add(notification.getAction().getActionId());
policyManager.addPolicy(applicationFileBuilder.getId(), fooPolicyFileBuilder.getArtifactId(), new PolicyParametrization(FOO_POLICY_ID, pointparameters -> true, 1, singletonMap(POLICY_PROPERTY_KEY, POLICY_PROPERTY_VALUE), getResourceFile("/fooPolicy.xml"), singletonList(notificationListener)));
executeApplicationFlow("main");
assertThat(invocationCount, equalTo(1));
new PollingProber(POLICY_NOTIFICATION_TIMEOUT, 100).check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
assertThat(notificationListenerActionIds, hasSize(4));
assertThat(notificationListenerActionIds, hasItems(PROCESS_START, BEFORE_NEXT, AFTER_NEXT, PROCESS_END));
return true;
}
});
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class PetStoreConnectionPoolingTestCase method exhaustion.
@Test
public void exhaustion() throws Exception {
if (NO_POOLING.equals(name)) {
// test does not apply
return;
}
executorService = Executors.newFixedThreadPool(poolSize);
List<Future<PetStoreClient>> clients = new ArrayList<>(poolSize);
for (int i = 0; i < poolSize; i++) {
clients.add(getClientOnLatch());
}
testLatch.await();
try {
getClient();
fail("was expecting pool to be exhausted when using config: " + name);
} catch (Exception e) {
assertThat(e.getCause(), is(instanceOf(ConnectionException.class)));
}
connectionLatch.release();
for (Future<PetStoreClient> future : clients) {
PollingProber prober = new PollingProber(1000, 100);
prober.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
PetStoreClient client = future.get(100, MILLISECONDS);
assertValidClient(client);
return true;
}
@Override
public String describeFailure() {
return "Could not obtain valid client";
}
});
}
// now test that the pool is usable again
assertValidClient(getClient());
}
use of org.mule.tck.probe.JUnitProbe in project mule by mulesoft.
the class MuleLoggerContextTestCase method assertLogged.
private void assertLogged() {
PollingProber pollingProber = new PollingProber(5000, 500);
pollingProber.check(new JUnitProbe() {
@Override
protected boolean test() throws Exception {
testAppender.ensure(new TestAppender.Expectation(LEVEL.name(), CATEGORY, MESSAGE));
return true;
}
@Override
public String describeFailure() {
return "message was not logged";
}
});
}
Aggregations