camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject svn commit: r1439771 - in /camel/trunk/camel-core/src/test/java/org/apache/camel/processor: ./ aggregator/
Date Tue, 29 Jan 2013 07:59:46 GMT
Author: bvahdat
Date: Tue Jan 29 07:59:45 2013
New Revision: 1439771

URL: http://svn.apache.org/viewvc?rev=1439771&view=rev
Log:
Fixed some broken tests similar to AggregateTimeoutTest which failed on the CI-Server.

Modified:
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java?rev=1439771&r1=1439770&r2=1439771&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java
Tue Jan 29 07:59:45 2013
@@ -20,6 +20,7 @@ import javax.naming.Context;
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
+import org.apache.camel.RecipientList;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.aggregate.TimeoutAwareAggregationStrategy;
@@ -30,6 +31,11 @@ import org.apache.camel.util.jndi.JndiCo
  */
 public class BeanRecipientListTimeoutTest extends ContextTestSupport {
 
+    private volatile Exchange receivedExchange;
+    private volatile int receivedIndex;
+    private volatile int receivedTotal;
+    private volatile long receivedTimeout;
+
     public void testBeanRecipientListParallelTimeout() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         // A will timeout so we only get B and/or C
@@ -38,6 +44,11 @@ public class BeanRecipientListTimeoutTes
         template.sendBody("direct:start", "Hello");
 
         assertMockEndpointsSatisfied();
+
+        assertNotNull(receivedExchange);
+        assertEquals(0, receivedIndex);
+        assertEquals(3, receivedTotal);
+        assertEquals(1000, receivedTimeout);
     }
 
     @Override
@@ -64,19 +75,24 @@ public class BeanRecipientListTimeoutTes
 
     public static class MyBean {
 
-        @org.apache.camel.RecipientList(strategyRef = "myStrategy", parallelProcessing =
true, timeout = 1000)
+        @RecipientList(strategyRef = "myStrategy", parallelProcessing = true, timeout = 1000)
         public String[] route(String body) {
             return new String[] {"direct:a", "direct:b", "direct:c"};
         }
     }
 
-    private static class MyAggregationStrategy implements TimeoutAwareAggregationStrategy
{
+    private class MyAggregationStrategy implements TimeoutAwareAggregationStrategy {
 
         public void timeout(Exchange oldExchange, int index, int total, long timeout) {
-            assertEquals(1000, timeout);
-            assertEquals(3, total);
-            assertEquals(0, index);
-            assertNotNull(oldExchange);
+            // we can't assert on the expected values here as the contract of this method
doesn't
+            // allow to throw any Throwable (including AssertionFailedError) so that we assert
+            // about the expected values directly inside the test method itself. other than
that
+            // asserting inside a thread other than the main thread dosen't make much sense
as
+            // junit would not realize the failed assertion!
+            receivedExchange = oldExchange;
+            receivedIndex = index;
+            receivedTotal = total;
+            receivedTimeout = timeout;
         }
 
         public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java?rev=1439771&r1=1439770&r2=1439771&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java
Tue Jan 29 07:59:45 2013
@@ -27,6 +27,11 @@ import org.apache.camel.processor.aggreg
  */
 public class MulticastParallelAllTimeoutAwareTest extends ContextTestSupport {
 
+    private volatile Exchange receivedExchange;
+    private volatile int receivedIndex;
+    private volatile int receivedTotal;
+    private volatile long receivedTimeout;
+
     public void testMulticastParallelAllTimeoutAware() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         // ABC will timeout so we only get our canned response
@@ -35,6 +40,11 @@ public class MulticastParallelAllTimeout
         template.sendBody("direct:start", "Hello");
 
         assertMockEndpointsSatisfied();
+
+        assertNotNull(receivedExchange);
+        assertEquals(0, receivedIndex);
+        assertEquals(3, receivedTotal);
+        assertEquals(500, receivedTimeout);
     }
 
     @Override
@@ -58,13 +68,19 @@ public class MulticastParallelAllTimeout
         };
     }
 
-    private static class MyAggregationStrategy implements TimeoutAwareAggregationStrategy
{
+    private class MyAggregationStrategy implements TimeoutAwareAggregationStrategy {
 
         public void timeout(Exchange oldExchange, int index, int total, long timeout) {
-            assertEquals(500, timeout);
-            assertEquals(3, total);
-            assertEquals(0, index);
-            assertNotNull(oldExchange);
+            // we can't assert on the expected values here as the contract of this method
doesn't
+            // allow to throw any Throwable (including AssertionFailedError) so that we assert
+            // about the expected values directly inside the test method itself. other than
that
+            // asserting inside a thread other than the main thread dosen't make much sense
as
+            // junit would not realize the failed assertion!
+            receivedExchange = oldExchange;
+            receivedIndex = index;
+            receivedTotal = total;
+            receivedTimeout = timeout;
+
             oldExchange.getIn().setBody("AllTimeout");
         }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java?rev=1439771&r1=1439770&r2=1439771&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java
Tue Jan 29 07:59:45 2013
@@ -27,6 +27,11 @@ import org.apache.camel.processor.aggreg
  */
 public class MulticastParallelTimeoutAwareTest extends ContextTestSupport {
 
+    private volatile Exchange receivedExchange;
+    private volatile int receivedIndex;
+    private volatile int receivedTotal;
+    private volatile long receivedTimeout;
+
     public void testMulticastParallelTimeoutAware() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         // A will timeout so we only get B and/or C
@@ -35,6 +40,11 @@ public class MulticastParallelTimeoutAwa
         template.sendBody("direct:start", "Hello");
 
         assertMockEndpointsSatisfied();
+
+        assertNotNull(receivedExchange);
+        assertEquals(0, receivedIndex);
+        assertEquals(3, receivedTotal);
+        assertEquals(1000, receivedTimeout);
     }
 
     @Override
@@ -58,13 +68,18 @@ public class MulticastParallelTimeoutAwa
         };
     }
 
-    private static class MyAggregationStrategy implements TimeoutAwareAggregationStrategy
{
+    private class MyAggregationStrategy implements TimeoutAwareAggregationStrategy {
 
         public void timeout(Exchange oldExchange, int index, int total, long timeout) {
-            assertEquals(1000, timeout);
-            assertEquals(3, total);
-            assertEquals(0, index);
-            assertNotNull(oldExchange);
+            // we can't assert on the expected values here as the contract of this method
doesn't
+            // allow to throw any Throwable (including AssertionFailedError) so that we assert
+            // about the expected values directly inside the test method itself. other than
that
+            // asserting inside a thread other than the main thread dosen't make much sense
as
+            // junit would not realize the failed assertion!
+            receivedExchange = oldExchange;
+            receivedIndex = index;
+            receivedTotal = total;
+            receivedTimeout = timeout;
         }
 
         public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java?rev=1439771&r1=1439770&r2=1439771&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java
Tue Jan 29 07:59:45 2013
@@ -27,6 +27,11 @@ import org.apache.camel.processor.aggreg
  */
 public class SplitParallelTimeoutTest extends ContextTestSupport {
 
+    private volatile Exchange receivedExchange;
+    private volatile int receivedIndex;
+    private volatile int receivedTotal;
+    private volatile long receivedTimeout;
+
     public void testSplitParallelTimeout() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:result");
         // A will timeout so we only get B and/or C
@@ -35,6 +40,11 @@ public class SplitParallelTimeoutTest ex
         template.sendBody("direct:start", "A,B,C");
 
         assertMockEndpointsSatisfied();
+
+        assertNotNull(receivedExchange);
+        assertEquals(0, receivedIndex);
+        assertEquals(3, receivedTotal);
+        assertEquals(1000, receivedTimeout);
     }
 
     @Override
@@ -62,13 +72,18 @@ public class SplitParallelTimeoutTest ex
         };
     }
 
-    private static class MyAggregationStrategy implements TimeoutAwareAggregationStrategy
{
+    private class MyAggregationStrategy implements TimeoutAwareAggregationStrategy {
 
         public void timeout(Exchange oldExchange, int index, int total, long timeout) {
-            assertEquals(1000, timeout);
-            assertEquals(3, total);
-            assertEquals(0, index);
-            assertNotNull(oldExchange);
+            // we can't assert on the expected values here as the contract of this method
doesn't
+            // allow to throw any Throwable (including AssertionFailedError) so that we assert
+            // about the expected values directly inside the test method itself. other than
that
+            // asserting inside a thread other than the main thread dosen't make much sense
as
+            // junit would not realize the failed assertion!
+            receivedExchange = oldExchange;
+            receivedIndex = index;
+            receivedTotal = total;
+            receivedTimeout = timeout;
         }
 
         public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java?rev=1439771&r1=1439770&r2=1439771&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java
Tue Jan 29 07:59:45 2013
@@ -51,13 +51,13 @@ public class AggregateTimeoutTest extend
         assertEquals(1, INVOKED.get());
 
         assertNotNull(receivedExchange);
-        assertEquals("A+B", receivedExchange.getIn().getBody());
+        assertEquals("AB", receivedExchange.getIn().getBody());
         assertEquals(-1, receivedIndex);
         assertEquals(-1, receivedTotal);
         assertEquals(2000, receivedTimeout);
 
         mock.reset();
-        mock.expectedBodiesReceived("A+B+C");
+        mock.expectedBodiesReceived("ABC");
 
         // now send 3 exchanges which shouldn't trigger the timeout anymore
         template.sendBodyAndHeader("direct:start", "A", "id", 123);
@@ -93,8 +93,10 @@ public class AggregateTimeoutTest extend
             INVOKED.incrementAndGet();
 
             // we can't assert on the expected values here as the contract of this method
doesn't
-            // allow to throw any Throwable here (including AssertionFailedError) so that
we assert
-            // about the expected values directly inside the test method itself
+            // allow to throw any Throwable (including AssertionFailedError) so that we assert
+            // about the expected values directly inside the test method itself. other than
that
+            // asserting inside a thread other than the main thread dosen't make much sense
as
+            // junit would not realize the failed assertion!
             receivedExchange = oldExchange;
             receivedIndex = index;
             receivedTotal = total;
@@ -107,7 +109,7 @@ public class AggregateTimeoutTest extend
             }
 
             String body = oldExchange.getIn().getBody(String.class);
-            oldExchange.getIn().setBody(body + "+" + newExchange.getIn().getBody(String.class));
+            oldExchange.getIn().setBody(body + newExchange.getIn().getBody(String.class));
             return oldExchange;
         }
     }



Mime
View raw message