You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ro...@apache.org on 2015/01/13 17:02:38 UTC
[5/5] qpid-jms git commit: add more TemporaryQueue tests
add more TemporaryQueue tests
Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/ec5c3e75
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/ec5c3e75
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/ec5c3e75
Branch: refs/heads/master
Commit: ec5c3e7540fcef13a1cfca65f8643edd61146bc5
Parents: 71cff45
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Jan 13 15:51:37 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Jan 13 16:02:09 2015 +0000
----------------------------------------------------------------------
.../jms/destinations/JmsTemporaryQueueTest.java | 80 ++++++++++++++++++++
1 file changed, 80 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/ec5c3e75/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryQueueTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryQueueTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryQueueTest.java
index 1eccaf2..8021ede 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryQueueTest.java
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryQueueTest.java
@@ -18,7 +18,14 @@ package org.apache.qpid.jms.destinations;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+import javax.jms.Connection;
+import javax.jms.IllegalStateException;
+import javax.jms.InvalidDestinationException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TemporaryQueue;
@@ -46,4 +53,77 @@ public class JmsTemporaryQueueTest extends AmqpTestSupport {
assertEquals(1, brokerService.getAdminView().getTemporaryQueues().length);
}
+
+ @Test(timeout = 60000)
+ public void testConsumeFromTemporaryQueueCreatedOnAnotherConnection() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryQueue tempQueue = session.createTemporaryQueue();
+ session.createConsumer(tempQueue);
+
+ Connection connection2 = createAmqpConnection();
+ try {
+ Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try {
+ session2.createConsumer(tempQueue);
+ fail("should not be able to consumer from temporary queue from another connection");
+ } catch (InvalidDestinationException ide) {
+ // expected
+ }
+ } finally {
+ connection2.close();
+ }
+ }
+
+ @Test(timeout = 60000)
+ public void testCantSendToTemporaryQueueFromClosedConnection() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryQueue tempQueue = session.createTemporaryQueue();
+
+ Connection connection2 = createAmqpConnection();
+ try {
+ Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Message msg = session2.createMessage();
+ MessageProducer producer = session2.createProducer(tempQueue);
+
+ // Close the original connection
+ connection.close();
+
+ try {
+ producer.send(msg);
+ fail("should not be able to send to temporary queue from closed connection");
+ } catch (IllegalStateException ide) {
+ // expected
+ }
+ } finally {
+ connection2.close();
+ }
+ }
+
+ @Test(timeout = 60000)
+ public void testCantDeleteTemporaryQueueWithConsumers() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryQueue tempQueue = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(tempQueue);
+
+ try {
+ tempQueue.delete();
+ fail("should not be able to delete temporary queue with active consumers");
+ } catch (IllegalStateException ide) {
+ // expected
+ }
+
+ consumer.close();
+
+ // Now it should be allowed
+ tempQueue.delete();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org