Search in sources :

Example 6 with JUnitLambdaProbe

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

the class DataTypeBuilderTestCase method cacheClean.

@Test
public void cacheClean() throws InterruptedException, ClassNotFoundException {
    ClassLoader custom = new ClassLoader(this.getClass().getClassLoader()) {

        @Override
        public Class<?> loadClass(String name) throws ClassNotFoundException {
            if (Message.class.getName().equals(name)) {
                byte[] classBytes;
                try {
                    classBytes = toByteArray(this.getClass().getResourceAsStream("/org/mule/runtime/api/message/Message.class"));
                    return this.defineClass(null, classBytes, 0, classBytes.length);
                } catch (Exception e) {
                    return super.loadClass(name);
                }
            } else {
                return super.loadClass(name);
            }
        }
    };
    PhantomReference<ClassLoader> clRef = new PhantomReference<>(custom, new ReferenceQueue<>());
    DataType.builder().type(custom.loadClass(Message.class.getName())).build();
    custom = null;
    new PollingProber(GC_POLLING_TIMEOUT, DEFAULT_POLLING_INTERVAL).check(new JUnitLambdaProbe(() -> {
        System.gc();
        assertThat(clRef.isEnqueued(), is(true));
        return true;
    }, "A hard reference is being mantained to the type of the DataType."));
}
Also used : Message(org.mule.runtime.api.message.Message) JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PhantomReference(java.lang.ref.PhantomReference) PollingProber(org.mule.tck.probe.PollingProber) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 7 with JUnitLambdaProbe

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

the class AbstractStreamingExtensionTestCase method assertAllStreamingResourcesClosed.

private void assertAllStreamingResourcesClosed() {
    StreamingStatistics stats = streamingManager.getStreamingStatistics();
    new PollingProber(10000, 100).check(new JUnitLambdaProbe(() -> {
        assertThat("There're still open cursor providers", stats.getOpenCursorProvidersCount(), is(0));
        assertThat("There're still open cursors", stats.getOpenCursorsCount(), is(0));
        return true;
    }));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) StreamingStatistics(org.mule.runtime.core.api.streaming.StreamingStatistics) PollingProber(org.mule.tck.probe.PollingProber)

Example 8 with JUnitLambdaProbe

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

the class BytesStreamingExtensionTestCase method startSourceAndListenSpell.

private void startSourceAndListenSpell(Flow flow, Predicate<String> predicate) throws Exception {
    flow.start();
    new PollingProber(4000, 100).check(new JUnitLambdaProbe(() -> {
        synchronized (CASTED_SPELLS) {
            return CASTED_SPELLS.stream().anyMatch(predicate);
        }
    }));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber)

Example 9 with JUnitLambdaProbe

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

the class PetStoreSourceRetryPolicyProviderTestCase method retryPolicySourceFailWithConnectionException.

@Test
public void retryPolicySourceFailWithConnectionException() throws Exception {
    startFlow("source-fail-with-connection-exception");
    new PollingProber(TIMEOUT_MILLIS, POLL_DELAY_MILLIS).check(new JUnitLambdaProbe(() -> {
        assertThat(PetStoreConnector.timesStarted, is(3));
        return true;
    }));
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) Test(org.junit.Test)

Example 10 with JUnitLambdaProbe

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

the class LifecycleAwareConfigurationInstanceAsyncRetryTestCase method testConnectivityUponStart.

@Override
@Test
public void testConnectivityUponStart() throws Exception {
    if (connectionProvider.isPresent()) {
        valueStarted();
        new PollingProber().check(new JUnitLambdaProbe(() -> {
            verify(connectionManager).testConnectivity(interceptable);
            return true;
        }));
    }
}
Also used : JUnitLambdaProbe(org.mule.tck.probe.JUnitLambdaProbe) PollingProber(org.mule.tck.probe.PollingProber) Test(org.junit.Test)

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