Search in sources :

Example 36 with PollingProber

use of org.mule.tck.probe.PollingProber in project mule by mulesoft.

the class AbstractDeploymentTestCase method assertDeploymentFailure.

protected void assertDeploymentFailure(final DeploymentListener listener, final String artifactName, final VerificationMode mode) {
    Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
    prober.check(new JUnitProbe() {

        @Override
        public boolean test() {
            verify(listener, mode).onDeploymentFailure(eq(artifactName), any(Throwable.class));
            return true;
        }

        @Override
        public String describeFailure() {
            return getArtifactType(listener) + " deployment was supposed to fail for: " + artifactName + super.describeFailure();
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober)

Example 37 with PollingProber

use of org.mule.tck.probe.PollingProber in project mule by mulesoft.

the class AbstractDeploymentTestCase method assertUndeploymentSuccess.

protected void assertUndeploymentSuccess(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)).onUndeploymentSuccess(appName);
            return true;
        }

        @Override
        public String describeFailure() {
            return "Failed to undeploy artifact: " + appName + System.lineSeparator() + super.describeFailure();
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober)

Example 38 with PollingProber

use of org.mule.tck.probe.PollingProber in project mule by mulesoft.

the class AbstractDeploymentTestCase method assertRedeploymentStart.

protected void assertRedeploymentStart(final DeploymentListener listener, final String artifactName) {
    Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
    prober.check(new JUnitProbe() {

        @Override
        public boolean test() {
            verify(listener).onRedeploymentStart(eq(artifactName));
            return true;
        }

        @Override
        public String describeFailure() {
            return getArtifactType(listener) + " redeployment was supposed to start for: " + artifactName + super.describeFailure();
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober)

Example 39 with PollingProber

use of org.mule.tck.probe.PollingProber 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();
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober)

Example 40 with PollingProber

use of org.mule.tck.probe.PollingProber in project mule by mulesoft.

the class AbstractDeploymentTestCase method assertNoDeploymentInvoked.

protected void assertNoDeploymentInvoked(final DeploymentListener deploymentListener) {
    // TODO(pablo.kraan): look for a better way to test this
    boolean invoked;
    Prober prober = new PollingProber(DeploymentDirectoryWatcher.DEFAULT_CHANGES_CHECK_INTERVAL_MS * 2, 100);
    try {
        prober.check(new Probe() {

            @Override
            public boolean isSatisfied() {
                try {
                    verify(deploymentListener, times(1)).onDeploymentStart(any(String.class));
                    return true;
                } catch (AssertionError e) {
                    return false;
                }
            }

            @Override
            public String describeFailure() {
                return "No deployment has started";
            }
        });
        invoked = true;
    } catch (AssertionError e) {
        invoked = false;
    }
    assertFalse("A deployment was started", invoked);
}
Also used : PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober) JUnitProbe(org.mule.tck.probe.JUnitProbe) Probe(org.mule.tck.probe.Probe)

Aggregations

PollingProber (org.mule.tck.probe.PollingProber)55 Test (org.junit.Test)24 JUnitProbe (org.mule.tck.probe.JUnitProbe)22 JUnitLambdaProbe (org.mule.tck.probe.JUnitLambdaProbe)21 Prober (org.mule.tck.probe.Prober)19 Probe (org.mule.tck.probe.Probe)8 MuleException (org.mule.runtime.api.exception.MuleException)7 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)6 URISyntaxException (java.net.URISyntaxException)5 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)5 File (java.io.File)4 IOException (java.io.IOException)4 MILLISECONDS (java.util.concurrent.TimeUnit.MILLISECONDS)4 Matchers.greaterThanOrEqualTo (org.hamcrest.Matchers.greaterThanOrEqualTo)4 After (org.junit.After)4 Assert.assertThat (org.junit.Assert.assertThat)4 Before (org.junit.Before)4 System.currentTimeMillis (java.lang.System.currentTimeMillis)3 ArrayList (java.util.ArrayList)3 Matchers.is (org.hamcrest.Matchers.is)3