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 B6FE8119E4 for ; Thu, 14 Aug 2014 02:13:36 +0000 (UTC) Received: (qmail 74530 invoked by uid 500); 14 Aug 2014 02:13:36 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 74467 invoked by uid 500); 14 Aug 2014 02:13:36 -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 74458 invoked by uid 99); 14 Aug 2014 02:13:36 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Aug 2014 02:13:36 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 654ED928E20; Thu, 14 Aug 2014 02:13:36 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Message-Id: <09b5f7441ac949c79b29aaea0445d7d6@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: Fix for CAMEL-7694 Eliminated race condition which caused intermittent test failures Date: Thu, 14 Aug 2014 02:13:36 +0000 (UTC) Repository: camel Updated Branches: refs/heads/master 343dd7733 -> b2c3b31bb Fix for CAMEL-7694 Eliminated race condition which caused intermittent test failures Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b2c3b31b Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b2c3b31b Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b2c3b31b Branch: refs/heads/master Commit: b2c3b31bba3191aa193cbb672b5d353fd2818ed2 Parents: 343dd77 Author: Kevin Earls Authored: Wed Aug 13 19:42:00 2014 +0200 Committer: Kevin Earls Committed: Wed Aug 13 19:42:34 2014 +0200 ---------------------------------------------------------------------- .../restlet/example/RestletGroovyIssueTest.java | 23 ++++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/b2c3b31b/tests/camel-itest/src/test/java/org/apache/camel/itest/restlet/example/RestletGroovyIssueTest.java ---------------------------------------------------------------------- diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/restlet/example/RestletGroovyIssueTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/restlet/example/RestletGroovyIssueTest.java index 2803ac9..68f68f4 100644 --- a/tests/camel-itest/src/test/java/org/apache/camel/itest/restlet/example/RestletGroovyIssueTest.java +++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/restlet/example/RestletGroovyIssueTest.java @@ -16,39 +16,48 @@ */ package org.apache.camel.itest.restlet.example; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.AvailablePortFinder; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @version */ public class RestletGroovyIssueTest extends CamelTestSupport { - + protected static final Logger LOG = LoggerFactory.getLogger(RestletGroovyIssueTest.class); private long port = AvailablePortFinder.getNextAvailable(16000); private ExecutorService executorService = Executors.newFixedThreadPool(5); @Test public void testRestletGroovy() throws Exception { - getMockEndpoint("mock:input").expectedMessageCount(10); - getMockEndpoint("mock:output").expectedBodiesReceivedInAnyOrder("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"); - - for (int i = 0; i < 10; i++) { - final Integer num = i; + String[] bodies = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}; + List expectedBodies = Arrays.asList(bodies); + final CountDownLatch responsesToReceive = new CountDownLatch(expectedBodies.size()); + getMockEndpoint("mock:input").expectedMessageCount(expectedBodies.size()); + getMockEndpoint("mock:output").expectedBodiesReceivedInAnyOrder(expectedBodies); + + for (final String s : expectedBodies) { executorService.submit(new Runnable() { @Override public void run() { - String s = "" + num; Object response = template.requestBody("restlet:http://localhost:" + port + "/foo/" + s + "?restletMethod=GET", ""); assertEquals(s, response); + responsesToReceive.countDown(); }; }); } + responsesToReceive.await(5, TimeUnit.SECONDS); assertMockEndpointsSatisfied(); executorService.shutdownNow();