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 for testing where we otherwise use thred sleep which can be speeded up.
Date Sat, 15 Jul 2017 14:11:58 GMT
Repository: camel
Updated Branches:
  refs/heads/master 9776b8494 -> 0fb523a9b


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/0fb523a9
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0fb523a9
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0fb523a9

Branch: refs/heads/master
Commit: 0fb523a9b21b46ffec5c2c42e348345af9cd7012
Parents: 9776b84
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sat Jul 15 16:11:30 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sat Jul 15 16:11:30 2017 +0200

----------------------------------------------------------------------
 .../issues/FilePollingConsumerIssueTest.java    |  2 +-
 .../FileSplitStreamingWithChoiceTest.java       |  2 +-
 ...yBuilderOnFailureShutdownCamelIssueTest.java |  2 +-
 .../camel/issues/OnCompletionIssueTest.java     |  2 --
 ...iginalMessageEndpointExceptionIssueTest.java |  2 +-
 ...yRouteScopedUntilRecipientListIssueTest.java | 11 +++----
 ...opedUntilRecipientListParallelIssueTest.java |  1 -
 .../RetryWhilePredicateExpressionIssueTest.java |  1 +
 .../RetryWhileSimpleExpressionIssueTest.java    |  1 +
 .../issues/SplitPropertiesFileIssueTest.java    |  2 +-
 ...eadsRejectedExecutionWithDeadLetterTest.java | 33 ++++++++++++++++++--
 .../issues/TimerAndErrorHandlerIssueTest.java   |  3 +-
 .../camel/issues/XPathSplitStreamTest.java      |  2 +-
 13 files changed, 45 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/FilePollingConsumerIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/FilePollingConsumerIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/FilePollingConsumerIssueTest.java
index 2a8692c..5071492 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/FilePollingConsumerIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/FilePollingConsumerIssueTest.java
@@ -35,7 +35,7 @@ public class FilePollingConsumerIssueTest extends ContextTestSupport {
     public void testFilePollingConsumer() throws Exception {
         template.sendBodyAndHeader("file://target/fpc", "Hello World", Exchange.FILE_NAME,
"hello.txt");
 
-        Endpoint endpoint = context.getEndpoint("file://target/fpc?fileName=hello.txt");
+        Endpoint endpoint = context.getEndpoint("file://target/fpc?initialDelay=0&delay=10&fileName=hello.txt");
         PollingConsumer consumer = endpoint.createPollingConsumer();
         consumer.start();
         Exchange exchange = consumer.receive(5000);

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/FileSplitStreamingWithChoiceTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/FileSplitStreamingWithChoiceTest.java
b/camel-core/src/test/java/org/apache/camel/issues/FileSplitStreamingWithChoiceTest.java
index bde7b6b..5c087ba 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/FileSplitStreamingWithChoiceTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/FileSplitStreamingWithChoiceTest.java
@@ -52,7 +52,7 @@ public class FileSplitStreamingWithChoiceTest extends ContextTestSupport
{
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/filesplit")
+                from("file://target/filesplit?initialDelay=0&delay=10")
                     .split(body().tokenize(LS)).streaming()
                     .to("mock:split")
                     .choice()

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
index 4efe1ab..ddb9061 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/NotifyBuilderOnFailureShutdownCamelIssueTest.java
@@ -35,7 +35,7 @@ public class NotifyBuilderOnFailureShutdownCamelIssueTest extends ContextTestSup
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("timer:foo?period=100")
+                from("timer:foo?delay=0&period=10")
                     .throwException(new IllegalArgumentException("Forced"));
             }
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java b/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
index 6f4dac0..e34638b 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/OnCompletionIssueTest.java
@@ -54,8 +54,6 @@ public class OnCompletionIssueTest extends ContextTestSupport {
             assertIsInstanceOf(RollbackExchangeException.class, e.getCause());
         }
 
-        setAssertPeriod(2000);
-
         assertMockEndpointsSatisfied();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/RecipientListUseOriginalMessageEndpointExceptionIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RecipientListUseOriginalMessageEndpointExceptionIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/RecipientListUseOriginalMessageEndpointExceptionIssueTest.java
index 3c43b8f..742617f 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/RecipientListUseOriginalMessageEndpointExceptionIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/RecipientListUseOriginalMessageEndpointExceptionIssueTest.java
@@ -58,7 +58,7 @@ public class RecipientListUseOriginalMessageEndpointExceptionIssueTest extends
C
                     .to("file://target/outbox")
                     .to("mock:error");
 
-                from("file://target/inbox")
+                from("file://target/inbox?initialDelay=0&delay=10")
                     .transform(constant("B"))
                     .setHeader("path", constant("mock:throwException"))
                     // must enable share uow to let the onException use

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
index 5cc6883..c4acfa6 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
@@ -134,7 +134,7 @@ public class RetryRouteScopedUntilRecipientListIssueTest extends ContextTestSupp
     public void testRetryUntilRecipientListFailOnly() throws Exception {
         invoked.set(0);
 
-        NotifyBuilder event = event().whenDone(1).create();
+        NotifyBuilder event = event().whenDone(2).create();
 
         getMockEndpoint("mock:result").expectedMessageCount(0);
         getMockEndpoint("mock:foo").expectedMessageCount(0);
@@ -155,7 +155,7 @@ public class RetryRouteScopedUntilRecipientListIssueTest extends ContextTestSupp
     public void testRetryUntilRecipientListFailAndOk() throws Exception {
         invoked.set(0);
 
-        NotifyBuilder event = event().whenDone(1).create();
+        NotifyBuilder event = event().whenDone(3).create();
 
         getMockEndpoint("mock:result").expectedMessageCount(0);
         getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);
@@ -176,7 +176,7 @@ public class RetryRouteScopedUntilRecipientListIssueTest extends ContextTestSupp
     public void testRetryUntilRecipientListOkAndFail() throws Exception {
         invoked.set(0);
 
-        NotifyBuilder event = event().whenFailed(1).create();
+        NotifyBuilder event = event().whenDone(3).create();
 
         getMockEndpoint("mock:result").expectedMessageCount(0);
         getMockEndpoint("mock:foo").expectedMessageCount(1);
@@ -212,7 +212,7 @@ public class RetryRouteScopedUntilRecipientListIssueTest extends ContextTestSupp
     public void testRetryUntilRecipientFailAndNotFail() throws Exception {
         invoked.set(0);
 
-        NotifyBuilder event = event().whenDone(1).create();
+        NotifyBuilder event = event().whenDone(3).create();
 
         getMockEndpoint("mock:result").expectedMessageCount(0);
         getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);
@@ -233,7 +233,7 @@ public class RetryRouteScopedUntilRecipientListIssueTest extends ContextTestSupp
     public void testRetryUntilRecipientNotFailAndFail() throws Exception {
         invoked.set(0);
 
-        NotifyBuilder event = event().whenDone(1).create();
+        NotifyBuilder event = event().whenDone(3).create();
 
         getMockEndpoint("mock:result").expectedMessageCount(0);
         getMockEndpoint("mock:foo").expectedMinimumMessageCount(0);
@@ -250,7 +250,6 @@ public class RetryRouteScopedUntilRecipientListIssueTest extends ContextTestSupp
         assertEquals(3, invoked.get());
     }
 
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
index 894b4b7..a17b7088 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
@@ -28,7 +28,6 @@ public class RetryRouteScopedUntilRecipientListParallelIssueTest extends
RetryRo
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-
                 from("seda:start")
                     .onException(Exception.class).redeliveryDelay(0).retryWhile(method("myRetryBean")).end()
                     .recipientList(header("recipientListHeader")).parallelProcessing()

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/RetryWhilePredicateExpressionIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RetryWhilePredicateExpressionIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/RetryWhilePredicateExpressionIssueTest.java
index 996aa06..1b1fc29 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/RetryWhilePredicateExpressionIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/RetryWhilePredicateExpressionIssueTest.java
@@ -43,6 +43,7 @@ public class RetryWhilePredicateExpressionIssueTest extends ContextTestSupport
{
             public void configure() throws Exception {
                 onException(IllegalArgumentException.class)
                     .handled(true)
+                    .redeliveryDelay(0)
                     .retryWhile(new Predicate() {
                         @Override
                         public boolean matches(Exchange exchange) {

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/RetryWhileSimpleExpressionIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/RetryWhileSimpleExpressionIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/RetryWhileSimpleExpressionIssueTest.java
index fdf5ec3..8ebdd73 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/RetryWhileSimpleExpressionIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/RetryWhileSimpleExpressionIssueTest.java
@@ -43,6 +43,7 @@ public class RetryWhileSimpleExpressionIssueTest extends ContextTestSupport
{
             public void configure() throws Exception {
                 onException(IllegalArgumentException.class)
                     .retryWhile(simple("${body.areWeCool} == 'no'"))
+                    .redeliveryDelay(0)
                     .handled(true)
                     .to("mock:error");
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/SplitPropertiesFileIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/SplitPropertiesFileIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/SplitPropertiesFileIssueTest.java
index 0d23b2f..dab351e 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/SplitPropertiesFileIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/SplitPropertiesFileIssueTest.java
@@ -59,7 +59,7 @@ public class SplitPropertiesFileIssueTest extends ContextTestSupport {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("file://target/file/splitprop?move=done")
+                from("file://target/file/splitprop?initialDelay=0&delay=10&move=done")
                     .convertBodyTo(String.class)
                     .split(new MyCustomExpression())
                     .recipientList(header("myCustomDestination"));

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/ThreadsRejectedExecutionWithDeadLetterTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/ThreadsRejectedExecutionWithDeadLetterTest.java
b/camel-core/src/test/java/org/apache/camel/issues/ThreadsRejectedExecutionWithDeadLetterTest.java
index 9f32e5f..b4e395a 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/ThreadsRejectedExecutionWithDeadLetterTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/ThreadsRejectedExecutionWithDeadLetterTest.java
@@ -16,7 +16,12 @@
  */
 package org.apache.camel.issues;
 
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.ThreadPoolRejectedPolicy;
 import org.apache.camel.builder.RouteBuilder;
 
@@ -31,6 +36,8 @@ public class ThreadsRejectedExecutionWithDeadLetterTest extends ContextTestSuppo
     }
 
     public void testThreadsRejectedExecution() throws Exception {
+        final CountDownLatch latch = new CountDownLatch(3);
+
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
@@ -42,7 +49,12 @@ public class ThreadsRejectedExecutionWithDeadLetterTest extends ContextTestSuppo
                         .maxQueueSize(1)            // 1 queued task
                         //(Test fails whatever the chosen policy below)
                         .rejectedPolicy(ThreadPoolRejectedPolicy.Abort)
-                        .delay(1000)
+                        .process(new Processor() {
+                            @Override
+                            public void process(Exchange exchange) throws Exception {
+                                latch.await(5, TimeUnit.SECONDS);
+                            }
+                        })
                         .to("log:after")
                         .to("mock:result");
             }
@@ -56,14 +68,20 @@ public class ThreadsRejectedExecutionWithDeadLetterTest extends ContextTestSuppo
         template.sendBody("seda:start", "Hi World");    // will be queued
         template.sendBody("seda:start", "Bye World");   // will be rejected
 
+        latch.countDown();
+        latch.countDown();
+        latch.countDown();
+
         assertMockEndpointsSatisfied();
     }
 
     public void testThreadsRejectedExecutionWithRedelivery() throws Exception {
+        final CountDownLatch latch = new CountDownLatch(3);
+
         context.addRoutes(new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("seda:start").errorHandler(deadLetterChannel("mock:failed").maximumRedeliveries(5))
+                from("seda:start").errorHandler(deadLetterChannel("mock:failed").maximumRedeliveries(10).redeliveryDelay(10))
                         .to("log:before")
                         // will use our custom pool
                         .threads()
@@ -71,7 +89,12 @@ public class ThreadsRejectedExecutionWithDeadLetterTest extends ContextTestSuppo
                         .maxQueueSize(1)            // 1 queued task
                         //(Test fails whatever the chosen policy below)
                         .rejectedPolicy(ThreadPoolRejectedPolicy.Abort)
-                        .delay(1000)
+                        .process(new Processor() {
+                            @Override
+                            public void process(Exchange exchange) throws Exception {
+                                latch.await(5, TimeUnit.SECONDS);
+                            }
+                        })
                         .to("log:after")
                         .to("mock:result");
             }
@@ -85,6 +108,10 @@ public class ThreadsRejectedExecutionWithDeadLetterTest extends ContextTestSuppo
         template.sendBody("seda:start", "Hi World");    // will be queued
         template.sendBody("seda:start", "Bye World");   // will be rejected and queued on
redelivery later
 
+        latch.countDown();
+        latch.countDown();
+        latch.countDown();
+
         assertMockEndpointsSatisfied();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/TimerAndErrorHandlerIssueTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/TimerAndErrorHandlerIssueTest.java
b/camel-core/src/test/java/org/apache/camel/issues/TimerAndErrorHandlerIssueTest.java
index 77decf6..929fe09 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/TimerAndErrorHandlerIssueTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/TimerAndErrorHandlerIssueTest.java
@@ -45,7 +45,8 @@ public class TimerAndErrorHandlerIssueTest extends ContextTestSupport {
                 String executionTriggerUri = "timer:executionTimer"
                         + "?fixedRate=true"
                         + "&daemon=true"
-                        + "&period=500";
+                        + "&delay=0"
+                        + "&period=10";
 
                 from(executionTriggerUri).to("mock:result");
             }

http://git-wip-us.apache.org/repos/asf/camel/blob/0fb523a9/camel-core/src/test/java/org/apache/camel/issues/XPathSplitStreamTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/issues/XPathSplitStreamTest.java b/camel-core/src/test/java/org/apache/camel/issues/XPathSplitStreamTest.java
index 042f2f5..c69618d 100644
--- a/camel-core/src/test/java/org/apache/camel/issues/XPathSplitStreamTest.java
+++ b/camel-core/src/test/java/org/apache/camel/issues/XPathSplitStreamTest.java
@@ -60,7 +60,7 @@ public class XPathSplitStreamTest extends ContextTestSupport {
             @Override
             public void configure() throws Exception {
                 // START SNIPPET: e1
-                from("file://target/file/xpathsplit")
+                from("file://target/file/xpathsplit?initialDelay=0&delay=10")
                     // set documentType to org.xml.sax.InputSource then Camel will use SAX
to split the file
                     .split(xpath("/persons/person").documentType(InputSource.class)).streaming()
                     .to("mock:splitted");


Mime
View raw message