Search in sources :

Example 46 with PollingProber

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

the class FakeMuleServer method assertUndeploymentSuccess.

public void assertUndeploymentSuccess(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)).onUndeploymentSuccess(appName);
                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 47 with PollingProber

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

the class FakeMuleServer method assertDeploymentSuccess.

private void assertDeploymentSuccess(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)).onDeploymentSuccess(appName);
                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 48 with PollingProber

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

the class LifecycleAwareConfigurationInstanceTestCase method disposeMetadataCacheWhenConfigIsDisposed.

@Test
public void disposeMetadataCacheWhenConfigIsDisposed() throws Exception {
    MuleMetadataService muleMetadataManager = ((MuleContextWithRegistries) muleContext).getRegistry().lookupObject(MuleMetadataService.class);
    muleMetadataManager.getMetadataCache(NAME);
    interceptable.initialise();
    interceptable.start();
    interceptable.stop();
    new PollingProber(1000, 100).check(new JUnitLambdaProbe(() -> muleMetadataManager.getMetadataCaches().entrySet().isEmpty()));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) MuleMetadataService(org.mule.runtime.core.internal.metadata.MuleMetadataService) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 49 with PollingProber

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

the class TypedValueParameterOperationExecutionTestCase method typedValueForStringOnSourceOnSuccess.

@Test
public void typedValueForStringOnSourceOnSuccess() throws Exception {
    Flow flow = (Flow) getFlowConstruct("typedValueForStringOnSourceOnSuccess");
    flow.start();
    new PollingProber(100000, 100).check(new JUnitLambdaProbe(() -> TypedValueSource.onSuccessValue != null));
    assertTypedValue(TypedValueSource.onSuccessValue, STRING_VALUE, WILDCARD, null);
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) Flow(org.mule.runtime.core.api.construct.Flow) Test(org.junit.Test)

Example 50 with PollingProber

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

the class PetStoreConnectionPoolingTestCase method exhaustion.

@Test
public void exhaustion() throws Exception {
    if (NO_POOLING.equals(name)) {
        // test does not apply
        return;
    }
    executorService = Executors.newFixedThreadPool(poolSize);
    List<Future<PetStoreClient>> clients = new ArrayList<>(poolSize);
    for (int i = 0; i < poolSize; i++) {
        clients.add(getClientOnLatch());
    }
    testLatch.await();
    try {
        getClient();
        fail("was expecting pool to be exhausted when using config: " + name);
    } catch (Exception e) {
        assertThat(e.getCause(), is(instanceOf(ConnectionException.class)));
    }
    connectionLatch.release();
    for (Future<PetStoreClient> future : clients) {
        PollingProber prober = new PollingProber(1000, 100);
        prober.check(new JUnitProbe() {

            @Override
            protected boolean test() throws Exception {
                PetStoreClient client = future.get(100, MILLISECONDS);
                assertValidClient(client);
                return true;
            }

            @Override
            public String describeFailure() {
                return "Could not obtain valid client";
            }
        });
    }
    // now test that the pool is usable again
    assertValidClient(getClient());
}
Also used : JUnitProbe(org.mule.tck.probe.JUnitProbe) PetStoreClient(org.mule.test.petstore.extension.PetStoreClient) PollingProber(org.mule.tck.probe.PollingProber) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) ConnectionException(org.mule.runtime.api.connection.ConnectionException) ConnectionException(org.mule.runtime.api.connection.ConnectionException) 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