camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [3/5] git commit: Using JmsTestHelper for JMS tests.
Date Fri, 08 Nov 2013 10:32:26 GMT
Using JmsTestHelper for JMS tests.


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

Branch: refs/heads/camel-2.12.x
Commit: 00668eec6393ad24fbfb16134c425416a27d6816
Parents: c6da2c9
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Fri Nov 8 11:29:31 2013 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Fri Nov 8 11:33:06 2013 +0100

----------------------------------------------------------------------
 .../apache/camel/itest/CamelJmsTestHelper.java  |  99 ++++++++++++++++
 .../camel/itest/async/HttpAsyncDslTest.java     |   9 +-
 .../camel/itest/issues/RemoveEndpointsTest.java |  10 +-
 .../camel/itest/jms/DynamicRouteTest.java       |   9 +-
 .../apache/camel/itest/jms/JmsHttpJmsTest.java  |   9 +-
 .../camel/itest/jms/JmsHttpPostIssueTest.java   |   9 +-
 .../itest/jms/JmsHttpPostIssueWithMockTest.java |   9 +-
 .../camel/itest/jms/JmsIntegrationTest.java     |  11 +-
 .../org/apache/camel/itest/jms/JmsJaxbTest.java |  10 +-
 .../camel/itest/jms/JmsJettyAsyncTest.java      |  10 +-
 .../camel/itest/jms/JmsPerformanceTest.java     |  16 +--
 .../camel/itest/jms/JmsPollEnrichTest.java      |  10 +-
 .../camel/itest/jms/JmsResequencerTest.java     |  19 ++--
 .../camel/itest/jms/JmsValidatorTest.java       |  10 +-
 .../org/apache/camel/itest/jms/StopWatch.java   | 113 -------------------
 .../itest/netty/NettyAsyncRequestReplyTest.java |  10 +-
 .../camel/itest/shiro/ShiroOverJmsTest.java     |  10 +-
 17 files changed, 218 insertions(+), 155 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/CamelJmsTestHelper.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/CamelJmsTestHelper.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/CamelJmsTestHelper.java
new file mode 100644
index 0000000..1bb277c
--- /dev/null
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/CamelJmsTestHelper.java
@@ -0,0 +1,99 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.itest;
+
+import java.io.File;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.jms.ConnectionFactory;
+
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.pool.PooledConnectionFactory;
+import org.apache.camel.util.FileUtil;
+
+/**
+ * A helper for unit testing with Apache ActiveMQ as embedded JMS broker.
+ *
+ * @version
+ */
+public final class CamelJmsTestHelper {
+
+    private static AtomicInteger counter = new AtomicInteger(0);
+
+    private CamelJmsTestHelper() {
+    }
+
+    public static ConnectionFactory createConnectionFactory() {
+        return createConnectionFactory(null);
+    }
+
+    public static ConnectionFactory createConnectionFactory(String options) {
+        // using a unique broker name improves testing when running the entire test suite
in the same JVM
+        int id = counter.incrementAndGet();
+        String url = "vm://test-broker-" + id + "?broker.persistent=false&broker.useJmx=false";
+        if (options != null) {
+            url = url + "&" + options;
+        }
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+        // optimize AMQ to be as fast as possible so unit testing is quicker
+        connectionFactory.setCopyMessageOnSend(false);
+        connectionFactory.setOptimizeAcknowledge(true);
+        connectionFactory.setOptimizedMessageDispatch(true);
+
+        // When using asyncSend, producers will not be guaranteed to send in the order we

+        // have in the tests (which may be confusing for queues) so we need this set to false.
+        // Another way of guaranteeing order is to use persistent messages or transactions.
+        connectionFactory.setUseAsyncSend(false);
+
+        connectionFactory.setAlwaysSessionAsync(false);
+        // use a pooled connection factory
+        PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
+        pooled.setMaxConnections(8);
+        return pooled;
+    }
+
+    public static ConnectionFactory createPersistentConnectionFactory() {
+        return createPersistentConnectionFactory(null);
+    }
+
+    public static ConnectionFactory createPersistentConnectionFactory(String options) {
+        // using a unique broker name improves testing when running the entire test suite
in the same JVM
+        int id = counter.incrementAndGet();
+
+        // use an unique data directory in target
+        String dir = "target/activemq-data-" + id;
+
+        // remove dir so its empty on startup
+        FileUtil.removeDir(new File(dir));
+
+        String url = "vm://test-broker-" + id + "?broker.persistent=true&broker.useJmx=false&broker.dataDirectory="
+ dir;
+        if (options != null) {
+            url = url + "&" + options;
+        }
+        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(url);
+        // optimize AMQ to be as fast as possible so unit testing is quicker
+        connectionFactory.setCopyMessageOnSend(false);
+        connectionFactory.setOptimizeAcknowledge(true);
+        connectionFactory.setOptimizedMessageDispatch(true);
+        connectionFactory.setUseAsyncSend(true);
+        connectionFactory.setAlwaysSessionAsync(false);
+
+        // use a pooled connection factory
+        PooledConnectionFactory pooled = new PooledConnectionFactory(connectionFactory);
+        pooled.setMaxConnections(8);
+        return pooled;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncDslTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncDslTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncDslTest.java
index 2e218db..5e8b380 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncDslTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/async/HttpAsyncDslTest.java
@@ -16,18 +16,22 @@
  */
 package org.apache.camel.itest.async;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.impl.StringDataFormat;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Before;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version 
  */
@@ -87,7 +91,8 @@ public class HttpAsyncDslTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
         answer.bind("jms", amq);
         return answer;

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RemoveEndpointsTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RemoveEndpointsTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RemoveEndpointsTest.java
index e6f33b1..563951a 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RemoveEndpointsTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/issues/RemoveEndpointsTest.java
@@ -18,16 +18,20 @@ package org.apache.camel.itest.issues;
 
 import java.util.Collection;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.Endpoint;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version 
  */
@@ -52,8 +56,10 @@ public class RemoveEndpointsTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/DynamicRouteTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/DynamicRouteTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/DynamicRouteTest.java
index 6955fef..66e84eb 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/DynamicRouteTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/DynamicRouteTest.java
@@ -16,16 +16,20 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.Exchange;
 import org.apache.camel.Header;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 public class DynamicRouteTest extends CamelTestSupport {
     
     @Test
@@ -68,7 +72,8 @@ public class DynamicRouteTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
         answer.bind("jms", amq);
         answer.bind("myBean", new MyBean());

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpJmsTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpJmsTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpJmsTest.java
index 607fb8c..1d85020 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpJmsTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpJmsTest.java
@@ -16,19 +16,23 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * Based on user forum.
  *
@@ -90,7 +94,8 @@ public class JmsHttpJmsTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
         answer.bind("jms", amq);
         return answer;

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueTest.java
index 2431a98..170c3e5 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueTest.java
@@ -16,13 +16,15 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.NotifyBuilder;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
@@ -31,6 +33,7 @@ import org.junit.Test;
 import static org.apache.camel.Exchange.CONTENT_TYPE;
 import static org.apache.camel.Exchange.HTTP_METHOD;
 import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
 
 /**
  * Based on user forum.
@@ -89,8 +92,10 @@ public class JmsHttpPostIssueTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueWithMockTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueWithMockTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueWithMockTest.java
index 7438a44..93d8e64 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueWithMockTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsHttpPostIssueWithMockTest.java
@@ -16,12 +16,14 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
@@ -30,6 +32,7 @@ import org.junit.Test;
 import static org.apache.camel.Exchange.CONTENT_TYPE;
 import static org.apache.camel.Exchange.HTTP_METHOD;
 import static org.apache.camel.Exchange.HTTP_RESPONSE_CODE;
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
 
 /**
  * Based on user forum.
@@ -93,8 +96,10 @@ public class JmsHttpPostIssueWithMockTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
index 5168b63..efcca5c 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsIntegrationTest.java
@@ -21,13 +21,15 @@ import java.util.concurrent.TimeUnit;
 import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version 
  */
@@ -59,8 +61,11 @@ public class JmsIntegrationTest extends CamelTestSupport {
         answer.bind("myBean", myBean);
 
         // add ActiveMQ with embedded broker
-        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
-        answer.bind("jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
+        amq.setCamelContext(context);
+
+        answer.bind("jms", amq);
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJaxbTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJaxbTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJaxbTest.java
index 59d6624..517fdfb 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJaxbTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJaxbTest.java
@@ -16,17 +16,21 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.converter.jaxb.JaxbDataFormat;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version 
  */
@@ -81,8 +85,10 @@ public class JmsJaxbTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJettyAsyncTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJettyAsyncTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJettyAsyncTest.java
index 9bc4ca5..34ec086 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJettyAsyncTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsJettyAsyncTest.java
@@ -17,15 +17,19 @@
 package org.apache.camel.itest.jms;
 
 import java.util.concurrent.TimeUnit;
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  *
  */
@@ -70,8 +74,10 @@ public class JmsJettyAsyncTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("activemq", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPerformanceTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPerformanceTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPerformanceTest.java
index 747e6ae..7c7365a 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPerformanceTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPerformanceTest.java
@@ -18,18 +18,19 @@ package org.apache.camel.itest.jms;
 
 import java.util.ArrayList;
 import java.util.List;
-
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.ActiveMQConnectionFactory;
-import org.apache.activemq.pool.PooledConnectionFactory;
 import org.apache.camel.Header;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version
  */
@@ -96,11 +97,12 @@ public class JmsPerformanceTest extends CamelTestSupport {
 
         // add AMQ client and make use of connection pooling we depend on because of the
(large) number
         // of the JMS messages we do produce
-        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://broker");
-        PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(connectionFactory);
-        pooledConnectionFactory.setMaxConnections(10);
-        answer.bind("activemq", JmsComponent.jmsComponentAutoAcknowledge(pooledConnectionFactory));
+        // add ActiveMQ with embedded broker
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
+        amq.setCamelContext(context);
 
+        answer.bind("activemq", amq);
         return answer;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPollEnrichTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPollEnrichTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPollEnrichTest.java
index eefaf74..b2888ef 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPollEnrichTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsPollEnrichTest.java
@@ -16,15 +16,19 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version 
  */
@@ -58,8 +62,10 @@ public class JmsPollEnrichTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker which must be persistent
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=true&broker.useJmx=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createPersistentConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsResequencerTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsResequencerTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsResequencerTest.java
index 4b086c5..b06809c 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsResequencerTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsResequencerTest.java
@@ -17,11 +17,9 @@
 package org.apache.camel.itest.jms;
 
 import java.util.List;
-
 import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.ActiveMQConnectionFactory;
 import org.apache.camel.Body;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
@@ -29,6 +27,7 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.model.config.BatchResequencerConfig;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
@@ -37,6 +36,8 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 public class JmsResequencerTest extends CamelTestSupport  {
     
     private static final Logger LOG = LoggerFactory.getLogger(JmsResequencerTest.class);
@@ -158,19 +159,21 @@ public class JmsResequencerTest extends CamelTestSupport  {
             LOG.info(name + " finished");
         }
     }
-    
+
     @Override
     protected Context createJndiContext() throws Exception {
         JndiContext answer = new JndiContext();
-        ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=true");
-        JmsComponent component = JmsComponent.jmsComponent(connectionFactory);
-        component.setConcurrentConsumers(4);
-        answer.bind("activemq", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
+
+        // add ActiveMQ with embedded broker
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
+        amq.setCamelContext(context);
+        answer.bind("activemq", amq);
+
         answer.bind("myBean1", b1);
         answer.bind("myBean2", b2);
         answer.bind("myBean3", b3);
         return answer;
     }
 
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsValidatorTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsValidatorTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsValidatorTest.java
index 2e7fdbd..ae746cb 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsValidatorTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/JmsValidatorTest.java
@@ -16,15 +16,19 @@
  */
 package org.apache.camel.itest.jms;
 
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.ValidationException;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * @version 
  */
@@ -59,8 +63,10 @@ public class JmsValidatorTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/StopWatch.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/StopWatch.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/StopWatch.java
deleted file mode 100644
index b828b29..0000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/jms/StopWatch.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.itest.jms;
-
-import java.text.NumberFormat;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @version 
- */
-public class StopWatch {
-    private static final Logger LOG = LoggerFactory.getLogger(StopWatch.class);
-    
-    private final String id;
-    private int loopCount;
-    private int totalLoops;
-    private long groupElapsed;
-    private long totalElapsed;
-    private long startTime;
-    private long minTime = Long.MAX_VALUE;
-    private long maxTime = Long.MIN_VALUE;
-    private int logFrequency = 1000;
-    private NumberFormat numberFormat = NumberFormat.getNumberInstance();
-
-    public StopWatch(String id) {
-        this.id = id;
-    }
-
-    public void start() {
-        startTime = System.currentTimeMillis();
-    }
-
-    public void stop() {
-        long elapsedTime = System.currentTimeMillis() - startTime;
-        groupElapsed += elapsedTime;
-        totalElapsed += elapsedTime;
-        loopCount++;
-        totalLoops++;
-
-        if (elapsedTime > maxTime) {
-            maxTime = elapsedTime;
-        }
-        if (elapsedTime < minTime) {
-            minTime = elapsedTime;
-        }
-        if (logFrequency > 0 && loopCount % logFrequency == 0) {
-            LOG.info(toString());
-            reset();
-        }
-    }
-
-    protected void reset() {
-        loopCount = 0;
-        groupElapsed = 0;
-        minTime = Long.MAX_VALUE;
-        maxTime = Long.MIN_VALUE;
-    }
-
-    @Override
-    public String toString() {
-        double average = totalElapsed;
-        average /= totalLoops;
-        return id + " count: " + loopCount + ", elapsed (ms): " + groupElapsed + ", min (ms):
" + minTime + ", max (ms): " + maxTime + ", average (ms): " + formatNumber(average);
-    }
-
-    public int getLogFrequency() {
-        return logFrequency;
-    }
-
-    public void setLogFrequency(int logFrequency) {
-        this.logFrequency = logFrequency;
-    }
-
-    public int getLoopCount() {
-        return loopCount;
-    }
-
-    public long getMaxTime() {
-        return maxTime;
-    }
-
-    public long getMinTime() {
-        return minTime;
-    }
-
-    public long getStartTime() {
-        return startTime;
-    }
-
-    public long getGroupElapsed() {
-        return groupElapsed;
-    }
-
-    protected String formatNumber(double time) {
-        return numberFormat.format(time);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/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..6898263 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
@@ -25,15 +25,19 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 /**
  * Doing request/reply over Netty with async processing.
  */
@@ -104,8 +108,10 @@ public class NettyAsyncRequestReplyTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("activemq", amq);
         return answer;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00668eec/tests/camel-itest/src/test/java/org/apache/camel/itest/shiro/ShiroOverJmsTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/shiro/ShiroOverJmsTest.java
b/tests/camel-itest/src/test/java/org/apache/camel/itest/shiro/ShiroOverJmsTest.java
index 116e6d7..48a5008 100644
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/shiro/ShiroOverJmsTest.java
+++ b/tests/camel-itest/src/test/java/org/apache/camel/itest/shiro/ShiroOverJmsTest.java
@@ -18,16 +18,20 @@ package org.apache.camel.itest.shiro;
 
 import java.util.HashMap;
 import java.util.Map;
+import javax.jms.ConnectionFactory;
 import javax.naming.Context;
 
-import org.apache.activemq.camel.component.ActiveMQComponent;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.jms.JmsComponent;
 import org.apache.camel.component.shiro.security.ShiroSecurityConstants;
 import org.apache.camel.component.shiro.security.ShiroSecurityPolicy;
+import org.apache.camel.itest.CamelJmsTestHelper;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.camel.util.jndi.JndiContext;
 import org.junit.Test;
 
+import static org.apache.camel.component.jms.JmsComponent.jmsComponentAutoAcknowledge;
+
 public class ShiroOverJmsTest extends CamelTestSupport {
 
     private byte[] passPhrase = {
@@ -55,8 +59,10 @@ public class ShiroOverJmsTest extends CamelTestSupport {
         JndiContext answer = new JndiContext();
 
         // add ActiveMQ with embedded broker
-        ActiveMQComponent amq = ActiveMQComponent.activeMQComponent("vm://localhost?broker.persistent=false");
+        ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
+        JmsComponent amq = jmsComponentAutoAcknowledge(connectionFactory);
         amq.setCamelContext(context);
+
         answer.bind("jms", amq);
         return answer;
     }


Mime
View raw message