You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/08/14 04:15:28 UTC
[2/2] git commit: Fix for CAMEL-7694 Eliminated race condition which
caused intermittent test failures
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/c8c74742
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/c8c74742
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/c8c74742
Branch: refs/heads/camel-2.12.x
Commit: c8c7474291fa6265f804c37ed21e20ca64d19198
Parents: c049000
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Wed Aug 13 19:42:00 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Thu Aug 14 10:14:57 2014 +0800
----------------------------------------------------------------------
.../restlet/example/RestletGroovyIssueTest.java | 23 ++++++++++++++------
1 file changed, 16 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/c8c74742/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<String> 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();