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 18:34:48 UTC
qpid-jms git commit: add more TemporaryTopic tests
Repository: qpid-jms
Updated Branches:
refs/heads/master dbf4fe01e -> 05d83c6f7
add more TemporaryTopic 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/05d83c6f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/05d83c6f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/05d83c6f
Branch: refs/heads/master
Commit: 05d83c6f792d8fc2cd9b75151a637f2ec9d11fb5
Parents: dbf4fe0
Author: Robert Gemmell <ro...@apache.org>
Authored: Tue Jan 13 17:18:34 2015 +0000
Committer: Robert Gemmell <ro...@apache.org>
Committed: Tue Jan 13 17:19:10 2015 +0000
----------------------------------------------------------------------
.../jms/destinations/JmsTemporaryQueueTest.java | 2 +-
.../jms/destinations/JmsTemporaryTopicTest.java | 95 +++++++++++++++++++-
2 files changed, 94 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/05d83c6f/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 8021ede..5289a59 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
@@ -55,7 +55,7 @@ public class JmsTemporaryQueueTest extends AmqpTestSupport {
}
@Test(timeout = 60000)
- public void testConsumeFromTemporaryQueueCreatedOnAnotherConnection() throws Exception {
+ public void testCantConsumeFromTemporaryQueueCreatedOnAnotherConnection() throws Exception {
connection = createAmqpConnection();
connection.start();
http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/05d83c6f/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryTopicTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryTopicTest.java b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryTopicTest.java
index 95e3303..ec5dac9 100644
--- a/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryTopicTest.java
+++ b/qpid-jms-interop-tests/qpid-jms-activemq-tests/src/test/java/org/apache/qpid/jms/destinations/JmsTemporaryTopicTest.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.TemporaryTopic;
@@ -35,8 +42,7 @@ public class JmsTemporaryTopicTest extends AmqpTestSupport {
protected static final Logger LOG = LoggerFactory.getLogger(JmsTemporaryTopicTest.class);
- // Temp Topics not yet supported on the Broker.
- @Ignore
+ @Ignore //TODO: enable and remove "testCreateTemporaryTopicWithoutBrokerCheck"
@Test(timeout = 60000)
public void testCreateTemporaryTopic() throws Exception {
connection = createAmqpConnection();
@@ -47,6 +53,91 @@ public class JmsTemporaryTopicTest extends AmqpTestSupport {
TemporaryTopic topic = session.createTemporaryTopic();
session.createConsumer(topic);
+ //TODO: TempTopics not yet supported on the Broker, it is faking it, this check fails.
assertEquals(1, brokerService.getAdminView().getTemporaryTopics().length);
}
+
+ @Test(timeout = 60000)
+ public void testCreateTemporaryTopicWithoutBrokerCheck() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ assertNotNull(session);
+ TemporaryTopic topic = session.createTemporaryTopic();
+ session.createConsumer(topic);
+ }
+
+ @Test(timeout = 60000)
+ public void testCantConsumeFromTemporaryTopicCreatedOnAnotherConnection() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryTopic tempTopic = session.createTemporaryTopic();
+ session.createConsumer(tempTopic);
+
+ Connection connection2 = createAmqpConnection();
+ try {
+ Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ try {
+ session2.createConsumer(tempTopic);
+ fail("should not be able to consumer from temporary topic from another connection");
+ } catch (InvalidDestinationException ide) {
+ // expected
+ }
+ } finally {
+ connection2.close();
+ }
+ }
+
+ @Test(timeout = 60000)
+ public void testCantSendToTemporaryTopicFromClosedConnection() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryTopic tempTopic = session.createTemporaryTopic();
+
+ Connection connection2 = createAmqpConnection();
+ try {
+ Session session2 = connection2.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Message msg = session2.createMessage();
+ MessageProducer producer = session2.createProducer(tempTopic);
+
+ // Close the original connection
+ connection.close();
+
+ try {
+ producer.send(msg);
+ fail("should not be able to send to temporary topic from closed connection");
+ } catch (IllegalStateException ide) {
+ // expected
+ }
+ } finally {
+ connection2.close();
+ }
+ }
+
+ @Test(timeout = 60000)
+ public void testCantDeleteTemporaryTopicWithConsumers() throws Exception {
+ connection = createAmqpConnection();
+ connection.start();
+
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ TemporaryTopic tempTopic = session.createTemporaryTopic();
+ MessageConsumer consumer = session.createConsumer(tempTopic);
+
+ try {
+ tempTopic.delete();
+ fail("should not be able to delete temporary topic with active consumers");
+ } catch (IllegalStateException ide) {
+ // expected
+ }
+
+ consumer.close();
+
+ // Now it should be allowed
+ tempTopic.delete();
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org