camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-11446: Use awaitility in camel-core for testing where we otherwise use thred sleep which can be speeded up.
Date Fri, 07 Jul 2017 11:12:46 GMT
Repository: camel
Updated Branches:
  refs/heads/master 21b93f572 -> 7a9a6acb7


CAMEL-11446: Use awaitility in camel-core for testing where we otherwise use thred sleep which
can be speeded up.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7a9a6acb
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7a9a6acb
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7a9a6acb

Branch: refs/heads/master
Commit: 7a9a6acb798c1d4c506a9c9c6da70f43a43473bb
Parents: 21b93f5
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Jul 7 13:12:38 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Jul 7 13:12:38 2017 +0200

----------------------------------------------------------------------
 .../component/dataset/DataSetConsumerTest.java   |  2 ++
 .../ValidatorResourceResolverFactoryTest.java    | 19 ++++++++-----------
 .../xslt/XsltUriResolverFactoryTest.java         | 19 ++++++++++---------
 .../camel/impl/CamelPostProcessorHelperTest.java |  7 +++++--
 .../impl/ConsumerCacheZeroCapacityTest.java      | 11 ++++++++---
 ...ontextSuspendResumeRouteStartupOrderTest.java |  2 +-
 ...efaultCamelContextSuspendResumeRouteTest.java |  2 +-
 .../impl/DefaultExecutorServiceManagerTest.java  |  5 +++--
 .../impl/DurationRoutePolicyMaxSecondsTest.java  | 14 ++++++++------
 .../impl/cloud/CachingServiceDiscoveryTest.java  | 11 ++++++-----
 .../async/AsyncEndpointDelayUoWTest.java         |  2 +-
 .../async/AsyncEndpointUoWFailedTest.java        |  2 +-
 .../processor/async/AsyncEndpointUoWTest.java    |  2 +-
 ...opedOnExceptionLoadBalancerStopRouteTest.java |  6 +++++-
 .../camel/support/DefaultTimeoutMapTest.java     | 10 +++++-----
 15 files changed, 65 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
index 5311330..f4a76a9 100644
--- a/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/dataset/DataSetConsumerTest.java
@@ -164,7 +164,9 @@ public class DataSetConsumerTest extends ContextTestSupport {
         result.allMessages().header(Exchange.DATASET_INDEX).isNotNull();
         result.expectsAscending(header(Exchange.DATASET_INDEX).convertTo(Number.class));
 
+        // run a little while
         Thread.sleep(100);
+
         assertMockEndpointsSatisfied();
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorResourceResolverFactoryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorResourceResolverFactoryTest.java
b/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorResourceResolverFactoryTest.java
index 08e0847..24e44c3 100644
--- a/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorResourceResolverFactoryTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/validator/ValidatorResourceResolverFactoryTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.validator;
 
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 
 import org.w3c.dom.ls.LSInput;
 import org.w3c.dom.ls.LSResourceResolver;
@@ -29,9 +30,9 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.model.language.ConstantExpression;
 import org.apache.camel.model.language.SimpleExpression;
-
 import org.junit.Assert;
 
+import static org.awaitility.Awaitility.await;
 
 public class ValidatorResourceResolverFactoryTest extends ContextTestSupport {
 
@@ -80,17 +81,13 @@ public class ValidatorResourceResolverFactoryTest extends ContextTestSupport
{
 
         template.sendBody(directStart, body);
 
-        // fetch dynamic endpoint
-        ValidatorEndpoint validatorEndpoint = null;
-        for (int i = 0; i < 5; i++) {
-            validatorEndpoint = resolveMandatoryEndpoint(endpointUri, ValidatorEndpoint.class);
-            if (validatorEndpoint != null) {
-                break;
-            }
-            // wait until endpoint is resolved
-            Thread.sleep(50);
-        }
+
+        // wait until endpoint is resolved
+        await().atMost(1, TimeUnit.SECONDS).until(() -> resolveMandatoryEndpoint(endpointUri,
ValidatorEndpoint.class) != null);
+
         MockEndpoint.assertIsSatisfied(endEndpoint);
+
+        ValidatorEndpoint validatorEndpoint = resolveMandatoryEndpoint(endpointUri, ValidatorEndpoint.class);
         Assert.assertNotNull(validatorEndpoint);
         CustomResourceResolver resolver = (CustomResourceResolver)validatorEndpoint.getResourceResolver();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/component/xslt/XsltUriResolverFactoryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/component/xslt/XsltUriResolverFactoryTest.java
b/camel-core/src/test/java/org/apache/camel/component/xslt/XsltUriResolverFactoryTest.java
index 2fe7a74..f65617d 100644
--- a/camel-core/src/test/java/org/apache/camel/component/xslt/XsltUriResolverFactoryTest.java
+++ b/camel-core/src/test/java/org/apache/camel/component/xslt/XsltUriResolverFactoryTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.xslt;
 import java.io.InputStream;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.TimeUnit;
 import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.URIResolver;
@@ -33,6 +34,8 @@ import org.apache.camel.model.language.ConstantExpression;
 import org.apache.camel.model.language.SimpleExpression;
 import org.junit.Assert;
 
+import static org.awaitility.Awaitility.await;
+
 /**
  *
  */
@@ -68,17 +71,15 @@ public class XsltUriResolverFactoryTest extends ContextTestSupport {
         mock.expectedMessageCount(1);
 
         sendBody(directStart, payloud);
-        XsltEndpoint xsltEndpoint = null;
-        for (int i = 0; i < 5; i++) {
-            xsltEndpoint = resolveMandatoryEndpoint(endpointUri, XsltEndpoint.class);
-            if (xsltEndpoint != null) {
-                break;
-            }
-            // wait until endpoint is resolved
-            Thread.sleep(50);
-        }
+
+        // wait until endpoint is resolved
+        await().atMost(1, TimeUnit.SECONDS).until(() -> resolveMandatoryEndpoint(endpointUri,
XsltEndpoint.class) != null);
+
         assertMockEndpointsSatisfied();
+
+        XsltEndpoint xsltEndpoint = resolveMandatoryEndpoint(endpointUri, XsltEndpoint.class);
         assertNotNull(xsltEndpoint);
+
         CustomXsltUriResolver resolver = (CustomXsltUriResolver)xsltEndpoint.getUriResolver();
         checkResourceUri(resolver.resolvedResourceUris, "xslt/staff/staff.xsl");
         checkResourceUri(resolver.resolvedResourceUris, "../common/staff_template.xsl");

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
b/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
index d0d8e32..0889f65 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/CamelPostProcessorHelperTest.java
@@ -19,6 +19,7 @@ package org.apache.camel.impl;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.util.Properties;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.BeanInject;
 import org.apache.camel.CamelContext;
@@ -40,6 +41,8 @@ import org.apache.camel.component.properties.PropertiesComponent;
 import org.apache.camel.support.SynchronizationAdapter;
 import org.apache.camel.util.ObjectHelper;
 
+import static org.awaitility.Awaitility.await;
+
 /**
  * @version
  */
@@ -130,7 +133,7 @@ public class CamelPostProcessorHelperTest extends ContextTestSupport {
         assertMockEndpointsSatisfied();
 
         // give UoW a bit of time
-        Thread.sleep(500);
+        await().atMost(1, TimeUnit.SECONDS).until(() -> mySynchronization.isOnDone());
 
         assertTrue("Should have invoked onDone", mySynchronization.isOnDone());
     }
@@ -150,7 +153,7 @@ public class CamelPostProcessorHelperTest extends ContextTestSupport {
         assertMockEndpointsSatisfied();
 
         // give UoW a bit of time
-        Thread.sleep(500);
+        await().atMost(1, TimeUnit.SECONDS).until(() -> mySynchronization.isOnDone());
 
         assertTrue("Should have invoked onDone", mySynchronization.isOnDone());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/ConsumerCacheZeroCapacityTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/ConsumerCacheZeroCapacityTest.java
b/camel-core/src/test/java/org/apache/camel/impl/ConsumerCacheZeroCapacityTest.java
index 3cbf2d4..d7614cb 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/ConsumerCacheZeroCapacityTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/ConsumerCacheZeroCapacityTest.java
@@ -16,9 +16,14 @@
  */
 package org.apache.camel.impl;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
 import org.apache.camel.PollingConsumer;
+import org.apache.camel.support.ServiceSupport;
+
+import static org.awaitility.Awaitility.await;
 
 /**
  * @version 
@@ -31,13 +36,13 @@ public class ConsumerCacheZeroCapacityTest extends ContextTestSupport
{
 
         assertEquals("Size should be 0", 0, cache.size());
 
-        Endpoint endpoint = context.getEndpoint("file:target/foo?fileName=foo.txt");
+        Endpoint endpoint = context.getEndpoint("file:target/foo?fileName=foo.txt&delay=10");
         PollingConsumer consumer = cache.acquirePollingConsumer(endpoint);
         assertNotNull(consumer);
         assertEquals("Started", ((org.apache.camel.support.ServiceSupport) consumer).getStatus().name());
 
         // let it run a poll
-        consumer.receive(1000);
+        consumer.receive(50);
 
         boolean found = Thread.getAllStackTraces().keySet().stream().anyMatch(t -> t.getName().contains("target/foo"));
         assertTrue("Should find file consumer thread", found);
@@ -45,7 +50,7 @@ public class ConsumerCacheZeroCapacityTest extends ContextTestSupport {
         cache.releasePollingConsumer(endpoint, consumer);
 
         // takes a little to stop
-        Thread.sleep(1000);
+        await().atMost(1, TimeUnit.SECONDS).until(() -> ((ServiceSupport) consumer).getStatus().isStopped());
 
         assertEquals("Stopped", ((org.apache.camel.support.ServiceSupport) consumer).getStatus().name());
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteStartupOrderTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteStartupOrderTest.java
b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteStartupOrderTest.java
index a8c4c1a..4819525 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteStartupOrderTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteStartupOrderTest.java
@@ -43,7 +43,7 @@ public class DefaultCamelContextSuspendResumeRouteStartupOrderTest extends
Conte
         context.suspend();
 
         // need to give seda consumer thread time to idle
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         template.sendBody("seda:foo", "B");
         mock.assertIsSatisfied(1000);

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteTest.java
b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteTest.java
index f7b6643..48a5b39 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultCamelContextSuspendResumeRouteTest.java
@@ -44,7 +44,7 @@ public class DefaultCamelContextSuspendResumeRouteTest extends ContextTestSuppor
         context.suspend();
 
         // need to give seda consumer thread time to idle
-        Thread.sleep(500);
+        Thread.sleep(100);
 
         template.sendBody("seda:foo", "B");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceManagerTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceManagerTest.java
b/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceManagerTest.java
index 6a003f2..84aa8cf 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceManagerTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DefaultExecutorServiceManagerTest.java
@@ -25,6 +25,7 @@ import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ThreadPoolRejectedPolicy;
 import org.apache.camel.spi.ThreadPoolProfile;
 import org.apache.camel.util.concurrent.SizedScheduledExecutorService;
+import org.junit.Ignore;
 
 /**
  * @version 
@@ -494,8 +495,8 @@ public class DefaultExecutorServiceManagerTest extends ContextTestSupport
{
         assertTrue(thread.getName().contains("Cool"));
     }
 
-    // this is a manual test, by looking at the logs
-    public void xxxTestLongShutdownOfThreadPool() throws Exception {
+    @Ignore("This is a manual test, by looking at the logs")
+    public void testLongShutdownOfThreadPool() throws Exception {
         final CountDownLatch latch = new CountDownLatch(1);
         ExecutorService pool = context.getExecutorServiceManager().newSingleThreadExecutor(this,
"Cool");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/DurationRoutePolicyMaxSecondsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/DurationRoutePolicyMaxSecondsTest.java
b/camel-core/src/test/java/org/apache/camel/impl/DurationRoutePolicyMaxSecondsTest.java
index 2890d92..624feaa 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/DurationRoutePolicyMaxSecondsTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/DurationRoutePolicyMaxSecondsTest.java
@@ -16,9 +16,13 @@
  */
 package org.apache.camel.impl;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 
+import static org.awaitility.Awaitility.await;
+
 public class DurationRoutePolicyMaxSecondsTest extends ContextTestSupport {
 
     public void testDurationRoutePolicy() throws Exception {
@@ -30,14 +34,12 @@ public class DurationRoutePolicyMaxSecondsTest extends ContextTestSupport
{
         assertMockEndpointsSatisfied();
 
         // need a little time to stop async
-        for (int i = 0; i < 10; i++) {
-            Thread.sleep(100);
+        await().atMost(5, TimeUnit.SECONDS).until(() -> {
             boolean started = context.getRouteStatus("foo").isStarted();
             boolean stopped = context.getRouteStatus("foo").isStopped();
-            if (!started && stopped) {
-                break;
-            }
-        }
+            return !started && stopped;
+        });
+
         assertFalse(context.getRouteStatus("foo").isStarted());
         assertTrue(context.getRouteStatus("foo").isStopped());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
b/camel-core/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
index 82a271c..e6ccd61 100644
--- a/camel-core/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
+++ b/camel-core/src/test/java/org/apache/camel/impl/cloud/CachingServiceDiscoveryTest.java
@@ -26,10 +26,11 @@ import org.junit.Assert;
 import org.junit.Test;
 
 public class CachingServiceDiscoveryTest extends ContextTestSupport {
+
     @Test
     public void testCachingServiceDiscovery() throws Exception {
         StaticServiceDiscovery discovery = new StaticServiceDiscovery();
-        CachingServiceDiscovery caching = CachingServiceDiscovery.wrap(discovery, 1, TimeUnit.SECONDS);
+        CachingServiceDiscovery caching = CachingServiceDiscovery.wrap(discovery, 50, TimeUnit.MILLISECONDS);
 
         discovery.addServer(new DefaultServiceDefinition("noname", "localhost", 1111));
         Assert.assertEquals(1, caching.getServices("noname").size());
@@ -37,7 +38,7 @@ public class CachingServiceDiscoveryTest extends ContextTestSupport {
         Assert.assertEquals(1, caching.getServices("noname").size());
 
         // Let the cache expire
-        Thread.sleep(1100);
+        Thread.sleep(100);
 
         Assert.assertEquals(2, caching.getServices("noname").size());
     }
@@ -49,8 +50,8 @@ public class CachingServiceDiscoveryTest extends ContextTestSupport {
 
         CachingServiceCallServiceDiscoveryConfiguration cachingConf = new CachingServiceCallServiceDiscoveryConfiguration();
         cachingConf.setServiceDiscoveryConfiguration(staticConf);
-        cachingConf.setTimeout(1);
-        cachingConf.setUnits(TimeUnit.SECONDS);
+        cachingConf.setTimeout(50);
+        cachingConf.setUnits(TimeUnit.MILLISECONDS);
 
         CachingServiceDiscovery caching = (CachingServiceDiscovery)cachingConf.newInstance(context);
         StaticServiceDiscovery delegate = (StaticServiceDiscovery)caching.getDelegate();
@@ -60,7 +61,7 @@ public class CachingServiceDiscoveryTest extends ContextTestSupport {
         Assert.assertEquals(1, caching.getServices("no-name").size());
 
         // Let the cache expire
-        Thread.sleep(1100);
+        Thread.sleep(100);
 
         Assert.assertEquals(2, caching.getServices("no-name").size());
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointDelayUoWTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointDelayUoWTest.java
b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointDelayUoWTest.java
index 98c22f6..281f9f4 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointDelayUoWTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointDelayUoWTest.java
@@ -44,7 +44,7 @@ public class AsyncEndpointDelayUoWTest extends ContextTestSupport {
         assertMockEndpointsSatisfied();
 
         // wait a bit to ensure UoW has been run
-        Thread.sleep(1000);
+        assertTrue(oneExchangeDone.matchesMockWaitTime());
 
         assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
         assertEquals(1, sync.isOnComplete());

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWFailedTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWFailedTest.java
b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWFailedTest.java
index 4f7056e..b04fc41 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWFailedTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWFailedTest.java
@@ -50,7 +50,7 @@ public class AsyncEndpointUoWFailedTest extends ContextTestSupport {
         assertMockEndpointsSatisfied();
 
         // wait a bit to ensure UoW has been run
-        Thread.sleep(1000);
+        assertTrue(oneExchangeDone.matchesMockWaitTime());
 
         assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
         assertEquals(0, sync.isOnComplete());

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWTest.java
b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWTest.java
index 728d1a4..ebc74bb 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/async/AsyncEndpointUoWTest.java
@@ -44,7 +44,7 @@ public class AsyncEndpointUoWTest extends ContextTestSupport {
         assertMockEndpointsSatisfied();
 
         // wait a bit to ensure UoW has been run
-        Thread.sleep(1000);
+        assertTrue(oneExchangeDone.matchesMockWaitTime());
 
         assertFalse("Should use different threads", beforeThreadName.equalsIgnoreCase(afterThreadName));
         assertEquals(1, sync.isOnComplete());

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/processor/onexception/ContextScopedOnExceptionLoadBalancerStopRouteTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/processor/onexception/ContextScopedOnExceptionLoadBalancerStopRouteTest.java
b/camel-core/src/test/java/org/apache/camel/processor/onexception/ContextScopedOnExceptionLoadBalancerStopRouteTest.java
index 6750231..f6e9682 100644
--- a/camel-core/src/test/java/org/apache/camel/processor/onexception/ContextScopedOnExceptionLoadBalancerStopRouteTest.java
+++ b/camel-core/src/test/java/org/apache/camel/processor/onexception/ContextScopedOnExceptionLoadBalancerStopRouteTest.java
@@ -16,11 +16,15 @@
  */
 package org.apache.camel.processor.onexception;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.ServiceStatus;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.seda.SedaEndpoint;
 
+import static org.awaitility.Awaitility.await;
+
 public class ContextScopedOnExceptionLoadBalancerStopRouteTest extends ContextTestSupport
{
 
     public void testOk() throws Exception {
@@ -67,7 +71,7 @@ public class ContextScopedOnExceptionLoadBalancerStopRouteTest extends ContextTe
         template.sendBody("direct:start", "World");
 
         // give time for route to stop
-        Thread.sleep(1000);
+        await().atMost(1, TimeUnit.SECONDS).until(() -> context.getRouteStatus("errorRoute").isStopped());
         assertEquals(ServiceStatus.Stopped, context.getRouteStatus("errorRoute"));
 
         template.sendBody("direct:start", "Kaboom");

http://git-wip-us.apache.org/repos/asf/camel/blob/7a9a6acb/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java
b/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java
index 731c6e7..d608375 100644
--- a/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java
+++ b/camel-core/src/test/java/org/apache/camel/support/DefaultTimeoutMapTest.java
@@ -21,11 +21,14 @@ import java.util.List;
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
 
 import junit.framework.TestCase;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.awaitility.Awaitility.await;
+
 /**
  * @version 
  */
@@ -249,11 +252,8 @@ public class DefaultTimeoutMapTest extends TestCase {
         map.start();
 
         // start and wait for scheduler to purge
-        Thread.sleep(250);
-        if (map.size() > 0) {
-            LOG.warn("Waiting extra due slow CI box");
-            Thread.sleep(1000);
-        }
+        await().atMost(2, TimeUnit.SECONDS).until(() -> map.size() == 0);
+
         // now it should be gone
         assertEquals(0, map.size());
 


Mime
View raw message