You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/11/20 08:19:39 UTC
[2/4] camel git commit: Fixed test
Fixed test
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/35268214
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/35268214
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/35268214
Branch: refs/heads/master
Commit: 35268214813be9b2bdf3990c122917bd8fdb51cb
Parents: 229517a
Author: Claus Ibsen <da...@apache.org>
Authored: Fri Nov 20 08:19:03 2015 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Fri Nov 20 08:19:03 2015 +0100
----------------------------------------------------------------------
...uestReplyTempQueueMultipleConsumersTest.java | 39 ++++++++++++--------
1 file changed, 23 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/35268214/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyTempQueueMultipleConsumersTest.java
----------------------------------------------------------------------
diff --git a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyTempQueueMultipleConsumersTest.java b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyTempQueueMultipleConsumersTest.java
index decf610..a293de3 100644
--- a/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyTempQueueMultipleConsumersTest.java
+++ b/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsRequestReplyTempQueueMultipleConsumersTest.java
@@ -20,7 +20,6 @@ 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.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -42,44 +41,52 @@ public class JmsRequestReplyTempQueueMultipleConsumersTest extends CamelTestSupp
private final Map<String, AtomicInteger> msgsPerThread = new ConcurrentHashMap<String, AtomicInteger>();
private PooledConnectionFactory connectionFactory;
-
+ private ExecutorService executorService;
+
@Test
public void testMultipleConsumingThreads() throws Exception {
- doSendMessages(1000, 5);
- assertTrue("Expected multiple consuming threads, but only found: " + msgsPerThread.keySet().size(),
+ executorService = context.getExecutorServiceManager().newFixedThreadPool(this, "test", 5);
+
+ doSendMessages(1000);
+
+ assertTrue("Expected multiple consuming threads, but only found: " + msgsPerThread.keySet().size(),
msgsPerThread.keySet().size() > 1);
+
+ context.getExecutorServiceManager().shutdown(executorService);
}
@Test
public void testTempQueueRefreshed() throws Exception {
- doSendMessages(500, 5);
- connectionFactory.clear();
- doSendMessages(100, 5);
+ executorService = context.getExecutorServiceManager().newFixedThreadPool(this, "test", 5);
+
+ doSendMessages(100);
connectionFactory.clear();
- doSendMessages(100, 5);
+ Thread.sleep(1000);
+ doSendMessages(100);
connectionFactory.clear();
- doSendMessages(100, 5);
+ Thread.sleep(1000);
+ doSendMessages(100);
+
+ context.getExecutorServiceManager().shutdown(executorService);
}
- private void doSendMessages(int files, int poolSize) throws Exception {
+ private void doSendMessages(int files) throws Exception {
resetMocks();
MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
mockEndpoint.expectedMessageCount(files);
mockEndpoint.expectsNoDuplicates(body());
- ExecutorService executor = Executors.newFixedThreadPool(poolSize);
for (int i = 0; i < files; i++) {
final int index = i;
- executor.submit(new Callable<Object>() {
+ executorService.submit(new Callable<Object>() {
public Object call() throws Exception {
- template.sendBody("seda:start", "Message " + index);
+ template.sendBody("direct:start", "Message " + index);
return null;
}
});
}
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
- executor.shutdownNow();
}
protected CamelContext createCamelContext() throws Exception {
@@ -96,7 +103,7 @@ public class JmsRequestReplyTempQueueMultipleConsumersTest extends CamelTestSupp
return new RouteBuilder() {
@Override
public void configure() throws Exception {
- from("seda:start").inOut("jms:queue:foo?replyToConcurrentConsumers=10&replyToMaxConcurrentConsumers=20&recoveryInterval=10").process(new Processor() {
+ from("direct:start").inOut("jms:queue:foo?replyToConcurrentConsumers=10&replyToMaxConcurrentConsumers=20&recoveryInterval=10").process(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
String threadName = Thread.currentThread().getName();
@@ -111,7 +118,7 @@ public class JmsRequestReplyTempQueueMultipleConsumersTest extends CamelTestSupp
}
}).to("mock:result");
- from("jms:queue:foo?concurrentConsumers=20&recoveryInterval=10").setBody(simple("Reply >>> ${body}"));
+ from("jms:queue:foo?concurrentConsumers=10&recoveryInterval=10").setBody(simple("Reply >>> ${body}"));
}
};
}