[1/2] activemq-artemis git commit: This closes #1754

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[1/2] activemq-artemis git commit: This closes #1754

martyntaylor
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 18d2d13d9 -> c959d0c67


This closes #1754


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

Branch: refs/heads/master
Commit: c959d0c67d4b2c9ebb9ed8fba5c0b5026ced8eb7
Parents: 18d2d13 2afe081
Author: Martyn Taylor <[hidden email]>
Authored: Thu Jan 11 10:59:11 2018 +0000
Committer: Martyn Taylor <[hidden email]>
Committed: Thu Jan 11 10:59:11 2018 +0000

----------------------------------------------------------------------
 .../integration/amqp/JMSTopicConsumerTest.java  | 86 ++++++++++++++++++++
 1 file changed, 86 insertions(+)
----------------------------------------------------------------------


Reply | Threaded
Open this post in threaded view
|

[2/2] activemq-artemis git commit: ARTEMIS-1576 couple more tests for good measure

martyntaylor
ARTEMIS-1576 couple more tests for good measure


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/2afe0812
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/2afe0812
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/2afe0812

Branch: refs/heads/master
Commit: 2afe08126b4aaf97920954e18ec971cd13e3abb4
Parents: 18d2d13
Author: Justin Bertram <[hidden email]>
Authored: Fri Jan 5 15:15:33 2018 -0600
Committer: Martyn Taylor <[hidden email]>
Committed: Thu Jan 11 10:59:11 2018 +0000

----------------------------------------------------------------------
 .../integration/amqp/JMSTopicConsumerTest.java  | 86 ++++++++++++++++++++
 1 file changed, 86 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/2afe0812/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTopicConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTopicConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTopicConsumerTest.java
index 52bd247..5f7490f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTopicConsumerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/JMSTopicConsumerTest.java
@@ -16,12 +16,17 @@
  */
 package org.apache.activemq.artemis.tests.integration.amqp;
 
+import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.TimeUnit;
 
 import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
 import javax.jms.ExceptionListener;
+import javax.jms.JMSConsumer;
+import javax.jms.JMSContext;
 import javax.jms.JMSException;
+import javax.jms.JMSProducer;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
 import javax.jms.TextMessage;
@@ -30,9 +35,11 @@ import javax.jms.TopicPublisher;
 import javax.jms.TopicSession;
 import javax.jms.TopicSubscriber;
 
+import org.apache.activemq.artemis.api.core.RoutingType;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.postoffice.Bindings;
 import org.apache.activemq.artemis.core.remoting.CloseListener;
+import org.apache.qpid.jms.JmsConnectionFactory;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -65,6 +72,85 @@ public class JMSTopicConsumerTest extends JMSClientTestSupport {
    }
 
    @Test(timeout = 60000)
+   public void testSendAndReceiveOnAutoCreatedTopic() throws Exception {
+      Connection connection = createConnection("myClientId");
+      String topicName = UUID.randomUUID().toString();
+      SimpleString simpleTopicName = SimpleString.toSimpleString(topicName);
+
+      try {
+         TopicSession session = (TopicSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         Topic topic = session.createTopic(topicName);
+         TopicPublisher producer = session.createPublisher(topic);
+
+         TextMessage message = session.createTextMessage("test-message");
+         // this will auto-create the address, but not the subscription queue
+         producer.send(message);
+
+         assertNotNull(server.getAddressInfo(simpleTopicName));
+         assertEquals(RoutingType.MULTICAST, server.getAddressInfo(simpleTopicName).getRoutingType());
+         assertTrue(server.getAddressInfo(simpleTopicName).isAutoCreated());
+         assertTrue(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
+
+         // this will auto-create the subscription queue
+         TopicSubscriber consumer = session.createSubscriber(topic);
+         assertFalse(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
+         producer.send(message);
+
+         producer.close();
+         connection.start();
+
+         message = (TextMessage) consumer.receive(1000);
+
+         assertNotNull(message);
+         assertNotNull(message.getText());
+         assertEquals("test-message", message.getText());
+         consumer.close();
+         assertTrue(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
+      } finally {
+         connection.close();
+      }
+   }
+
+   @Test(timeout = 60000)
+   public void testSendAndReceiveOnAutoCreatedTopicJMS2() throws Exception {
+      ConnectionFactory cf = new JmsConnectionFactory(getBrokerQpidJMSConnectionURI());
+      JMSContext context = cf.createContext();
+      String topicName = UUID.randomUUID().toString();
+      SimpleString simpleTopicName = SimpleString.toSimpleString(topicName);
+
+      try {
+         Topic topic = context.createTopic(topicName);
+         JMSProducer producer = context.createProducer();
+
+         TextMessage message = context.createTextMessage("test-message");
+         // this will auto-create the address, but not the subscription queue
+         producer.send(topic, message);
+
+         assertNotNull(server.getAddressInfo(simpleTopicName));
+         assertEquals(RoutingType.MULTICAST, server.getAddressInfo(simpleTopicName).getRoutingType());
+         assertTrue(server.getAddressInfo(simpleTopicName).isAutoCreated());
+         assertTrue(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
+
+         // this will auto-create the subscription queue
+         JMSConsumer consumer = context.createConsumer(topic);
+         assertFalse(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
+         producer.send(topic, message);
+
+         context.start();
+
+         message = (TextMessage) consumer.receive(1000);
+
+         assertNotNull(message);
+         assertNotNull(message.getText());
+         assertEquals("test-message", message.getText());
+         consumer.close();
+         assertTrue(server.getPostOffice().getBindingsForAddress(simpleTopicName).getBindings().isEmpty());
+      } finally {
+         context.close();
+      }
+   }
+
+   @Test(timeout = 60000)
    public void testSendWithMultipleReceiversOnTopic() throws Exception {
       Connection connection = createConnection();