Author: bvahdat Date: Tue Jan 29 08:03:30 2013 New Revision: 1439774 URL: http://svn.apache.org/viewvc?rev=1439774&view=rev Log: Merged revisions 1439773 via svnmerge from https://svn.apache.org/repos/asf/camel/branches/camel-2.10.x
................ r1439773 | bvahdat | 2013-01-29 09:01:54 +0100 (Di, 29 Jan 2013) | 9 lines Merged revisions 1439771 via svnmerge from https://svn.apache.org/repos/asf/camel/trunk ........ r1439771 | bvahdat | 2013-01-29 08:59:45 +0100 (Di, 29 Jan 2013) | 1 line Fixed some broken tests similar to AggregateTimeoutTest which failed on the CI-Server. ........ ................ Modified: camel/branches/camel-2.9.x/ (props changed) camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Merged /camel/trunk:r1439771 Merged /camel/branches/camel-2.10.x:r1439773 Propchange: camel/branches/camel-2.9.x/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java?rev=1439774&r1=1439773&r2=1439774&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/BeanRecipientListTimeoutTest.java Tue Jan 29 08:03:30 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/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java?rev=1439774&r1=1439773&r2=1439774&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelAllTimeoutAwareTest.java Tue Jan 29 08:03:30 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/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java?rev=1439774&r1=1439773&r2=1439774&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/MulticastParallelTimeoutAwareTest.java Tue Jan 29 08:03:30 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/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java?rev=1439774&r1=1439773&r2=1439774&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/SplitParallelTimeoutTest.java Tue Jan 29 08:03:30 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/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java?rev=1439774&r1=1439773&r2=1439774&view=diff ============================================================================== --- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java (original) +++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateTimeoutTest.java Tue Jan 29 08:03:30 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; } }
