Search in sources :

Example 6 with Repeat

use of org.springframework.test.annotation.Repeat in project opennms by OpenNMS.

the class AsyncDetectorFileDescriptorLeakTest method testNoServerPresent.

@Test
@Repeat(10000)
public void testNoServerPresent() throws Exception {
    AsyncAbstractDetector detector = getNewDetector(1999, ".*");
    LOG.info("Starting testNoServerPresent with detector: {}\n", detector);
    final DetectFuture future = detector.isServiceDetected(InetAddressUtils.getLocalHostAddress());
    assertNotNull(future);
    future.awaitFor();
    assertFalse("False positive during detection!!", future.isServiceDetected());
    assertNull(future.getException());
    LOG.info("Finished testNoServerPresent with detector: {}\n", detector);
}
Also used : DetectFuture(org.opennms.netmgt.provision.DetectFuture) AsyncAbstractDetector(org.opennms.netmgt.provision.support.AsyncAbstractDetector) Test(org.junit.Test) Repeat(org.springframework.test.annotation.Repeat)

Example 7 with Repeat

use of org.springframework.test.annotation.Repeat in project spring-integration by spring-projects.

the class FileReadingMessageSourceIntegrationTests method concurrentProcessing.

@Test
@Repeat(5)
public void concurrentProcessing() throws Exception {
    CountDownLatch go = new CountDownLatch(1);
    Runnable successfulConsumer = () -> {
        Message<File> received = pollableFileSource.receive();
        while (received == null) {
            Thread.yield();
            received = pollableFileSource.receive();
        }
    };
    Runnable failingConsumer = () -> {
        Message<File> received = pollableFileSource.receive();
        if (received != null) {
            pollableFileSource.onFailure(received);
        }
    };
    CountDownLatch successfulDone = doConcurrently(3, successfulConsumer, go);
    CountDownLatch failingDone = doConcurrently(10, failingConsumer, go);
    go.countDown();
    try {
        successfulDone.await();
        failingDone.await();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    // make sure three different files were taken
    Message<File> received = pollableFileSource.receive();
    assertNull(received);
}
Also used : Message(org.springframework.messaging.Message) CountDownLatch(java.util.concurrent.CountDownLatch) File(java.io.File) Test(org.junit.Test) Repeat(org.springframework.test.annotation.Repeat)

Aggregations

Repeat (org.springframework.test.annotation.Repeat)7 Test (org.junit.Test)6 IntegrationMessageHeaderAccessor (org.springframework.integration.IntegrationMessageHeaderAccessor)2 Rollback (org.springframework.test.annotation.Rollback)2 Transactional (org.springframework.transaction.annotation.Transactional)2 File (java.io.File)1 NotSerializableException (java.io.NotSerializableException)1 ArrayList (java.util.ArrayList)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 Statement (org.junit.runners.model.Statement)1 DetectFuture (org.opennms.netmgt.provision.DetectFuture)1 AsyncAbstractDetector (org.opennms.netmgt.provision.support.AsyncAbstractDetector)1 SerializationFailedException (org.springframework.core.serializer.support.SerializationFailedException)1 JdbcMessageStore (org.springframework.integration.jdbc.store.JdbcMessageStore)1 RefreshableResourceScriptSource (org.springframework.integration.scripting.RefreshableResourceScriptSource)1 Message (org.springframework.messaging.Message)1 MessageDeliveryException (org.springframework.messaging.MessageDeliveryException)1