You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2015/01/13 23:04:57 UTC

[1/4] qpid-jms git commit: Ensure connection is closed so its threads are shutdown if any.

Repository: qpid-jms
Updated Branches:
  refs/heads/master a3ae2856c -> 6217cb29a


Ensure connection is closed so its threads are shutdown if any.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/b172d59b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/b172d59b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/b172d59b

Branch: refs/heads/master
Commit: b172d59ba73675ea8b8f6a170f36a8150b1c4d09
Parents: a3ae285
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jan 13 16:43:09 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jan 13 16:43:09 2015 -0500

----------------------------------------------------------------------
 .../java/org/apache/qpid/jms/JmsConnectionTest.java   | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/b172d59b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
index 4f50a37..f3d8a57 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsConnectionTest.java
@@ -130,10 +130,24 @@ public class JmsConnectionTest {
             }
         }).when(provider).create(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
 
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                LOG.debug("Handling provider destroy call");
+                if (args[0] instanceof JmsConnectionInfo) {
+                    ProviderFuture request = (ProviderFuture) args[1];
+                    request.onSuccess();
+                }
+                return null;
+            }
+        }).when(provider).destroy(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
         JmsConnection connection = new JmsConnection("ID:TEST:1", provider, clientIdGenerator);
         assertFalse(connection.isConnected());
         connection.start();
         assertTrue(connection.isConnected());
+        connection.close();
     }
 
     //---------- Test methods fail after connection closed -------------------//


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[3/4] qpid-jms git commit: Add test for the TopicConnection implementation JmsTopicConnection to validate that the Queue based methods throw javax.jms.IllegalStateException.

Posted by ta...@apache.org.
Add test for the TopicConnection implementation JmsTopicConnection to
validate that the Queue based methods throw
javax.jms.IllegalStateException.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/97503ca6
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/97503ca6
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/97503ca6

Branch: refs/heads/master
Commit: 97503ca67cb76ef34aa0f32a5a854188077da3a1
Parents: 045e521
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jan 13 17:03:57 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jan 13 17:03:57 2015 -0500

----------------------------------------------------------------------
 .../apache/qpid/jms/JmsQueueConnectionTest.java |   4 +-
 .../apache/qpid/jms/JmsTopicConnectionTest.java | 125 +++++++++++++++++++
 2 files changed, 127 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/97503ca6/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
index 0f4b991..71bc1be 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
@@ -56,7 +56,7 @@ public class JmsQueueConnectionTest {
             @Override
             public Object answer(InvocationOnMock invocation) throws Throwable {
                 Object[] args = invocation.getArguments();
-                LOG.debug("Handling provider create call for resource: {}", args[0]);
+                LOG.trace("Handling provider create call for resource: {}", args[0]);
                 ProviderFuture request = (ProviderFuture) args[1];
                 request.onSuccess();
                 return null;
@@ -67,7 +67,7 @@ public class JmsQueueConnectionTest {
             @Override
             public Object answer(InvocationOnMock invocation) throws Throwable {
                 Object[] args = invocation.getArguments();
-                LOG.debug("Handling provider destroy call");
+                LOG.trace("Handling provider destroy call");
                 ProviderFuture request = (ProviderFuture) args[1];
                 request.onSuccess();
                 return null;

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/97503ca6/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsTopicConnectionTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsTopicConnectionTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsTopicConnectionTest.java
new file mode 100644
index 0000000..7eabde5
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsTopicConnectionTest.java
@@ -0,0 +1,125 @@
+/**
+ * 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.qpid.jms;
+
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.Session;
+import javax.jms.TopicSession;
+
+import org.apache.qpid.jms.meta.JmsResource;
+import org.apache.qpid.jms.provider.Provider;
+import org.apache.qpid.jms.provider.ProviderFuture;
+import org.apache.qpid.jms.util.IdGenerator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test various contract aspects of the TopicConnection implementation
+ */
+public class JmsTopicConnectionTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(JmsTopicConnectionTest.class);
+
+    private final Provider provider = Mockito.mock(Provider.class);
+    private final IdGenerator clientIdGenerator = new IdGenerator();
+
+    private JmsTopicConnection topicConnection;
+    private TopicSession topicSession;
+    private final JmsQueue queue = new JmsQueue();
+
+    @Before
+    public void setUp() throws Exception {
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                LOG.trace("Handling provider create call for resource: {}", args[0]);
+                ProviderFuture request = (ProviderFuture) args[1];
+                request.onSuccess();
+                return null;
+            }
+        }).when(provider).create(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                LOG.trace("Handling provider destroy call");
+                ProviderFuture request = (ProviderFuture) args[1];
+                request.onSuccess();
+                return null;
+            }
+        }).when(provider).destroy(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        topicConnection = new JmsTopicConnection("ID:TEST:1", provider, clientIdGenerator);
+        topicConnection.start();
+
+        topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        topicConnection.close();
+    }
+
+    /**
+     * Test that a call to <code>createBrowser()</code> method
+     * on a <code>TopicSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateBrowserOnTopicSession() throws JMSException {
+        topicSession.createBrowser(queue);
+    }
+
+    /**
+     * Test that a call to <code>createQueue()</code> method
+     * on a <code>TopicSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateQueueOnTopicSession() throws JMSException {
+        topicSession.createQueue("test-queue");
+    }
+
+    /**
+     * Test that a call to <code>createTemporaryQueue()</code> method
+     * on a <code>TopicSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateTemporaryQueueOnTopicSession() throws JMSException {
+        topicSession.createTemporaryQueue();
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[2/4] qpid-jms git commit: Test contract of QueueConnection implementation JmsQueueConnection, topic related methods should throw javax.jms.IllegalStateException.

Posted by ta...@apache.org.
Test contract of QueueConnection implementation JmsQueueConnection,
topic related methods should throw javax.jms.IllegalStateException.

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/045e5215
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/045e5215
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/045e5215

Branch: refs/heads/master
Commit: 045e52152a788dc4c0ea893dae32742e2bc5aa4e
Parents: b172d59
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jan 13 16:55:43 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jan 13 16:55:43 2015 -0500

----------------------------------------------------------------------
 .../apache/qpid/jms/JmsQueueConnectionTest.java | 152 +++++++++++++++++++
 1 file changed, 152 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/045e5215/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
new file mode 100644
index 0000000..0f4b991
--- /dev/null
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/JmsQueueConnectionTest.java
@@ -0,0 +1,152 @@
+/**
+ * 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.qpid.jms;
+
+import javax.jms.IllegalStateException;
+import javax.jms.JMSException;
+import javax.jms.QueueSession;
+import javax.jms.ServerSessionPool;
+import javax.jms.Session;
+
+import org.apache.qpid.jms.meta.JmsResource;
+import org.apache.qpid.jms.provider.Provider;
+import org.apache.qpid.jms.provider.ProviderFuture;
+import org.apache.qpid.jms.util.IdGenerator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Test various contract aspects of the QueueConnection implementation
+ */
+public class JmsQueueConnectionTest {
+
+    private static final Logger LOG = LoggerFactory.getLogger(JmsQueueConnectionTest.class);
+
+    private final Provider provider = Mockito.mock(Provider.class);
+    private final IdGenerator clientIdGenerator = new IdGenerator();
+
+    private JmsQueueConnection queueConnection;
+    private QueueSession queueSession;
+    private final JmsTopic topic = new JmsTopic();
+
+    @Before
+    public void setUp() throws Exception {
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                LOG.debug("Handling provider create call for resource: {}", args[0]);
+                ProviderFuture request = (ProviderFuture) args[1];
+                request.onSuccess();
+                return null;
+            }
+        }).when(provider).create(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        Mockito.doAnswer(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable {
+                Object[] args = invocation.getArguments();
+                LOG.debug("Handling provider destroy call");
+                ProviderFuture request = (ProviderFuture) args[1];
+                request.onSuccess();
+                return null;
+            }
+        }).when(provider).destroy(Mockito.any(JmsResource.class), Mockito.any(ProviderFuture.class));
+
+        queueConnection = new JmsQueueConnection("ID:TEST:1", provider, clientIdGenerator);
+        queueConnection.start();
+
+        queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        queueConnection.close();
+    }
+
+    /**
+     * Test that a call to <code>createDurableConnectionConsumer()</code> method
+     * on a <code>QueueConnection</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateDurableConnectionConsumerOnQueueConnection() throws JMSException{
+        queueConnection.createDurableConnectionConsumer(topic, "subscriptionName", "", (ServerSessionPool)null, 1);
+    }
+
+    /**
+     * Test that a call to <code>createDurableSubscriber()</code> method
+     * on a <code>QueueSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateDurableSubscriberOnQueueSession() throws JMSException {
+        queueSession.createDurableSubscriber(topic, "subscriptionName");
+    }
+
+    /**
+     * Test that a call to <code>createTemporaryTopic()</code> method
+     * on a <code>QueueSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateTemporaryTopicOnQueueSession() throws JMSException {
+        queueSession.createTemporaryTopic();
+    }
+
+    /**
+     * Test that a call to <code>createTopic()</code> method
+     * on a <code>QueueSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testCreateTopicOnQueueSession() throws JMSException {
+        queueSession.createTopic("test-topic");
+    }
+
+    /**
+     * Test that a call to <code>unsubscribe()</code> method
+     * on a <code>QueueSession</code> throws a
+     * <code>javax.jms.IllegalStateException</code>.
+     * (see JMS 1.1 specs, table 4-1).
+     *
+     * @since JMS 1.1
+     */
+    @Test(timeout = 30000, expected=IllegalStateException.class)
+    public void testUnsubscribeOnQueueSession() throws JMSException  {
+        queueSession.unsubscribe("subscriptionName");
+    }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


[4/4] qpid-jms git commit: Remove this test, it is now covered by the offline tests in the client lib JmsTopicConnectionTest and JmsQueueConnectionTest

Posted by ta...@apache.org.
Remove this test, it is now covered by the offline tests in the client
lib JmsTopicConnectionTest and JmsQueueConnectionTest

Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/6217cb29
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/6217cb29
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/6217cb29

Branch: refs/heads/master
Commit: 6217cb29ac0a9c98c9b90774f388baea3f5f39f7
Parents: 97503ca
Author: Timothy Bish <ta...@gmail.com>
Authored: Tue Jan 13 17:04:45 2015 -0500
Committer: Timothy Bish <ta...@gmail.com>
Committed: Tue Jan 13 17:04:45 2015 -0500

----------------------------------------------------------------------
 .../qpid/jms/joram/JoramUnifiedSessionTest.java | 56 --------------------
 1 file changed, 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/6217cb29/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/joram/JoramUnifiedSessionTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/joram/JoramUnifiedSessionTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/joram/JoramUnifiedSessionTest.java
deleted file mode 100644
index c06e2a4..0000000
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/joram/JoramUnifiedSessionTest.java
+++ /dev/null
@@ -1,56 +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.qpid.jms.joram;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.junit.After;
-import org.junit.Before;
-import org.objectweb.jtests.jms.conform.session.UnifiedSessionTest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Runs the Joram UnifiedSessionTest
- */
-public class JoramUnifiedSessionTest extends UnifiedSessionTest {
-
-    private final Logger LOG = LoggerFactory.getLogger(getClass());
-
-    public JoramUnifiedSessionTest(String name) {
-        super(name);
-    }
-
-    @Before
-    @Override
-    public void setUp() throws Exception {
-        LOG.info("========== Starting test: " + getName() + " ==========");
-        super.setUp();
-    }
-
-    @After
-    @Override
-    public void tearDown() throws Exception {
-        LOG.info("========== Finsished test: " + getName() + " ==========");
-        super.tearDown();
-    }
-
-    public static Test suite() {
-       return new TestSuite(JoramUnifiedSessionTest.class);
-    }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org