This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/master by this push:
     new d7eb076  ARTEMIS-2190 move tests
     new ff81f2e  This closes #2477
d7eb076 is described below

commit d7eb076d4bbde61a68617dfcee0f790ef873b05c
Author: Justin Bertram <[email protected]>
AuthorDate: Fri Dec 21 09:15:45 2018 -0600

    ARTEMIS-2190 move tests
    
    The "jms-tests" module is deprecated and these tests should have never
    gone in there. Moving them to the "integration-tests" module.
---
 .../jms/client/TemporaryDestinationTest.java       | 207 +++++++++++++++++++++
 .../activemq/artemis/tests/util/JMSTestBase.java   |  20 ++
 .../jms/tests/TemporaryDestinationTest.java        | 169 -----------------
 3 files changed, 227 insertions(+), 169 deletions(-)

diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TemporaryDestinationTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TemporaryDestinationTest.java
new file mode 100644
index 0000000..6f87d52
--- /dev/null
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/client/TemporaryDestinationTest.java
@@ -0,0 +1,207 @@
+/*
+ * 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.activemq.artemis.tests.integration.jms.client;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TemporaryQueue;
+import javax.jms.TemporaryTopic;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
+import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
+import org.apache.activemq.artemis.tests.util.JMSTestBase;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TemporaryDestinationTest extends JMSTestBase {
+
+   @Override
+   @Before
+   public void setUp() throws Exception {
+      super.setUp();
+   }
+
+   @Test
+   public void testTemporaryQueueLeak() throws Exception {
+      ActiveMQConnection conn = null;
+
+      try {
+         conn = (ActiveMQConnection) createConnection();
+
+         Session producerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         Session consumerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
+
+         MessageProducer producer = producerSession.createProducer(tempQueue);
+
+         MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
+
+         conn.start();
+
+         final String messageText = "This is a message";
+
+         javax.jms.Message m = producerSession.createTextMessage(messageText);
+
+         producer.send(m);
+
+         TextMessage m2 = (TextMessage) consumer.receive(2000);
+
+         assertNotNull(m2);
+
+         assertEquals(messageText, m2.getText());
+
+         consumer.close();
+
+         tempQueue.delete();
+
+         
assertFalse(conn.containsKnownDestination(SimpleString.toSimpleString(tempQueue.getQueueName())));
+
+         
assertFalse(conn.containsTemporaryQueue(SimpleString.toSimpleString(tempQueue.getQueueName())));
+      } finally {
+         if (conn != null) {
+            conn.close();
+         }
+      }
+   }
+   @Test
+   public void testTemporaryQueueDeletedAfterSessionClosed() throws Exception {
+      server.getAddressSettingsRepository().addMatch("#", new 
AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
+
+      Connection conn = null;
+
+      try {
+         conn = createConnection();
+
+         Session producerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         Session consumerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         // Make sure temporary queue cannot be used after it has been deleted
+
+         TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
+
+         MessageProducer producer = producerSession.createProducer(tempQueue);
+
+         MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
+
+         conn.start();
+
+         final String messageText = "This is a message";
+
+         javax.jms.Message m = producerSession.createTextMessage(messageText);
+
+         producer.send(m);
+
+         TextMessage m2 = (TextMessage) consumer.receive(2000);
+
+         assertNotNull(m2);
+
+         assertEquals(messageText, m2.getText());
+
+         consumer.close();
+
+         consumerSession.close();
+
+         producer.close();
+
+         producerSession.close();
+
+         tempQueue.delete();
+
+         producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         try {
+            producer = producerSession.createProducer(tempQueue);
+            producer.send(m);
+            fail();
+         } catch (JMSException e) {
+         }
+      } finally {
+         if (conn != null) {
+            conn.close();
+         }
+      }
+   }
+
+   @Test
+   public void testTemporaryTopicDeletedAfterSessionClosed() throws Exception {
+      server.getAddressSettingsRepository().addMatch("#", new 
AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
+
+      Connection conn = null;
+
+      try {
+         conn = createConnection();
+
+         Session producerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         Session consumerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+
+         // Make sure temporary topic cannot be used after it has been deleted
+
+         TemporaryTopic tempTopic = producerSession.createTemporaryTopic();
+
+         MessageProducer producer = producerSession.createProducer(tempTopic);
+
+         MessageConsumer consumer = consumerSession.createConsumer(tempTopic);
+
+         conn.start();
+
+         final String messageText = "This is a message";
+
+         javax.jms.Message m = producerSession.createTextMessage(messageText);
+
+         producer.send(m);
+
+         TextMessage m2 = (TextMessage) consumer.receive(2000);
+
+         assertNotNull(m2);
+
+         assertEquals(messageText, m2.getText());
+
+         consumer.close();
+
+         consumerSession.close();
+
+         producer.close();
+
+         producerSession.close();
+
+         tempTopic.delete();
+
+         producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+         try {
+            producer = producerSession.createProducer(tempTopic);
+            producer.send(m);
+            fail();
+         } catch (JMSException e) {
+         }
+      } finally {
+         if (conn != null) {
+            conn.close();
+         }
+      }
+   }
+
+}
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java
index 44ab399..50074e9 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/util/JMSTestBase.java
@@ -64,6 +64,7 @@ public class JMSTestBase extends ActiveMQTestBase {
    private final Set<JMSContext> contextSet = new HashSet<>();
    private final Random random = new Random();
    protected InVMNamingContext namingContext;
+   private final Set<Connection> connectionsSet = new HashSet<>();
 
    protected boolean useSecurity() {
       return false;
@@ -176,6 +177,15 @@ public class JMSTestBase extends ActiveMQTestBase {
       } catch (Exception e) {
          // no-op
       }
+      try {
+         for (Connection localConn : connectionsSet) {
+            localConn.close();
+         }
+      } catch (Exception ignored) {
+         // no-op
+      } finally {
+         connectionsSet.clear();
+      }
 
       namingContext.close();
       jmsServer.stop();
@@ -275,4 +285,14 @@ public class JMSTestBase extends ActiveMQTestBase {
       }
    }
 
+   protected final Connection createConnection() throws JMSException {
+      Connection c = cf.createConnection();
+      return addConnection(c);
+   }
+
+   protected final Connection addConnection(Connection conn) {
+      connectionsSet.add(conn);
+      return conn;
+   }
+
 }
diff --git 
a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
 
b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
index 6b29aea..f43dd4e 100644
--- 
a/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
+++ 
b/tests/jms-tests/src/test/java/org/apache/activemq/artemis/jms/tests/TemporaryDestinationTest.java
@@ -27,9 +27,6 @@ import javax.jms.TemporaryTopic;
 import javax.jms.TextMessage;
 import javax.naming.NamingException;
 
-import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
-import org.apache.activemq.artemis.api.core.SimpleString;
-import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
 import org.apache.activemq.artemis.jms.tests.util.ProxyAssertSupport;
 import org.junit.Test;
 
@@ -128,52 +125,6 @@ public class TemporaryDestinationTest extends JMSTestCase {
          }
       }
    }
-
-   @Test
-   public void testTemporaryQueueLeak() throws Exception {
-      ActiveMQConnection conn = null;
-
-      try {
-         conn = (ActiveMQConnection) createConnection();
-
-         Session producerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-
-         Session consumerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-
-         TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
-
-         MessageProducer producer = producerSession.createProducer(tempQueue);
-
-         MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
-
-         conn.start();
-
-         final String messageText = "This is a message";
-
-         Message m = producerSession.createTextMessage(messageText);
-
-         producer.send(m);
-
-         TextMessage m2 = (TextMessage) consumer.receive(2000);
-
-         ProxyAssertSupport.assertNotNull(m2);
-
-         ProxyAssertSupport.assertEquals(messageText, m2.getText());
-
-         consumer.close();
-
-         tempQueue.delete();
-
-         
ProxyAssertSupport.assertFalse(conn.containsKnownDestination(SimpleString.toSimpleString(tempQueue.getQueueName())));
-
-         
ProxyAssertSupport.assertFalse(conn.containsTemporaryQueue(SimpleString.toSimpleString(tempQueue.getQueueName())));
-      } finally {
-         if (conn != null) {
-            conn.close();
-         }
-      }
-   }
-
    /**
     * http://jira.jboss.com/jira/browse/JBMESSAGING-93
     */
@@ -314,126 +265,6 @@ public class TemporaryDestinationTest extends JMSTestCase 
{
    }
 
    @Test
-   public void testTemporaryQueueDeletedAfterSessionClosed() throws Exception {
-      
servers.get(0).getActiveMQServer().getAddressSettingsRepository().addMatch("#", 
new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
-
-      Connection conn = null;
-
-      try {
-         conn = createConnection();
-
-         Session producerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-
-         Session consumerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-
-         // Make sure temporary queue cannot be used after it has been deleted
-
-         TemporaryQueue tempQueue = producerSession.createTemporaryQueue();
-
-         MessageProducer producer = producerSession.createProducer(tempQueue);
-
-         MessageConsumer consumer = consumerSession.createConsumer(tempQueue);
-
-         conn.start();
-
-         final String messageText = "This is a message";
-
-         Message m = producerSession.createTextMessage(messageText);
-
-         producer.send(m);
-
-         TextMessage m2 = (TextMessage) consumer.receive(2000);
-
-         ProxyAssertSupport.assertNotNull(m2);
-
-         ProxyAssertSupport.assertEquals(messageText, m2.getText());
-
-         consumer.close();
-
-         consumerSession.close();
-
-         producer.close();
-
-         producerSession.close();
-
-         tempQueue.delete();
-
-         producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         try {
-            producer = producerSession.createProducer(tempQueue);
-            producer.send(m);
-            ProxyAssertSupport.fail();
-         } catch (JMSException e) {
-         }
-      } finally {
-         if (conn != null) {
-            conn.close();
-         }
-      }
-   }
-
-   @Test
-   public void testTemporaryTopicDeletedAfterSessionClosed() throws Exception {
-      
servers.get(0).getActiveMQServer().getAddressSettingsRepository().addMatch("#", 
new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
-
-      Connection conn = null;
-
-      try {
-         conn = createConnection();
-
-         Session producerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-
-         Session consumerSession = conn.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
-
-         // Make sure temporary topic cannot be used after it has been deleted
-
-         TemporaryTopic tempTopic = producerSession.createTemporaryTopic();
-
-         MessageProducer producer = producerSession.createProducer(tempTopic);
-
-         MessageConsumer consumer = consumerSession.createConsumer(tempTopic);
-
-         conn.start();
-
-         final String messageText = "This is a message";
-
-         Message m = producerSession.createTextMessage(messageText);
-
-         producer.send(m);
-
-         TextMessage m2 = (TextMessage) consumer.receive(2000);
-
-         ProxyAssertSupport.assertNotNull(m2);
-
-         ProxyAssertSupport.assertEquals(messageText, m2.getText());
-
-         consumer.close();
-
-         consumerSession.close();
-
-         producer.close();
-
-         producerSession.close();
-
-         tempTopic.delete();
-
-         producerSession = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-         try {
-            producer = producerSession.createProducer(tempTopic);
-            producer.send(m);
-            ProxyAssertSupport.fail();
-         } catch (JMSException e) {
-         }
-      } finally {
-         if (conn != null) {
-            conn.close();
-         }
-      }
-   }
-
-   @Test
    public void testTemporaryTopicBasic() throws Exception {
       Connection conn = null;
 

Reply via email to