You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by bv...@apache.org on 2013/10/11 19:20:40 UTC
git commit: Fixed JpaProducerConcurrentTest failing from time to time
on the CI-Server. Also polished it a bit.
Updated Branches:
refs/heads/master 4bae319a9 -> 924ebada9
Fixed JpaProducerConcurrentTest failing from time to time on the CI-Server. Also polished it a bit.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/924ebada
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/924ebada
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/924ebada
Branch: refs/heads/master
Commit: 924ebada9ea261d7a09abe11689b2b2b269927b8
Parents: 4bae319
Author: bvahdat <bv...@apache.org>
Authored: Fri Oct 11 19:20:24 2013 +0200
Committer: bvahdat <bv...@apache.org>
Committed: Fri Oct 11 19:20:24 2013 +0200
----------------------------------------------------------------------
.../jpa/JpaProducerConcurrentTest.java | 21 +++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/924ebada/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
index 8e753aa..ac278be 100644
--- a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
+++ b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerConcurrentTest.java
@@ -16,9 +16,9 @@
*/
package org.apache.camel.processor.jpa;
+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;
@@ -50,13 +50,14 @@ public class JpaProducerConcurrentTest extends AbstractJpaTest {
getMockEndpoint("mock:result").assertNoDuplicates(body());
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<SendEmail>> responses = new HashMap<Integer, Future<SendEmail>>();
for (int i = 0; i < files; i++) {
final int index = i;
- Future<Object> out = executor.submit(new Callable<Object>() {
- public Object call() throws Exception {
- template.sendBody("direct:start", new SendEmail("user" + index + "@somewhere.org"));
- return null;
+ Future<SendEmail> out = executor.submit(new Callable<SendEmail>() {
+ public SendEmail call() throws Exception {
+ return template.requestBody("direct:start", new SendEmail("user" + index + "@somewhere.org"), SendEmail.class);
}
});
responses.put(index, out);
@@ -67,8 +68,10 @@ public class JpaProducerConcurrentTest extends AbstractJpaTest {
assertEquals(files, responses.size());
// get them so they are complete
- for (Future<Object> future : responses.values()) {
- future.get();
+ for (Future<SendEmail> future : responses.values()) {
+ SendEmail sendMail = future.get();
+ assertNotNull(sendMail);
+ log.info("Got the managed entity {}", sendMail);
}
// assert in the database
@@ -80,7 +83,7 @@ public class JpaProducerConcurrentTest extends AbstractJpaTest {
protected RouteBuilder createRouteBuilder() {
return new SpringRouteBuilder() {
public void configure() {
- from("direct:start").to("jpa://" + SendEmail.class.getName()).to("mock:result");
+ from("direct:start").to("jpa://" + SendEmail.class.getName() + "?usePersist=true").to("mock:result");
}
};
}