Search in sources :

Example 1 with PollingProber

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

the class EventCorrelatorTestCase method doExpiredGroupMonitoringTest.

private void doExpiredGroupMonitoringTest(boolean primaryNode) throws Exception {
    when(mockMuleContext.isPrimaryPollingInstance()).thenReturn(primaryNode);
    EventCorrelator eventCorrelator = createEventCorrelator();
    when(mockEventCorrelatorCallback.createEventGroup(mockMuleEvent, TEST_GROUP_ID)).thenReturn(mockEventGroup);
    eventCorrelator.start();
    try {
        Prober prober = new PollingProber(1000, 50);
        prober.check(new Probe() {

            @Override
            public boolean isSatisfied() {
                try {
                    return !memoryObjectStore.contains(TEST_GROUP_ID, "prefix.eventGroups");
                } catch (ObjectStoreException e) {
                    LOGGER.debug("Could not access object store.");
                    return false;
                }
            }

            @Override
            public String describeFailure() {
                return "Event group not expired.";
            }
        });
    } finally {
        eventCorrelator.stop();
    }
}
Also used : ObjectStoreException(org.mule.runtime.api.store.ObjectStoreException) 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 2 with PollingProber

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

the class AsyncRequestReplyRequesterTestCase method testMultiple.

@Test
@Ignore("See MULE-8830")
public void testMultiple() throws Exception {
    asyncReplyMP = new TestAsyncRequestReplyRequester(muleContext);
    SensingNullMessageProcessor target = getSensingNullMessageProcessor();
    target.setWaitTime(50);
    AsyncDelegateMessageProcessor asyncMP = createAsyncMessageProcessor(target);
    asyncMP.initialise();
    asyncReplyMP.setListener(asyncMP);
    asyncReplyMP.setReplySource(target.getMessageSource());
    final AtomicInteger count = new AtomicInteger();
    for (int i = 0; i < 500; i++) {
        scheduler.execute(() -> {
            try {
                CoreEvent resultEvent = asyncReplyMP.process(testEvent());
                // Can't assert same because we copy event for async currently
                assertEquals(((PrivilegedEvent) testEvent()).getMessageAsString(muleContext), ((PrivilegedEvent) resultEvent).getMessageAsString(muleContext));
                count.incrementAndGet();
                LOGGER.debug("Finished " + count.get());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
    }
    new PollingProber().check(new JUnitLambdaProbe(() -> {
        assertThat(count.get(), greaterThanOrEqualTo(500));
        return true;
    }));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) PollingProber(org.mule.tck.probe.PollingProber) AsyncDelegateMessageProcessor(org.mule.runtime.core.internal.processor.AsyncDelegateMessageProcessor) SensingNullMessageProcessor(org.mule.tck.SensingNullMessageProcessor) InitialisationException(org.mule.runtime.api.lifecycle.InitialisationException) ResponseTimeoutException(org.mule.runtime.core.privileged.routing.ResponseTimeoutException) MuleException(org.mule.runtime.api.exception.MuleException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with PollingProber

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

the class AbstractDeploymentTestCase method assertDeploymentSuccess.

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

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

        @Override
        public String describeFailure() {
            return "Failed to deploy application: " + 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 4 with PollingProber

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

the class AbstractDeploymentTestCase method assertMuleContextInitialized.

protected void assertMuleContextInitialized(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)).onArtifactInitialised(eq(appName), any(Registry.class));
            return true;
        }

        @Override
        public String describeFailure() {
            return String.format("Did not received notification '%s' for app '%s'", "onArtifactInitialised", 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 5 with PollingProber

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

the class AbstractDeploymentTestCase method assertAppFolderIsDeleted.

protected void assertAppFolderIsDeleted(String appName) {
    Prober prober = new PollingProber(DEPLOYMENT_TIMEOUT, 100);
    File appFolder = new File(appsDir, appName);
    prober.check(new FileDoesNotExists(appFolder));
}
Also used : FileDoesNotExists(org.mule.tck.probe.file.FileDoesNotExists) PollingProber(org.mule.tck.probe.PollingProber) PollingProber(org.mule.tck.probe.PollingProber) Prober(org.mule.tck.probe.Prober) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) TestServicesUtils.buildExpressionLanguageServiceFile(org.mule.functional.services.TestServicesUtils.buildExpressionLanguageServiceFile) File(java.io.File) TestServicesUtils.buildSchedulerServiceFile(org.mule.functional.services.TestServicesUtils.buildSchedulerServiceFile) FileUtils.copyFile(org.apache.commons.io.FileUtils.copyFile)

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