Search in sources :

Example 6 with PollingProber

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

the class AbstractDeploymentTestCase method assertRedeploymentSuccess.

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

        @Override
        protected boolean test() throws Exception {
            verify(listener, times(1)).onRedeploymentSuccess(artifactName);
            return true;
        }

        @Override
        public String describeFailure() {
            return "Failed to redeploy artifact: " + artifactName + 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) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) MuleException(org.mule.runtime.api.exception.MuleException) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException)

Example 7 with PollingProber

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

the class DynamicConfigExpirationTestCase method assertExpired.

private void assertExpired(HeisenbergExtension config, long timeoutMilis, long pollDelayMillis) {
    PollingProber prober = new PollingProber(timeoutMilis, pollDelayMillis);
    prober.check(new JUnitLambdaProbe(() -> {
        assertThat(config.getStop(), is(1));
        assertThat(config.getDispose(), is(1));
        return true;
    }, "config was not stopped or disposed"));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber)

Example 8 with PollingProber

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

the class DefaultEventContextTestCase method childSuccessWithResultForPublisherFreesChild.

@Test
@Description("Once a child context is completed, its event is not kept in memory after the response publisher is consumed.")
public void childSuccessWithResultForPublisherFreesChild() 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<>());
    Publisher<CoreEvent> responsePublisher = child.getResponsePublisher();
    child.success(eventChild);
    eventChild = null;
    childResultValue.set(null);
    // Force finalization of the response publisher
    from(responsePublisher).block();
    responsePublisher = 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)

Example 9 with PollingProber

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

the class MuleObjectStoreManagerIntegrationTestCase method expirationIntervalWithLowTTL.

@Test
public void expirationIntervalWithLowTTL() throws Exception {
    int maxEntries = 5;
    int entryTTL = 10;
    int expirationInterval = 100;
    final ObjectStore os = objectStoreFactory.createObjectStore("myOs", maxEntries, entryTTL, expirationInterval);
    for (int i = 0; i < maxEntries; i++) {
        os.store(valueOf(i), i);
    }
    PollingProber prober = new PollingProber(1000, expirationInterval);
    prober.check(new JUnitProbe() {

        @Override
        public boolean test() throws Exception {
            return os.allKeys().isEmpty();
        }

        @Override
        public String describeFailure() {
            return "not all entries were evicted";
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) ObjectStore(org.mule.runtime.api.store.ObjectStore) PollingProber(org.mule.tck.probe.PollingProber) ObjectStoreNotAvailableException(org.mule.runtime.api.store.ObjectStoreNotAvailableException) Test(org.junit.Test)

Example 10 with PollingProber

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

the class MuleObjectStoreManagerIntegrationTestCase method maxEntriesIsHonored.

@Test
public void maxEntriesIsHonored() throws Exception {
    final int expirationInterval = 1000;
    final int maxEntries = 5;
    final ObjectStore os = objectStoreFactory.createObjectStore("myOs", 5, 0, expirationInterval);
    os.store("0", 0);
    ensureMilisecondChanged();
    for (int i = 1; i < maxEntries + 1; i++) {
        os.store(valueOf(i), i);
    }
    PollingProber prober = new PollingProber(expirationInterval * 5, expirationInterval);
    prober.check(new JUnitProbe() {

        @Override
        public boolean test() throws Exception {
            assertThat(os.contains("0"), is(false));
            for (int i = 1; i < maxEntries + 1; i++) {
                assertThat(os.contains(valueOf(i)), is(true));
            }
            return true;
        }

        @Override
        public String describeFailure() {
            return "max entries were not honoured";
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) ObjectStore(org.mule.runtime.api.store.ObjectStore) PollingProber(org.mule.tck.probe.PollingProber) ObjectStoreNotAvailableException(org.mule.runtime.api.store.ObjectStoreNotAvailableException) 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