Search in sources :

Example 21 with PollingProber

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

the class ArtifactAwareContextSelectorTestCase method assertReaperThreadNotRunning.

private void assertReaperThreadNotRunning() {
    PollingProber prober = new PollingProber(PROBER_TIMEOUT, PROBER_FREQ);
    prober.check(new Probe() {

        @Override
        public boolean isSatisfied() {
            return getReaperThread() == null;
        }

        @Override
        public String describeFailure() {
            return "Reaper thread exists from previous test and did not died";
        }
    });
}
Also used : PollingProber(org.mule.tck.probe.PollingProber) Matchers.anyString(org.mockito.Matchers.anyString) JUnitProbe(org.mule.tck.probe.JUnitProbe) Probe(org.mule.tck.probe.Probe)

Example 22 with PollingProber

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

the class ArtifactAwareContextSelectorTestCase method assertStopped.

private void assertStopped(final MuleLoggerContext context) {
    final Reference<Boolean> contextWasAccessibleDuringShutdown = new Reference<>(true);
    PollingProber pollingProber = new PollingProber(1000, 10);
    pollingProber.check(new JUnitProbe() {

        @Override
        protected boolean test() throws Exception {
            if (context.getState().equals(LifeCycle.State.STOPPED)) {
                return true;
            } else {
                LoggerContext currentContext = getContext();
                if (currentContext != null && currentContext != context) {
                    contextWasAccessibleDuringShutdown.set(false);
                }
                return false;
            }
        }

        @Override
        public String describeFailure() {
            return "context was not stopped";
        }
    });
    assertThat(context, not(getContext()));
    assertThat(contextWasAccessibleDuringShutdown.get(), is(true));
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) Reference(org.mule.runtime.api.util.Reference) PollingProber(org.mule.tck.probe.PollingProber) Matchers.anyString(org.mockito.Matchers.anyString) LoggerContext(org.apache.logging.log4j.core.LoggerContext) MalformedURLException(java.net.MalformedURLException)

Example 23 with PollingProber

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

the class FakeMuleServer method assertDeploymentFailure.

private void assertDeploymentFailure(final DeploymentListener listener, final String appName) {
    Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
    prober.check(new Probe() {

        @Override
        public boolean isSatisfied() {
            try {
                verify(listener, times(1)).onDeploymentFailure(eq(appName), any(Throwable.class));
                return true;
            } catch (AssertionError e) {
                return false;
            }
        }

        @Override
        public String describeFailure() {
            return "Failed to deploy application: " + appName;
        }
    });
}
Also used : PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober) Probe(org.mule.tck.probe.Probe)

Example 24 with PollingProber

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

the class MuleDeployment method before.

protected void before() throws Throwable {
    super.before();
    prober = new PollingProber(deploymentTimeout, POLL_DELAY_MILLIS);
    mule = new MuleProcessController(getMuleHome());
    addShutdownHooks();
    try {
        doBefore();
    } catch (Error e) {
        logServerError(e);
    }
}
Also used : PollingProber(org.mule.tck.probe.PollingProber) MuleProcessController(org.mule.test.infrastructure.process.MuleProcessController)

Example 25 with PollingProber

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

the class DefaultEventContextTestCase method childSuccessWithResultFreesChild.

@Test
@Description("Once a child context is completed, its event is not kept in memory.")
public void childSuccessWithResultFreesChild() throws Exception {
    child = addChild(parent);
    CoreEvent eventChild = getEventBuilder().message(Message.of(TEST_PAYLOAD)).build();
    CoreEvent eventParent = getEventBuilder().message(Message.of(TEST_PAYLOAD)).build();
    PhantomReference<CoreEvent> childRef = new PhantomReference<>(eventChild, new ReferenceQueue<>());
    child.success(eventChild);
    eventChild = null;
    childResultValue.set(null);
    new PollingProber(GC_POLLING_TIMEOUT, DEFAULT_POLLING_INTERVAL).check(new JUnitLambdaProbe(() -> {
        System.gc();
        assertThat(childRef.isEnqueued(), is(true));
        return true;
    }, "A hard reference is being mantained to the child event."));
    parent.success(eventParent);
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) PhantomReference(java.lang.ref.PhantomReference) PollingProber(org.mule.tck.probe.PollingProber) Description(io.qameta.allure.Description) Test(org.junit.Test)

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