Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A4D24EFD4 for ; Tue, 29 Jan 2013 08:00:09 +0000 (UTC) Received: (qmail 98701 invoked by uid 500); 29 Jan 2013 08:00:09 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 98602 invoked by uid 500); 29 Jan 2013 08:00:08 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 98572 invoked by uid 99); 29 Jan 2013 08:00:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jan 2013 08:00:07 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jan 2013 08:00:05 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5385423889DE; Tue, 29 Jan 2013 07:59:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@camel.apache.org From: bvahdat@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130129075946.5385423889DE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; } }