Search in sources :

Example 31 with PollingProber

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

the class ExpiryMonitorTestCase method testExpiry.

@Test
public void testExpiry() throws InterruptedException {
    Expirable e = () -> expire();
    monitor.addExpirable(EXPIRE_TIME, MILLISECONDS, e);
    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();
    }));
}
Also used : Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) System.currentTimeMillis(java.lang.System.currentTimeMillis) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Expirable(org.mule.runtime.core.privileged.util.monitor.Expirable) PollingProber(org.mule.tck.probe.PollingProber) Assert.assertThat(org.junit.Assert.assertThat) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) After(org.junit.After) Matchers.is(org.hamcrest.Matchers.is) ExpiryMonitor(org.mule.runtime.core.privileged.util.monitor.ExpiryMonitor) Before(org.junit.Before) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) Expirable(org.mule.runtime.core.privileged.util.monitor.Expirable) Test(org.junit.Test)

Example 32 with PollingProber

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

Example 33 with PollingProber

use of org.mule.tck.probe.PollingProber 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());
        }
    });
}
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) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException)

Example 34 with PollingProber

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

the class AbstractDeploymentTestCase method assertConditionOnRegistry.

protected void assertConditionOnRegistry(TestDeploymentListener listener, Function<DefaultRegistry, Boolean> verifier) {
    Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
    prober.check(new JUnitProbe() {

        @Override
        public boolean test() {
            DefaultRegistry registry = (DefaultRegistry) listener.getRegistry();
            if (registry == null) {
                return false;
            }
            return verifier.apply(registry);
        }

        @Override
        public String describeFailure() {
            return "Properties were not overriden by the deployment properties";
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) PollingProber(org.mule.tck.probe.PollingProber) DefaultRegistry(org.mule.runtime.core.internal.registry.DefaultRegistry) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober)

Example 35 with PollingProber

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

the class AbstractDeploymentTestCase method assertAtLeastOneUndeploymentSuccess.

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

        @Override
        public boolean test() {
            verify(listener, atLeastOnce()).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)

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