You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2017/07/14 18:52:09 UTC

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

Repository: camel
Updated Branches:
  refs/heads/master d700f9f3f -> 722e590cb


CAMEL-11446: Use awaitility 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/722e590c
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/722e590c
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/722e590c

Branch: refs/heads/master
Commit: 722e590cbe7a1ec8fd7fec79ced9d99eceb25f03
Parents: d700f9f
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Jul 14 20:51:49 2017 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Jul 14 20:51:49 2017 +0200

----------------------------------------------------------------------
 .../camel/spring/DefaultJMXAgentTest.java       | 11 ++++++--
 .../apache/camel/spring/MainExampleTest.java    | 13 +++++----
 .../java/org/apache/camel/spring/MainTest.java  |  2 +-
 .../PojoDualCamelContextConsumerTest.java       |  3 +-
 .../file/SpringFileConsumerPreMoveTest.java     | 18 ++----------
 ...eTransactedWithFileLocalOnExceptionTest.java |  4 +--
 ...SourceTransactedWithFileOnExceptionTest.java | 28 +++++++++++--------
 ...lClientDataSourceTransactedWithFileTest.java | 29 +++++++++++---------
 .../apache/camel/spring/mock/BeanMockTest.java  |  4 +--
 ...geWithSprinPropertyPlaceholderRouteTest.java | 11 ++++----
 .../idempotent/FileConsumerIdempotentTest.java  |  5 ++--
 .../SpringTokenXMLPairNamespaceSplitTest.xml    |  2 +-
 .../camel/language/SpringXMLTokenSplitTest.xml  |  2 +-
 ...FileAntPathMatcherFileFilterTest-context.xml |  2 +-
 .../file/SpringFileConsumerPreMoveIssueTest.xml |  2 +-
 .../file/SpringFileConsumerPreMoveTest.xml      |  2 +-
 .../spring/file/SpringFileLanguageCBRTest.xml   |  2 +-
 ...pringSimpleFileNameWithQuoteTest-context.xml |  2 +-
 .../CamelContextModelErrorHandlerIssueTest.xml  |  2 +-
 .../camel/spring/issues/CustomIdIssueTest.xml   |  2 +-
 .../FileWireTapWithXMLPayloadIssueTest.xml      |  2 +-
 .../SpringRenameFileOnCommitIssueTest.xml       |  2 +-
 ...lCamelContextManagedAutoAssignedNameTest.xml |  4 +--
 .../management/dualCamelContextManagedTest.xml  |  4 +--
 .../org/apache/camel/spring/mock/spring.xml     |  2 +-
 .../processor/ShutdownCompleteAllTasksTest.xml  |  2 +-
 .../ShutdownCompleteCurrentTaskOnlyTest.xml     |  2 +-
 ...erChannelUseOriginalExchangeWithFileTest.xml |  2 +-
 .../idempotent/fileConsumerIdempotentTest.xml   |  2 +-
 29 files changed, 83 insertions(+), 85 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java
index 9929976..fa88d2d 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/DefaultJMXAgentTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring;
 
 import java.lang.management.ManagementFactory;
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 import javax.management.MBeanServer;
 import javax.management.MBeanServerConnection;
 import javax.management.MBeanServerFactory;
@@ -26,6 +27,8 @@ import javax.management.ObjectName;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
+import static org.awaitility.Awaitility.await;
+
 /**
  * Test that verifies JMX is enabled by default.
  *
@@ -34,7 +37,6 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
 public class DefaultJMXAgentTest extends SpringTestSupport {
 
     protected MBeanServerConnection mbsc;
-    protected long sleepForConnection = 3000;
 
     @Override
     protected boolean useJmx() {
@@ -45,8 +47,11 @@ public class DefaultJMXAgentTest extends SpringTestSupport {
     protected void setUp() throws Exception {
         releaseMBeanServers();
         super.setUp();
-        Thread.sleep(sleepForConnection);
-        mbsc = getMBeanConnection();
+
+        await().atMost(3, TimeUnit.SECONDS).ignoreExceptions().until(() -> {
+            mbsc = getMBeanConnection();
+            return true;
+        });
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/MainExampleTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/MainExampleTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/MainExampleTest.java
index 7179268..bf39867 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/MainExampleTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/MainExampleTest.java
@@ -30,13 +30,14 @@ public class MainExampleTest extends TestCase {
         main.addRouteBuilder(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://src/test/data?noop=true").process(new MyProcessor()).to("file://target/mainTest");
+                from("file://src/test/data?initialDelay=0&delay=10&noop=true").process(new MyProcessor()).to("file://target/mainTest");
             }
         });
         main.start();
 
-        // then some time later
-        Thread.sleep(1000);
+        // run for 100 millis
+        main.setDuration(100);
+
         main.stop();
     }
     
@@ -44,8 +45,10 @@ public class MainExampleTest extends TestCase {
         Main main = new Main();
         main.setFileApplicationContextUri("src/test/resources/org/apache/camel/spring/routingUsingProcessor.xml");
         main.start();
-        // sleep for a while
-        Thread.sleep(1000);
+
+        // run for 100 millis
+        main.setDuration(100);
+
         main.stop();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/MainTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/MainTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/MainTest.java
index 74782ae..4882704 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/MainTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/MainTest.java
@@ -39,7 +39,7 @@ public class MainTest extends TestCase {
         main.addRouteBuilder(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://src/test/data?noop=true").process(new MyProcessor()).to("mock:results");
+                from("file://src/test/data?initialDelay=0&delay=10&noop=true").process(new MyProcessor()).to("mock:results");
             }
         });
         main.start();

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
index 59c23c7..5563321 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/example/PojoDualCamelContextConsumerTest.java
@@ -65,14 +65,13 @@ public class PojoDualCamelContextConsumerTest extends TestSupport {
         // seda:foo has no consumer in camel-1 so we should not expect any messages to be routed to result/foo
         MockEndpoint result = camel1.getEndpoint("mock:result", MockEndpoint.class);
         result.expectedMessageCount(0);
+        result.setResultMinimumWaitTime(50);
 
         ProducerTemplate template = camel1.createProducerTemplate();
         template.start();
         template.sendBody("seda:foo", body);
         template.stop();
 
-        Thread.sleep(200);
-        
         result.assertIsSatisfied();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
index 6958457..d6ace72 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.java
@@ -18,25 +18,13 @@ package org.apache.camel.spring.file;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.component.file.FileConsumerPreMoveTest;
-import org.springframework.context.support.AbstractXmlApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
 public class SpringFileConsumerPreMoveTest extends FileConsumerPreMoveTest {
-    private AbstractXmlApplicationContext applicationContext;
 
-    @Override
     protected CamelContext createCamelContext() throws Exception {
-        applicationContext = new ClassPathXmlApplicationContext(
-            "org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml");
-        return applicationContext.getBean(CamelContext.class);
-    }
-
-    @Override
-    protected void tearDown() throws Exception {
-        if (applicationContext != null) {
-            applicationContext.stop();
-        }
-        super.tearDown();
+        return createSpringCamelContext(this, "org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml");
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest.java
index a72e1e6..3ff8ddf 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest.java
@@ -28,12 +28,12 @@ public class TransactionalClientDataSourceTransactedWithFileLocalOnExceptionTest
         return new SpringRouteBuilder() {
             public void configure() throws Exception {
 
-                from("file://target/transacted/okay")
+                from("file://target/transacted/okay?initialDelay=0&delay=10")
                     .transacted()
                     .setBody(constant("Tiger in Action")).bean("bookService")
                     .setBody(constant("Elephant in Action")).bean("bookService");
 
-                from("file://target/transacted/fail?moveFailed=../failed")
+                from("file://target/transacted/fail?initialDelay=0&delay=10&moveFailed=../failed")
                     .onException(IllegalArgumentException.class)
                         .handled(false)
                         .to("mock:error")

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
index fe03c43..120775e 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileOnExceptionTest.java
@@ -16,11 +16,15 @@
  */
 package org.apache.camel.spring.interceptor;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.spring.SpringRouteBuilder;
 
+import static org.awaitility.Awaitility.await;
+
 /**
  * @version 
  */
@@ -29,11 +33,11 @@ public class TransactionalClientDataSourceTransactedWithFileOnExceptionTest exte
     public void testTransactionSuccess() throws Exception {
         template.sendBodyAndHeader("file://target/transacted/okay", "Hello World", Exchange.FILE_NAME, "okay.txt");
 
-        // wait for route to complete
-        Thread.sleep(3000);
-
-        int count = jdbc.queryForObject("select count(*) from books", Integer.class);
-        assertEquals("Number of books", 3, count);
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // wait for route to complete
+            int count = jdbc.queryForObject("select count(*) from books", Integer.class);
+            assertEquals("Number of books", 3, count);
+        });
     }
 
     public void testTransactionRollback() throws Exception {
@@ -46,11 +50,11 @@ public class TransactionalClientDataSourceTransactedWithFileOnExceptionTest exte
         template.sendBodyAndHeader("file://target/transacted/fail", "Hello World", Exchange.FILE_NAME, "fail.txt");
 
         // wait for route to complete
-        Thread.sleep(3000);
-
-        // should not be able to process the file so we still got 1 book as we did from the start
-        int count = jdbc.queryForObject("select count(*) from books", Integer.class);
-        assertEquals("Number of books", 1, count);
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // should not be able to process the file so we still got 1 book as we did from the start
+            int count = jdbc.queryForObject("select count(*) from books", Integer.class);
+            assertEquals("Number of books", 1, count);
+        });
 
         assertMockEndpointsSatisfied();
     }
@@ -60,12 +64,12 @@ public class TransactionalClientDataSourceTransactedWithFileOnExceptionTest exte
             public void configure() throws Exception {
                 onException(IllegalArgumentException.class).handled(false).to("mock:error");
 
-                from("file://target/transacted/okay")
+                from("file://target/transacted/okay?initialDelay=0&delay=10")
                     .transacted()
                     .setBody(constant("Tiger in Action")).bean("bookService")
                     .setBody(constant("Elephant in Action")).bean("bookService");
 
-                from("file://target/transacted/fail?moveFailed=../failed")
+                from("file://target/transacted/fail?initialDelay=0&delay=10&moveFailed=../failed")
                     .transacted()
                     .setBody(constant("Tiger in Action")).bean("bookService")
                     .setBody(constant("Donkey in Action")).bean("bookService");

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
index 1d33f1e..c916547 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTransactedWithFileTest.java
@@ -16,10 +16,14 @@
  */
 package org.apache.camel.spring.interceptor;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spring.SpringRouteBuilder;
 
+import static org.awaitility.Awaitility.await;
+
 /**
  * @version 
  */
@@ -34,33 +38,32 @@ public class TransactionalClientDataSourceTransactedWithFileTest extends Transac
     public void testTransactionSuccess() throws Exception {
         template.sendBodyAndHeader("file://target/transacted/okay", "Hello World", Exchange.FILE_NAME, "okay.txt");
 
-        // wait for route to complete
-        Thread.sleep(3000);
-
-        int count = jdbc.queryForObject("select count(*) from books", Integer.class);
-        assertEquals("Number of books", 3, count);
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // wait for route to complete
+            int count = jdbc.queryForObject("select count(*) from books", Integer.class);
+            assertEquals("Number of books", 3, count);
+        });
     }
 
     public void testTransactionRollback() throws Exception {
         template.sendBodyAndHeader("file://target/transacted/fail", "Hello World", Exchange.FILE_NAME, "fail.txt");
 
-        // wait for route to complete
-        Thread.sleep(3000);
-
-        // should not be able to process the file so we still got 1 book as we did from the start
-        int count = jdbc.queryForObject("select count(*) from books", Integer.class);
-        assertEquals("Number of books", 1, count);
+        await().atMost(3, TimeUnit.SECONDS).untilAsserted(() -> {
+            // should not be able to process the file so we still got 1 book as we did from the start
+            int count = jdbc.queryForObject("select count(*) from books", Integer.class);
+            assertEquals("Number of books", 1, count);
+        });
     }
 
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new SpringRouteBuilder() {
             public void configure() throws Exception {
-                from("file://target/transacted/okay")
+                from("file://target/transacted/okay?initialDelay=0&delay=10")
                     .transacted()
                     .setBody(constant("Tiger in Action")).bean("bookService")
                     .setBody(constant("Elephant in Action")).bean("bookService");
 
-                from("file://target/transacted/fail?delay=1000")
+                from("file://target/transacted/fail?initialDelay=0&delay=10")
                     .transacted()
                     .setBody(constant("Tiger in Action")).bean("bookService")
                     .setBody(constant("Donkey in Action")).bean("bookService");

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/mock/BeanMockTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/mock/BeanMockTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/mock/BeanMockTest.java
index 1199f78..fe8db29 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/mock/BeanMockTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/mock/BeanMockTest.java
@@ -24,12 +24,10 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
  * @version 
  */
 public class BeanMockTest extends ApplicationContextTestSupport {
+
     public void testAssertionsUsingBean() throws Exception {
         MyAssertions bean = getMandatoryBean(MyAssertions.class, "myBean");
         bean.assertEndpointsValid();
-
-        // give time for file consumer to stop properly
-        Thread.sleep(20);
     }
 
     protected AbstractXmlApplicationContext createApplicationContext() {

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
index 0f12600..8aedea5 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/placeholder/SimpleLanguageWithSprinPropertyPlaceholderRouteTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.spring.placeholder;
 
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.concurrent.TimeUnit;
 
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
@@ -28,6 +29,8 @@ import org.junit.Test;
 import org.springframework.test.annotation.DirtiesContext;
 import org.springframework.test.context.ContextConfiguration;
 
+import static org.awaitility.Awaitility.await;
+
 @ContextConfiguration
 public class SimpleLanguageWithSprinPropertyPlaceholderRouteTest extends SpringRunWithTestSupport {
     
@@ -45,9 +48,7 @@ public class SimpleLanguageWithSprinPropertyPlaceholderRouteTest extends SpringR
     public void replaceSimpleExpression() throws Exception {
         template.sendBody("Test");
 
-        Thread.sleep(500);
-        
-        assertFileExists("target/outBoxSimple/");
+        await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> assertFileExists("target/outBoxSimple/"));
     }
     
     @Ignore(value = "disabled because of https://jira.springsource.org/browse/SPR-7593")
@@ -56,9 +57,7 @@ public class SimpleLanguageWithSprinPropertyPlaceholderRouteTest extends SpringR
     public void replaceExpression() throws Exception {
         template.sendBody("direct:start", "Test");
 
-        Thread.sleep(500);
-        
-        assertFileExists("target/outBox/" + getTestFileName());
+        await().atMost(2, TimeUnit.SECONDS).untilAsserted(() -> assertFileExists("target/outBox/" + getTestFileName()));
     }
 
     private String getTestFileName() {

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/java/org/apache/camel/spring/processor/idempotent/FileConsumerIdempotentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/idempotent/FileConsumerIdempotentTest.java b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/idempotent/FileConsumerIdempotentTest.java
index 0d39744..4910235 100644
--- a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/idempotent/FileConsumerIdempotentTest.java
+++ b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/idempotent/FileConsumerIdempotentTest.java
@@ -58,15 +58,14 @@ public class FileConsumerIdempotentTest extends ContextTestSupport {
         // reset mock and set new expectations
         mock.reset();
         mock.expectedMessageCount(0);
+        // sleep to let the consumer try to poll the file
+        mock.setResultMinimumWaitTime(50);
 
         // move file back
         File file = new File("target/fileidempotent/done/report.txt");
         File renamed = new File("target/fileidempotent/report.txt");
         file.renameTo(renamed);
 
-        // sleep to let the consumer try to poll the file
-        Thread.sleep(2000);
-
         // should NOT consume the file again, let 2 secs pass to let the consumer try to consume it but it should not
         assertMockEndpointsSatisfied();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/language/SpringTokenXMLPairNamespaceSplitTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/language/SpringTokenXMLPairNamespaceSplitTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/language/SpringTokenXMLPairNamespaceSplitTest.xml
index 725dddd..2d582af 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/language/SpringTokenXMLPairNamespaceSplitTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/language/SpringTokenXMLPairNamespaceSplitTest.xml
@@ -27,7 +27,7 @@
   <!-- START SNIPPET: e1 -->
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
-      <from uri="file:target/pair"/>
+      <from uri="file:target/pair?initialDelay=0&amp;delay=10"/>
       <split>
         <!-- split the file using XML tokenizer, where we grab the order tag,
              and inherit the namespaces from the parent/root orders tag

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/language/SpringXMLTokenSplitTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/language/SpringXMLTokenSplitTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/language/SpringXMLTokenSplitTest.xml
index 28570ba..b0d7b7d 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/language/SpringXMLTokenSplitTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/language/SpringXMLTokenSplitTest.xml
@@ -27,7 +27,7 @@
   <!-- START SNIPPET: e1 -->
   <camelContext xmlns="http://camel.apache.org/schema/spring" xmlns:s="http:acme.com">
     <route>
-      <from uri="file:target/xtokenizer"/>
+      <from uri="file:target/xtokenizer?initialDelay=0&amp;delay=10"/>
       <split>
         <!-- split the file using XML tokenizer, where we grab the order tag,
              and inject the namespaces declarations from its ancestor nodes -->

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileAntPathMatcherFileFilterTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileAntPathMatcherFileFilterTest-context.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileAntPathMatcherFileFilterTest-context.xml
index ac0a9c2..9c5c54b 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileAntPathMatcherFileFilterTest-context.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileAntPathMatcherFileFilterTest-context.xml
@@ -29,7 +29,7 @@
         <template id="camelTemplate"/>
 
         <!-- use myFilter as filter to allow setting ANT paths for which files to scan for -->
-        <endpoint id="myFileEndpoint" uri="file://target/antpathmatcher?recursive=true&amp;filter=#myAntFilter"/>
+        <endpoint id="myFileEndpoint" uri="file://target/antpathmatcher?initialDelay=0&amp;delay=10&amp;recursive=true&amp;filter=#myAntFilter"/>
 
         <route>
             <from ref="myFileEndpoint"/>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
index d514f2c..cd8c776 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveIssueTest.xml
@@ -26,7 +26,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/premove?preMove=before/${file:name.noext}-moved.${file:ext}"/>
+            <from uri="file://target/premove?initialDelay=0&amp;delay=10&amp;preMove=before/${file:name.noext}-moved.${file:ext}"/>
             <process ref="checker"/>
             <to uri="mock:result"/>
         </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml
index 2396843..6e5f83b 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileConsumerPreMoveTest.xml
@@ -26,7 +26,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/premove?preMove=work/work-${file:name}"/>
+            <from uri="file://target/premove?initialDelay=0&amp;delay=10&amp;preMove=work/work-${file:name}"/>
             <process ref="checker"/>
             <to uri="mock:result"/>
         </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileLanguageCBRTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileLanguageCBRTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileLanguageCBRTest.xml
index 534cb25..c45657f 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileLanguageCBRTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringFileLanguageCBRTest.xml
@@ -27,7 +27,7 @@
     <!-- START SNIPPET: e1 -->
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/cbr?delete=true"/>
+            <from uri="file://target/cbr?initialDelay=0&amp;delay=10&amp;delete=true"/>
             <choice>
                 <when>
                     <simple>${file:ext} == 'txt'</simple>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest-context.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest-context.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest-context.xml
index 8041be6..f9e30e7 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest-context.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/file/SpringSimpleFileNameWithQuoteTest-context.xml
@@ -26,7 +26,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/foo"/>
+            <from uri="file://target/foo?initialDelay=0&amp;delay=10"/>
             <setHeader headerName="foo">
                 <simple>"${file:name}" abc</simple>
             </setHeader>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CamelContextModelErrorHandlerIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CamelContextModelErrorHandlerIssueTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CamelContextModelErrorHandlerIssueTest.xml
index 5649a63..349bf64 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CamelContextModelErrorHandlerIssueTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CamelContextModelErrorHandlerIssueTest.xml
@@ -23,7 +23,7 @@
                       retryAttemptedLogLevel="ERROR" asyncDelayedRedelivery="true" maximumRedeliveries="6"/>
   </errorHandler>
   <route>
-    <from uri="file:src/data?noop=true"/>
+    <from uri="file:src/data?initialDelay=0&amp;delay=10&amp;noop=true"/>
     <choice>
       <when>
         <xpath>/person/city = 'London'</xpath>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
index 717530b..3035a36 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/CustomIdIssueTest.xml
@@ -29,7 +29,7 @@
       <description>here is a sample which processes the input files
         (leaving them in place - see the 'noop' flag)
         then performs content based routing on the message using XPath</description>
-      <from uri="file:src/data?noop=true" customId="true" id="fromFile">
+      <from uri="file:src/data?initialDelay=0&amp;delay=10&amp;noop=true" customId="true" id="fromFile">
         <description/>
       </from>
       <choice customId="true" id="myChoice">

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/FileWireTapWithXMLPayloadIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/FileWireTapWithXMLPayloadIssueTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/FileWireTapWithXMLPayloadIssueTest.xml
index 356ba89..449a88a 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/FileWireTapWithXMLPayloadIssueTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/FileWireTapWithXMLPayloadIssueTest.xml
@@ -26,7 +26,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/xmldata"/>
+            <from uri="file://target/xmldata?initialDelay=0&amp;delay=10"/>
             <convertBodyTo type="java.lang.String"/>
             <wireTap uri="mock:wiretap"/>
             <to uri="mock:result"/>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringRenameFileOnCommitIssueTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringRenameFileOnCommitIssueTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringRenameFileOnCommitIssueTest.xml
index f5b5b93..1b849cf 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringRenameFileOnCommitIssueTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/issues/SpringRenameFileOnCommitIssueTest.xml
@@ -27,7 +27,7 @@
 
     <camelContext trace="true" xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/renameissue?noop=false"/>
+            <from uri="file://target/renameissue?initialDelay=0&amp;delay=10&amp;noop=false"/>
             <setProperty propertyName="PartitionID">
                 <xpath>//persons/person[1]/@name</xpath>
             </setProperty>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml
index 3831522..8287482 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedAutoAssignedNameTest.xml
@@ -26,7 +26,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         
-        <endpoint id="fromFile" uri="file://target/route1"/>
+        <endpoint id="fromFile" uri="file://target/route1?initialDelay=0&amp;delay=10"/>
         <endpoint id="mock1" uri="mock:mock1"/>
 
         <route id="route1">
@@ -38,7 +38,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         
-        <endpoint id="fromFile2" uri="file://target/route2"/>
+        <endpoint id="fromFile2" uri="file://target/route2?initialDelay=0&amp;delay=10"/>
         <endpoint id="mock2" uri="mock:mock2"/>
 
         <route id="route2">

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
index 1cb003f..ab7bf40 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/management/dualCamelContextManagedTest.xml
@@ -26,7 +26,7 @@
 
     <camelContext id="camel-A" xmlns="http://camel.apache.org/schema/spring">
         
-        <endpoint id="fromFile" uri="file://target/route1"/>
+        <endpoint id="fromFile" uri="file://target/route1?initialDelay=0&amp;delay=10"/>
         <endpoint id="mock1" uri="mock:mock1"/>
 
         <route id="route1">
@@ -38,7 +38,7 @@
 
     <camelContext id="camel-B" xmlns="http://camel.apache.org/schema/spring">
         
-        <endpoint id="fromFile2" uri="file://target/route2"/>
+        <endpoint id="fromFile2" uri="file://target/route2?initialDelay=0&amp;delay=10"/>
         <endpoint id="mock2" uri="mock:mock2"/>
 
         <route id="route2">

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/spring.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/spring.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/spring.xml
index dd36680..6acaeb5 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/spring.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/mock/spring.xml
@@ -27,7 +27,7 @@
   <!-- START SNIPPET: example -->
   <camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
-      <from uri="file:src/test/data?noop=true"/>
+      <from uri="file:src/test/data?initialDelay=0&amp;delay=10&amp;noop=true"/>
       <filter>
         <xpath>/person/city = 'London'</xpath>
         <to uri="mock:matched"/>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
index bb99afe..e2544ab 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteAllTasksTest.xml
@@ -35,7 +35,7 @@
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <!-- let this route complete all its pending messages when asked to shutdown -->
         <route id="foo" autoStartup="false" shutdownRunningTask="CompleteAllTasks">
-            <from uri="file:target/pending"/>
+            <from uri="file:target/pending?initialDelay=0&amp;delay=10"/>
             <delay><constant>1000</constant></delay>
             <process ref="myProcessor"/>
             <to uri="mock:bar"/>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteCurrentTaskOnlyTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteCurrentTaskOnlyTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteCurrentTaskOnlyTest.xml
index f7130ea..d6989e1 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteCurrentTaskOnlyTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ShutdownCompleteCurrentTaskOnlyTest.xml
@@ -31,7 +31,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route startupOrder="1" shutdownRunningTask="CompleteCurrentTaskOnly">
-            <from uri="file:target/pending"/>
+            <from uri="file:target/pending?initialDelay=0&amp;delay=10"/>
             <delay><constant>1000</constant></delay>
             <to uri="seda:foo"/>
         </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
index d11c1be..af8fddf 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringDeadLetterChannelUseOriginalExchangeWithFileTest.xml
@@ -57,7 +57,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring" errorHandlerRef="dead">
         <route>
-            <from uri="file://target/originalexchange?noop=true"/>
+            <from uri="file://target/originalexchange?initialDelay=0&amp;delay=10&amp;noop=true"/>
             <transform><simple>${in.body} World</simple></transform>
             <process ref="myThrowProcessor"/>
         </route>

http://git-wip-us.apache.org/repos/asf/camel/blob/722e590c/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/idempotent/fileConsumerIdempotentTest.xml
----------------------------------------------------------------------
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/idempotent/fileConsumerIdempotentTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/idempotent/fileConsumerIdempotentTest.xml
index 22f21de..bb2c385 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/idempotent/fileConsumerIdempotentTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/idempotent/fileConsumerIdempotentTest.xml
@@ -38,7 +38,7 @@
 
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
-            <from uri="file://target/fileidempotent/?idempotent=true&amp;idempotentRepository=#fileStore&amp;move=done/${file:name}"/>
+            <from uri="file://target/fileidempotent/?initialDelay=0&amp;delay=10&amp;idempotent=true&amp;idempotentRepository=#fileStore&amp;move=done/${file:name}"/>
             <to uri="mock:result"/>
         </route>
     </camelContext>