camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [6/6] camel git commit: CAMEL-11147: camel-jms should include JMS 2.0 functionality.
Date Mon, 18 Sep 2017 12:42:36 GMT
CAMEL-11147: camel-jms should include JMS 2.0 functionality.


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

Branch: refs/heads/master
Commit: 67339a8ec22b93dda0192868b75cf550b9a8333e
Parents: 987f41d
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Mon Sep 18 14:38:14 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Mon Sep 18 14:38:49 2017 +0200

----------------------------------------------------------------------
 tests/camel-itest-jms2/pom.xml                  | 104 +++++++++++
 .../camel/itest/jms2/BaseJms2TestSupport.java   | 177 +++++++++++++++++++
 .../camel/itest/jms2/Jms1TopicDurableTest.java  |  59 +++++++
 .../itest/jms2/Jms2TopicDurableSharedTest.java  |  62 +++++++
 .../camel/itest/jms2/Jms2TopicDurableTest.java  |  60 +++++++
 .../camel/itest/jms2/Jms2TopicSharedTest.java   |  62 +++++++
 .../src/test/resources/log4j2.properties        |  32 ++++
 tests/pom.xml                                   |   1 +
 8 files changed, 557 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/pom.xml b/tests/camel-itest-jms2/pom.xml
new file mode 100644
index 0000000..dc1aaf9
--- /dev/null
+++ b/tests/camel-itest-jms2/pom.xml
@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>tests</artifactId>
+    <version>2.20.0-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-itest-jms2</artifactId>
+  <name>Camel :: Integration Tests :: JMS 2.0 API</name>
+  <description>Tests for camel-jms with JMS 2.0 API Broker</description>
+
+  <dependencies>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-jms</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- ActiveMQ Artemis JMS 2.0 API Broker -->
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>artemis-server</artifactId>
+      <version>${activemq-artemis-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>artemis-jms-server</artifactId>
+      <version>${activemq-artemis-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>artemis-jms-client</artifactId>
+      <version>${activemq-artemis-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>artemis-amqp-protocol</artifactId>
+      <version>${activemq-artemis-version}</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+  </dependencies>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/BaseJms2TestSupport.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/BaseJms2TestSupport.java
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/BaseJms2TestSupport.java
new file mode 100644
index 0000000..92edada
--- /dev/null
+++ b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/BaseJms2TestSupport.java
@@ -0,0 +1,177 @@
+/**
+ * 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.jms2;
+
+import java.util.Arrays;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.Topic;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.api.core.TransportConfiguration;
+import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.artemis.core.config.Configuration;
+import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
+import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
+import org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration;
+import org.apache.activemq.artemis.jms.server.config.JMSConfiguration;
+import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration;
+import org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl;
+import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.jms.JmsComponent;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.test.AvailablePortFinder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+
+/**
+ * A support class that builds up and tears down an ActiveMQ Artemis instance to be used
+ * for unit testing.
+ */
+public class BaseJms2TestSupport extends CamelTestSupport {
+
+    @Produce
+    protected ProducerTemplate template;
+    protected String brokerUri;
+    protected int port;
+    protected EmbeddedJMS broker;
+    protected Connection connection;
+    protected Session session;
+
+    /**
+     * Set up the Broker
+     *
+     * @see CamelTestSupport#doPreSetup()
+     *
+     * @throws Exception
+     */
+    @Override
+    protected void doPreSetup() throws Exception {
+        broker = new EmbeddedJMS();
+        deleteDirectory("target/data");
+        port = AvailablePortFinder.getNextAvailable(33333);
+        brokerUri = "tcp://localhost:" + port;
+        configureBroker(this.broker);
+        startBroker();
+    }
+
+    protected void configureBroker(EmbeddedJMS broker) throws Exception {
+        Configuration configuration = new ConfigurationImpl()
+            .setPersistenceEnabled(false)
+            .setJournalDirectory("target/data/journal")
+            .setSecurityEnabled(false)
+            .addAcceptorConfiguration("connector", brokerUri + "?protocols=CORE,AMQP")
+            .addAcceptorConfiguration("vm", "vm://123")
+            .addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
+
+        JMSConfiguration jmsConfig = new JMSConfigurationImpl();
+
+        ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(
+            Arrays.asList("connector")).setBindings("cf");
+        jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
+
+        JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1");
+        jmsConfig.getQueueConfigurations().add(queueConfig);
+
+        JMSQueueConfiguration topicConfig = new JMSQueueConfigurationImpl().setName("foo").setDurable(true).setBindings("topic/foo");
+        jmsConfig.getQueueConfigurations().add(topicConfig);
+
+        broker.setConfiguration(configuration).setJmsConfiguration(jmsConfig);
+    }
+
+    private void startBroker() throws Exception {
+        broker.start();
+        log.info("Started Embedded JMS Server");
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        DefaultCamelContext dcc = (DefaultCamelContext)context;
+        while (!dcc.isStopped()) {
+            log.info("Waiting on the Camel Context to stop");
+        }
+        log.info("Closing JMS Session");
+        if (getSession() != null) {
+            getSession().close();
+            setSession(null);
+        }
+        log.info("Closing JMS Connection");
+        if (connection != null) {
+            connection.stop();
+            connection = null;
+        }
+        log.info("Stopping the ActiveMQ Broker");
+        if (broker != null) {
+            broker.stop();
+            broker = null;
+        }
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext camelContext = super.createCamelContext();
+        ConnectionFactory connectionFactory = getConnectionFactory();
+        connection = connectionFactory.createConnection();
+        connection.start();
+        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        JmsComponent component = new JmsComponent();
+        component.setConnectionFactory(connectionFactory);
+        component.setClientId(getClientId());
+        camelContext.addComponent("jms", component);
+        return camelContext;
+    }
+
+    protected String getClientId() {
+        return null;
+    }
+
+    protected ConnectionFactory getConnectionFactory() throws Exception {
+        return ActiveMQJMSClient.createConnectionFactory(brokerUri, "test");
+    }
+
+    public QueueQueryResult getQueueQueryResult(String queueQuery) throws Exception {
+        return broker.getActiveMQServer().queueQuery(new SimpleString(queueQuery));
+    }
+
+    public void setSession(Session session) {
+        this.session = session;
+    }
+
+    public Session getSession() {
+        return session;
+    }
+
+    public MessageConsumer createQueueConsumer(String destination) throws Exception {
+        Queue queue = session.createQueue(destination);
+        return session.createConsumer(queue);
+    }
+
+    public MessageConsumer createTopicConsumer(String destination, String messageSelector)
throws Exception {
+        Topic topic = session.createTopic(destination);
+        return session.createConsumer(topic, messageSelector);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms1TopicDurableTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms1TopicDurableTest.java
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms1TopicDurableTest.java
new file mode 100644
index 0000000..af6d893
--- /dev/null
+++ b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms1TopicDurableTest.java
@@ -0,0 +1,59 @@
+/**
+ * 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.jms2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class Jms1TopicDurableTest extends BaseJms2TestSupport {
+
+    // Jms1TopicDurableTest and Jms2TopicDurableTest are similar
+    // as the test using JMS 1.1 style durable topic which does not
+    // use any of the JMS 2.0 APIs but it works on a JMS 2.0 broker as well
+
+    @Test
+    public void testJms11DurableTopic() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        MockEndpoint mock2 = getMockEndpoint("mock:result2");
+        mock2.expectedBodiesReceived("Hello World");
+
+        // wait a bit and send the message
+        Thread.sleep(500);
+
+        template.sendBody("jms:topic:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jms:topic:foo?clientId=123&durableSubscriptionName=bar")
+                    .to("mock:result");
+
+                from("jms:topic:foo?clientId=456&durableSubscriptionName=bar")
+                    .to("mock:result2");
+            }
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableSharedTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableSharedTest.java
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableSharedTest.java
new file mode 100644
index 0000000..d854493
--- /dev/null
+++ b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableSharedTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.jms2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class Jms2TopicDurableSharedTest extends BaseJms2TestSupport {
+
+    private static final String TEST_DESTINATION_NAME = "jms:topic:in.only.topic.consumer.test";
+
+    @Test
+    public void testDurableSharedTopic() throws Exception {
+        final String expectedBody = "Hello World";
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello World");
+
+        MockEndpoint mock2 = getMockEndpoint("mock:result2");
+        mock2.expectedMessageCount(1);
+        mock2.expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", expectedBody);
+
+        mock.assertIsSatisfied();
+        mock2.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .to(TEST_DESTINATION_NAME);
+
+                from(TEST_DESTINATION_NAME)
+                    .to("log:test.log.1?showBody=true", "mock:result");
+
+                from(TEST_DESTINATION_NAME + "?subscriptionName=sharedTest&subscriptionShared=true&subscriptionDurable=true")
+                    .to("log:test.log.2?showBody=true", "mock:result2");
+
+                from(TEST_DESTINATION_NAME + "?subscriptionName=sharedTest&subscriptionShared=true&subscriptionDurable=true")
+                    .to("log:test.log.3?showBody=true", "mock:result2");
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableTest.java
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableTest.java
new file mode 100644
index 0000000..e082dca
--- /dev/null
+++ b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicDurableTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.jms2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class Jms2TopicDurableTest extends BaseJms2TestSupport {
+
+    // Jms1TopicDurableTest and Jms2TopicDurableTest are similar
+    // as the test using JMS 1.1 style durable topic which does not
+    // use any of the JMS 2.0 APIs but it works on a JMS 2.0 broker as well
+
+    @Test
+    public void testDurableTopic() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedBodiesReceived("Hello World");
+
+        MockEndpoint mock2 = getMockEndpoint("mock:result2");
+        mock2.expectedBodiesReceived("Hello World");
+
+        // wait a bit and send the message
+        Thread.sleep(500);
+
+        template.sendBody("jms:topic:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("jms:topic:foo?clientId=123&durableSubscriptionName=one")
+                    .to("log:test.log.1?showBody=true")
+                    .to("mock:result");
+
+                from("jms:topic:foo?clientId=456&durableSubscriptionName=two")
+                    .to("log:test.log.2?showBody=true")
+                    .to("mock:result2");
+            }
+        };
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicSharedTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicSharedTest.java
b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicSharedTest.java
new file mode 100644
index 0000000..b9eacd7
--- /dev/null
+++ b/tests/camel-itest-jms2/src/test/java/org/apache/camel/itest/jms2/Jms2TopicSharedTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.jms2;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.junit.Test;
+
+public class Jms2TopicSharedTest extends BaseJms2TestSupport {
+
+    private static final String TEST_DESTINATION_NAME = "jms:topic:in.only.topic.consumer.test";
+
+    @Test
+    public void testSharedTopic() throws Exception {
+        final String expectedBody = "Hello World";
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+        mock.expectedBodiesReceived("Hello World");
+
+        MockEndpoint mock2 = getMockEndpoint("mock:result2");
+        mock2.expectedMessageCount(1);
+        mock2.expectedBodiesReceived("Hello World");
+
+        template.sendBody("direct:start", expectedBody);
+
+        mock.assertIsSatisfied();
+        mock2.assertIsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                from("direct:start")
+                    .to(TEST_DESTINATION_NAME);
+
+                from(TEST_DESTINATION_NAME)
+                    .to("log:test.log.1?showBody=true", "mock:result");
+
+                from(TEST_DESTINATION_NAME + "?subscriptionName=sharedTest&subscriptionShared=true")
+                    .to("log:test.log.2?showBody=true", "mock:result2");
+
+                from(TEST_DESTINATION_NAME + "?subscriptionName=sharedTest&subscriptionShared=true")
+                    .to("log:test.log.3?showBody=true", "mock:result2");
+            }
+        };
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/camel-itest-jms2/src/test/resources/log4j2.properties
----------------------------------------------------------------------
diff --git a/tests/camel-itest-jms2/src/test/resources/log4j2.properties b/tests/camel-itest-jms2/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..832697f
--- /dev/null
+++ b/tests/camel-itest-jms2/src/test/resources/log4j2.properties
@@ -0,0 +1,32 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+appender.file.type = File
+appender.file.name = file
+appender.file.fileName = target/camel-itest-jms2.log
+appender.file.layout.type = PatternLayout
+appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n
+appender.out.type = Console
+appender.out.name = out
+appender.out.layout.type = PatternLayout
+appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n
+logger.activemq.name = org.apache.activemq
+logger.activemq.level = warn
+logger.camel.name = org.apache.camel
+logger.camel.level = info
+rootLogger.level = INFO
+rootLogger.appenderRef.file.ref = file

http://git-wip-us.apache.org/repos/asf/camel/blob/67339a8e/tests/pom.xml
----------------------------------------------------------------------
diff --git a/tests/pom.xml b/tests/pom.xml
index 47ce84b..7e7aa45 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -42,6 +42,7 @@
     <module>camel-itest-standalone</module>
     <module>camel-itest</module>
     <module>camel-itest-cdi</module>
+    <module>camel-itest-jms2</module>
     <module>camel-jmh</module>
     <module>camel-blueprint-cxf-test</module>
     <module>camel-blueprint-test</module>


Mime
View raw message