Search in sources :

Example 16 with JUnitLambdaProbe

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

the class ExpiryMonitorTestCase method testNotExpiry.

@Test
public void testNotExpiry() throws InterruptedException {
    Expirable e = () -> expire();
    long startTime = currentTimeMillis();
    monitor.addExpirable(EXPIRE_TIME, MILLISECONDS, e);
    monitor.run();
    assertThat(expired, is(false));
    new PollingProber(EXPIRE_TIMEOUT, 50).check(new JUnitLambdaProbe(() -> {
        assertThat(monitor.isRegistered(e), is(false));
        assertThat(expired, is(true));
        return true;
    }, ae -> {
        ae.printStackTrace();
        return "" + currentTimeMillis() + " - " + monitor.toString();
    }));
    assertThat(expiredTime - startTime, greaterThanOrEqualTo(EXPIRE_TIME - DELTA_TIME));
}
Also used : Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) System.currentTimeMillis(java.lang.System.currentTimeMillis) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Expirable(org.mule.runtime.core.privileged.util.monitor.Expirable) PollingProber(org.mule.tck.probe.PollingProber) Assert.assertThat(org.junit.Assert.assertThat) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) After(org.junit.After) Matchers.is(org.hamcrest.Matchers.is) ExpiryMonitor(org.mule.runtime.core.privileged.util.monitor.ExpiryMonitor) Before(org.junit.Before) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) Expirable(org.mule.runtime.core.privileged.util.monitor.Expirable) Test(org.junit.Test)

Example 17 with JUnitLambdaProbe

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

the class ExpiryMonitorTestCase method testExpiry.

@Test
public void testExpiry() throws InterruptedException {
    Expirable e = () -> expire();
    monitor.addExpirable(EXPIRE_TIME, MILLISECONDS, e);
    new PollingProber(EXPIRE_TIMEOUT, 50).check(new JUnitLambdaProbe(() -> {
        assertThat(monitor.isRegistered(e), is(false));
        assertThat(expired, is(true));
        return true;
    }, ae -> {
        ae.printStackTrace();
        return "" + currentTimeMillis() + " - " + monitor.toString();
    }));
}
Also used : Matchers.greaterThanOrEqualTo(org.hamcrest.Matchers.greaterThanOrEqualTo) System.currentTimeMillis(java.lang.System.currentTimeMillis) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) MILLISECONDS(java.util.concurrent.TimeUnit.MILLISECONDS) Expirable(org.mule.runtime.core.privileged.util.monitor.Expirable) PollingProber(org.mule.tck.probe.PollingProber) Assert.assertThat(org.junit.Assert.assertThat) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) AbstractMuleContextTestCase(org.mule.tck.junit4.AbstractMuleContextTestCase) After(org.junit.After) Matchers.is(org.hamcrest.Matchers.is) ExpiryMonitor(org.mule.runtime.core.privileged.util.monitor.ExpiryMonitor) Before(org.junit.Before) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) Expirable(org.mule.runtime.core.privileged.util.monitor.Expirable) Test(org.junit.Test)

Example 18 with JUnitLambdaProbe

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

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

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

the class PetStoreDefaultEncodingTestCase method listen.

private Message listen() {
    PollingProber prober = new PollingProber(TIMEOUT_MILLIS, POLL_DELAY_MILLIS);
    prober.check(new JUnitLambdaProbe(() -> messageHolder.get() != null));
    return messageHolder.get();
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber)

Aggregations

JUnitLambdaProbe (org.mule.tck.probe.JUnitLambdaProbe)21 PollingProber (org.mule.tck.probe.PollingProber)21 Test (org.junit.Test)15 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 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)4 AbstractMuleContextTestCase (org.mule.tck.junit4.AbstractMuleContextTestCase)4 System.currentTimeMillis (java.lang.System.currentTimeMillis)3 PhantomReference (java.lang.ref.PhantomReference)3 Matchers.is (org.hamcrest.Matchers.is)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 RegistrationException (org.mule.runtime.core.privileged.registry.RegistrationException)3 Expirable (org.mule.runtime.core.privileged.util.monitor.Expirable)3 ExpiryMonitor (org.mule.runtime.core.privileged.util.monitor.ExpiryMonitor)3 Description (io.qameta.allure.Description)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ObjectAlreadyExistsException (org.mule.runtime.api.store.ObjectAlreadyExistsException)2