Repository: camel
Updated Branches:
  refs/heads/master 259648fc3 -> ed240a0f1


CAMEL-8255: Fixed tests


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

Branch: refs/heads/master
Commit: ed240a0f16f0236b5b43611f15e59a455bfe1e18
Parents: 259648f
Author: Claus Ibsen <davscl...@apache.org>
Authored: Fri Feb 6 14:14:59 2015 +0100
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Fri Feb 6 14:14:59 2015 +0100

----------------------------------------------------------------------
 .../aws/sqs/SqsConcurrentConsumerTest.java      | 23 +++++---------------
 .../aws/swf/CamelSWFWorkflowConsumerTest.java   |  3 ++-
 2 files changed, 7 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ed240a0f/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConcurrentConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConcurrentConsumerTest.java
 
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConcurrentConsumerTest.java
index 9de5627..ca2c7b3 100644
--- 
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConcurrentConsumerTest.java
+++ 
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsConcurrentConsumerTest.java
@@ -29,12 +29,6 @@ import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
-
-
-/**
- * Created by ceposta
- * <a href="http://christianposta.com/blog>http://christianposta.com/blog</a>.
- */
 public class SqsConcurrentConsumerTest extends CamelTestSupport {
     private static final int NUM_CONCURRENT = 10;
     private static final int NUM_MESSAGES = 100;
@@ -44,19 +38,14 @@ public class SqsConcurrentConsumerTest extends 
CamelTestSupport {
     @Test
     public void consumeMessagesFromQueue() throws Exception {
         NotifyBuilder notifier = new 
NotifyBuilder(context).whenCompleted(NUM_MESSAGES).create();
-        assertTrue("We didn't process "
-                + NUM_MESSAGES
-                + " messages as we expected!", notifier.matches(5, 
TimeUnit.SECONDS));
-
+        assertTrue("We didn't process " + NUM_MESSAGES + " messages as we 
expected!", notifier.matches(5, TimeUnit.SECONDS));
 
-
-        // simple test to make sure all N concurrent consumers were used in 
the test
-        if (threadNumbers.size() != NUM_CONCURRENT) {
-            fail(String.format("We were expecting to have %d numbers of 
concurrent consumers, but only found %d",
+        // simple test to make sure that concurrent consumers were used in the 
test
+        // usually we use all threads evenly but sometimes threads are reused 
so just test that 50%+ was used
+        if (threadNumbers.size() < (NUM_CONCURRENT / 2)) {
+            fail(String.format("We were expecting to have about half of %d 
numbers of concurrent consumers, but only found %d",
                     NUM_CONCURRENT, threadNumbers.size()));
         }
-
-
     }
 
     @Override
@@ -79,7 +68,6 @@ public class SqsConcurrentConsumerTest extends 
CamelTestSupport {
         }
     }
 
-
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
@@ -96,5 +84,4 @@ public class SqsConcurrentConsumerTest extends 
CamelTestSupport {
         };
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/ed240a0f/components/camel-aws/src/test/java/org/apache/camel/component/aws/swf/CamelSWFWorkflowConsumerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/swf/CamelSWFWorkflowConsumerTest.java
 
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/swf/CamelSWFWorkflowConsumerTest.java
index 2159fb8..01f2197 100644
--- 
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/swf/CamelSWFWorkflowConsumerTest.java
+++ 
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/swf/CamelSWFWorkflowConsumerTest.java
@@ -47,7 +47,8 @@ public class CamelSWFWorkflowConsumerTest extends 
CamelSWFTestSupport {
 
     @Test
     public void receivesDecisionTask() throws Exception {
-        result.expectedMessageCount(1);
+        // use minimum as depending on the polling we may do more than 1 in 
the test before we assert and stop
+        result.expectedMinimumMessageCount(1);
         result.expectedMessagesMatches(new Predicate() {
             public boolean matches(Exchange exchange) {
                 return exchange.getIn().getHeader(SWFConstants.ACTION) != null;

Reply via email to