camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bvah...@apache.org
Subject git commit: Polished some XyzConcurrentTests a bit.
Date Wed, 16 Oct 2013 09:18:12 GMT
Updated Branches:
  refs/heads/master b8c6b0697 -> ce0091e22


Polished some XyzConcurrentTests a bit.

Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ce0091e2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ce0091e2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ce0091e2

Branch: refs/heads/master
Commit: ce0091e22d9cbd818368a6a7329d56f1a793966a
Parents: b8c6b06
Author: Babak Vahdat <bvahdat@apache.org>
Authored: Wed Oct 16 11:17:58 2013 +0200
Committer: Babak Vahdat <bvahdat@apache.org>
Committed: Wed Oct 16 11:17:58 2013 +0200

----------------------------------------------------------------------
 .../camel/component/http4/HttpConcurrentTest.java    | 14 ++++++++------
 .../component/jdbc/JdbcProducerConcurrenctTest.java  | 14 ++++++++------
 .../component/jetty/HttpProducerConcurrentTest.java  |  8 +++++---
 .../JettyHttpProducerConcurrentTest.java             |  8 +++++---
 .../camel/component/jpa/AbstractJpaMethodTest.java   |  2 +-
 .../jpa/JpaWithNamedQueryAndParametersTest.java      |  4 ----
 .../mina/MinaProducerAnotherConcurrentTest.java      |  8 +++++---
 .../component/mina/MinaProducerConcurrentTest.java   |  8 +++++---
 .../mina2/Mina2ProducerAnotherConcurrentTest.java    | 13 +++++++------
 .../component/mina2/Mina2ProducerConcurrentTest.java | 15 ++++++++-------
 .../netty/http/NettyHttpProducerConcurrentTest.java  |  8 +++++---
 .../camel/component/netty/NettyConcurrentTest.java   |  8 +++++---
 .../camel/component/netty4/NettyConcurrentTest.java  |  8 +++++---
 .../restlet/RestletProducerConcurrentTest.java       | 13 +++++++------
 .../camel/component/restlet/RestletTestSupport.java  |  2 +-
 .../component/sql/SqlProducerConcurrentTest.java     | 15 ++++++++-------
 .../itest/netty/NettyAsyncRequestReplyTest.java      |  8 +++++---
 17 files changed, 88 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpConcurrentTest.java
b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpConcurrentTest.java
index 11b950e..478cab9 100644
--- a/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpConcurrentTest.java
+++ b/components/camel-http4/src/test/java/org/apache/camel/component/http4/HttpConcurrentTest.java
@@ -17,11 +17,11 @@
 package org.apache.camel.component.http4;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -71,11 +71,13 @@ public class HttpConcurrentTest extends BaseHttpTest {
 
     private void doSendMessages(int files, int poolSize) throws Exception {
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<Object>> responses = new ConcurrentHashMap<Integer,
Future<Object>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
-            Future<Object> out = executor.submit(new Callable<Object>() {
-                public Object call() throws Exception {
+            Future<String> out = executor.submit(new Callable<String>() {
+                public String call() throws Exception {
                     return template.requestBody("http4://" + getHostName() + ":" + getPort(),
null, String.class);
                 }
             });
@@ -85,8 +87,8 @@ public class HttpConcurrentTest extends BaseHttpTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
-        for (Future<Object> future : responses.values()) {
+        Set<String> unique = new HashSet<String>();
+        for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerConcurrenctTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerConcurrenctTest.java
b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerConcurrenctTest.java
index d4052e4..76f1ce8 100644
--- a/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerConcurrenctTest.java
+++ b/components/camel-jdbc/src/test/java/org/apache/camel/component/jdbc/JdbcProducerConcurrenctTest.java
@@ -16,10 +16,10 @@
  */
 package org.apache.camel.component.jdbc;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -49,13 +49,15 @@ public class JdbcProducerConcurrenctTest extends AbstractJdbcTestSupport
{
         mock.expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<Object>> responses = new ConcurrentHashMap<Integer,
Future<Object>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<List<?>>> responses = new HashMap<Integer,
Future<List<?>>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
-            Future<Object> out = executor.submit(new Callable<Object>() {
-                public Object call() throws Exception {
+            Future<List<?>> out = executor.submit(new Callable<List<?>>()
{
+                public List<?> call() throws Exception {
                     int id = (index % 2) + 1;
-                    return template.requestBody("direct:start", "select * from customer where
id = 'cust" + id + "'");
+                    return template.requestBody("direct:start", "select * from customer where
id = 'cust" + id + "'", List.class);
                 }
             });
             responses.put(index, out);
@@ -65,7 +67,7 @@ public class JdbcProducerConcurrenctTest extends AbstractJdbcTestSupport
{
         assertEquals(files, responses.size());
 
         for (int i = 0; i < files; i++) {
-            List rows = (List) responses.get(i).get();
+            List<?> rows = responses.get(i).get();
             Map columns = (Map) rows.get(0);
             if (i % 2 == 0) {
                 assertEquals("jstrachan", columns.get("NAME"));

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerConcurrentTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerConcurrentTest.java
index ab20da4..a9361eb 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerConcurrentTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/HttpProducerConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -50,7 +50,9 @@ public class HttpProducerConcurrentTest extends BaseJettyTest {
         getMockEndpoint("mock:result").assertNoDuplicates(body());
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -66,7 +68,7 @@ public class HttpProducerConcurrentTest extends BaseJettyTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java
index 05c844e..7289539 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/jettyproducer/JettyHttpProducerConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.jetty.jettyproducer;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -67,7 +67,9 @@ public class JettyHttpProducerConcurrentTest extends BaseJettyTest {
         getMockEndpoint("mock:result").assertNoDuplicates(body());
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -83,7 +85,7 @@ public class JettyHttpProducerConcurrentTest extends BaseJettyTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodTest.java
b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodTest.java
index 1f6b939..6f8db08 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/AbstractJpaMethodTest.java
@@ -84,7 +84,7 @@ public abstract class AbstractJpaMethodTest extends CamelTestSupport {
         List<Customer> customers = new ArrayList<Customer>();
         customers.add(createDefaultCustomer());
         customers.add(createDefaultCustomer());
-        List returnedCustomers = template.requestBody(endpoint, customers, List.class);
+        List<?> returnedCustomers = template.requestBody(endpoint, customers, List.class);
         
         assertEquals(2, returnedCustomers.size());
         

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
index 1af0632..8494cc6 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/component/jpa/JpaWithNamedQueryAndParametersTest.java
@@ -22,7 +22,6 @@ import java.util.Map;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 import javax.persistence.EntityManager;
-import javax.persistence.PersistenceException;
 
 import org.apache.camel.Consumer;
 import org.apache.camel.Endpoint;
@@ -39,13 +38,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.orm.jpa.JpaCallback;
 import org.springframework.transaction.TransactionStatus;
 import org.springframework.transaction.support.TransactionCallback;
 import org.springframework.transaction.support.TransactionTemplate;
 
-import static org.apache.camel.util.ServiceHelper.startServices;
-
 public class JpaWithNamedQueryAndParametersTest extends Assert {
     
     protected static final Logger LOG = LoggerFactory.getLogger(JpaWithNamedQueryAndParametersTest.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
index 3dd46e8..5f29c8c 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerAnotherConcurrentTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.camel.component.mina;
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -53,7 +53,9 @@ public class MinaProducerAnotherConcurrentTest extends BaseMinaTest {
         getMockEndpoint("mock:result").expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -68,7 +70,7 @@ public class MinaProducerAnotherConcurrentTest extends BaseMinaTest {
         assertEquals(files, responses.size());
 
         for (int i = 0; i < files; i++) {
-            Object out = responses.get(i).get();
+            String out = responses.get(i).get();
             assertEquals("Bye " + i, out);
         }
         executor.shutdownNow();

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
index 73e9863..9b9d7fc 100644
--- a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
+++ b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.mina;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -49,7 +49,9 @@ public class MinaProducerConcurrentTest extends BaseMinaTest {
         getMockEndpoint("mock:result").expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -64,7 +66,7 @@ public class MinaProducerConcurrentTest extends BaseMinaTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerAnotherConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerAnotherConcurrentTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerAnotherConcurrentTest.java
index ca9e9a6..c2f2f7e 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerAnotherConcurrentTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerAnotherConcurrentTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.camel.component.mina2;
 
+import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -53,12 +53,13 @@ public class Mina2ProducerAnotherConcurrentTest extends BaseMina2Test
{
         getMockEndpoint("mock:result").expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<Object>> responses = new ConcurrentHashMap<Integer,
Future<Object>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
-            Future<Object> out = executor.submit(new Callable<Object>() {
-
-                public Object call() throws Exception {
+            Future<String> out = executor.submit(new Callable<String>() {
+                public String call() throws Exception {
                     return template.requestBody("direct:start", index, String.class);
                 }
             });
@@ -69,7 +70,7 @@ public class Mina2ProducerAnotherConcurrentTest extends BaseMina2Test {
         assertEquals(files, responses.size());
 
         for (int i = 0; i < files; i++) {
-            Object out = responses.get(i).get();
+            String out = responses.get(i).get();
             assertEquals("Bye " + i, out);
         }
         executor.shutdownNow();

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerConcurrentTest.java
b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerConcurrentTest.java
index 96430da..7c0910f 100644
--- a/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerConcurrentTest.java
+++ b/components/camel-mina2/src/test/java/org/apache/camel/component/mina2/Mina2ProducerConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.mina2;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -49,12 +49,13 @@ public class Mina2ProducerConcurrentTest extends BaseMina2Test {
         getMockEndpoint("mock:result").expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<Object>> responses = new ConcurrentHashMap<Integer,
Future<Object>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
-            Future<Object> out = executor.submit(new Callable<Object>() {
-
-                public Object call() throws Exception {
+            Future<String> out = executor.submit(new Callable<String>() {
+                public String call() throws Exception {
                     return template.requestBody(String.format("mina2:tcp://localhost:%1$s?sync=true",
getPort()), index, String.class);
                 }
             });
@@ -65,8 +66,8 @@ public class Mina2ProducerConcurrentTest extends BaseMina2Test {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
-        for (Future<Object> future : responses.values()) {
+        Set<String> unique = new HashSet<String>();
+        for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpProducerConcurrentTest.java
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpProducerConcurrentTest.java
index 7f54ddf..2e4b032 100644
--- a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpProducerConcurrentTest.java
+++ b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettyHttpProducerConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.netty.http;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -45,7 +45,9 @@ public class NettyHttpProducerConcurrentTest extends BaseNettyTest {
         getMockEndpoint("mock:result").assertNoDuplicates(body());
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -61,7 +63,7 @@ public class NettyHttpProducerConcurrentTest extends BaseNettyTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTest.java
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTest.java
index b05a74d..7cce6db 100644
--- a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTest.java
+++ b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.netty;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -57,7 +57,9 @@ public class NettyConcurrentTest extends BaseNettyTest {
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(files).create();
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -76,7 +78,7 @@ public class NettyConcurrentTest extends BaseNettyTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConcurrentTest.java
b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConcurrentTest.java
index f0d2c7d..123f557 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConcurrentTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyConcurrentTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.component.netty4;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -57,7 +57,9 @@ public class NettyConcurrentTest extends BaseNettyTest {
         NotifyBuilder notify = new NotifyBuilder(context).whenDone(files).create();
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -76,7 +78,7 @@ public class NettyConcurrentTest extends BaseNettyTest {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
index f9ae6ba..8539a96 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletProducerConcurrentTest.java
@@ -21,7 +21,6 @@ import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -52,11 +51,13 @@ public class RestletProducerConcurrentTest extends RestletTestSupport
{
         getMockEndpoint("mock:result").expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<?>> responses = new ConcurrentHashMap<Integer,
Future<?>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
-            Future<?> out = executor.submit(new Callable<Object>() {
-                public Object call() throws Exception {
+            Future<String> out = executor.submit(new Callable<String>() {
+                public String call() throws Exception {
                     Map<String, Object> headers = new HashMap<String, Object>();
                     headers.put("username", "davsclaus");
                     headers.put("id", index);
@@ -72,8 +73,8 @@ public class RestletProducerConcurrentTest extends RestletTestSupport {
         assertEquals(files, responses.size());
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
-        for (Future<?> future : responses.values()) {
+        Set<String> unique = new HashSet<String>();
+        for (Future<String> future : responses.values()) {
             unique.add(future.get());
         }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
index 1975cb0..f1ddf06 100644
--- a/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
+++ b/components/camel-restlet/src/test/java/org/apache/camel/component/restlet/RestletTestSupport.java
@@ -34,7 +34,7 @@ import org.junit.BeforeClass;
  * @version 
  */
 public abstract class RestletTestSupport extends CamelTestSupport {
-    public static int portNum;
+    protected static int portNum;
     
     @BeforeClass
     public static void initializePortNum() {

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
index cf4d7f1..f0c9428 100755
--- a/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
+++ b/components/camel-sql/src/test/java/org/apache/camel/component/sql/SqlProducerConcurrentTest.java
@@ -16,10 +16,10 @@
  */
 package org.apache.camel.component.sql;
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -58,14 +58,15 @@ public class SqlProducerConcurrentTest extends CamelTestSupport {
         mockEndpoint.expectedMessageCount(files);
 
         ExecutorService executor = Executors.newFixedThreadPool(poolSize);
-        Map<Integer, Future<?>> responses = new ConcurrentHashMap<Integer,
Future<?>>();
-
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<List<?>>> responses = new HashMap<Integer,
Future<List<?>>>();
         for (int i = 0; i < files; i++) {
             final int index = i;
-            Future<?> out = executor.submit(new Callable<Object>() {
-                public Object call() throws Exception {
+            Future<List<?>> out = executor.submit(new Callable<List<?>>()
{
+                public List<?> call() throws Exception {
                     int id = (index % 3) + 1;
-                    return template.requestBody("direct:simple", "" + id);
+                    return template.requestBody("direct:simple", "" + id, List.class);
                 }
             });
             responses.put(index, out);
@@ -75,7 +76,7 @@ public class SqlProducerConcurrentTest extends CamelTestSupport {
         assertEquals(files, responses.size());
 
         for (int i = 0; i < files; i++) {
-            List<?> rows = assertIsInstanceOf(List.class, responses.get(i).get());
+            List<?> rows = responses.get(i).get();
             Map<?, ?> columns = assertIsInstanceOf(Map.class, rows.get(0));
             if (i % 3 == 0) {
                 assertEquals("Camel", columns.get("PROJECT"));

http://git-wip-us.apache.org/repos/asf/camel/blob/ce0091e2/tests/camel-itest/src/test/java/org/apache/camel/itest/netty/NettyAsyncRequestReplyTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/netty/NettyAsyncRequestReplyTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/netty/NettyAsyncRequestReplyTest.java
index 4ccad78..ee3bd60 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/netty/NettyAsyncRequestReplyTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/netty/NettyAsyncRequestReplyTest.java
@@ -16,11 +16,11 @@
  */
 package org.apache.camel.itest.netty;
 
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.Callable;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -55,7 +55,9 @@ public class NettyAsyncRequestReplyTest extends CamelTestSupport {
         int size = 1000;
 
         ExecutorService executor = Executors.newFixedThreadPool(20);
-        Map<Integer, Future<String>> responses = new ConcurrentHashMap<Integer,
Future<String>>();
+        // we access the responses Map below only inside the main thread,
+        // so no need for a thread-safe Map implementation
+        Map<Integer, Future<String>> responses = new HashMap<Integer, Future<String>>();
         for (int i = 0; i < size; i++) {
             final int index = i;
             Future<String> out = executor.submit(new Callable<String>() {
@@ -70,7 +72,7 @@ public class NettyAsyncRequestReplyTest extends CamelTestSupport {
         }
 
         // get all responses
-        Set<Object> unique = new HashSet<Object>();
+        Set<String> unique = new HashSet<String>();
         for (Future<String> future : responses.values()) {
             String reply = future.get(120, TimeUnit.SECONDS);
             assertNotNull("Should get a reply", reply);


Mime
View raw message