Search in sources :

Example 6 with JUnitProbe

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

the class BytesStreamingExtensionTestCase method nonRepeatableStreamIsAutomaticallyClosed.

@Test
@Description("A non repeatable stream is closed automatically when flow completes")
public void nonRepeatableStreamIsAutomaticallyClosed() throws Exception {
    InputStream stream = (InputStream) flowRunner("toNonRepeatableStream").withPayload(data).run().getMessage().getPayload().getValue();
    // Stream will close on terminate but flowRunner will be done on response
    new PollingProber(TIMEOUT, DELAY).check(new JUnitProbe() {

        @Override
        protected boolean test() throws Exception {
            assertThat(stream.read(), is(-1));
            return true;
        }

        @Override
        public String describeFailure() {
            return "Stream was not automatically closed.";
        }
    });
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) InputStream(java.io.InputStream) PollingProber(org.mule.tck.probe.PollingProber) Description(io.qameta.allure.Description) Test(org.junit.Test)

Example 7 with JUnitProbe

use of org.mule.tck.probe.JUnitProbe 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 8 with JUnitProbe

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

the class MuleObjectStoreManagerIntegrationTestCase method onlySizeBoundedObjectStore.

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

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

        @Override
        public String describeFailure() {
            return "objectStore was not trimmed";
        }
    });
}
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 9 with JUnitProbe

use of org.mule.tck.probe.JUnitProbe 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 10 with JUnitProbe

use of org.mule.tck.probe.JUnitProbe 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)

Aggregations

JUnitProbe (org.mule.tck.probe.JUnitProbe)20 PollingProber (org.mule.tck.probe.PollingProber)20 Prober (org.mule.tck.probe.Prober)11 Test (org.junit.Test)6 URISyntaxException (java.net.URISyntaxException)5 IOException (java.io.IOException)4 MuleException (org.mule.runtime.api.exception.MuleException)4 InitialisationException (org.mule.runtime.api.lifecycle.InitialisationException)4 ArrayList (java.util.ArrayList)2 MuleRuntimeException (org.mule.runtime.api.exception.MuleRuntimeException)2 ObjectStore (org.mule.runtime.api.store.ObjectStore)2 ObjectStoreNotAvailableException (org.mule.runtime.api.store.ObjectStoreNotAvailableException)2 Description (io.qameta.allure.Description)1 File (java.io.File)1 InputStream (java.io.InputStream)1 MalformedURLException (java.net.MalformedURLException)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 Collections.emptyMap (java.util.Collections.emptyMap)1 Collections.singletonList (java.util.Collections.singletonList)1