summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarnie McCormack <marnie@apache.org>2006-11-07 11:10:08 +0000
committerMarnie McCormack <marnie@apache.org>2006-11-07 11:10:08 +0000
commit8d1976af4c4fc702d57942d6d504059b15fd7720 (patch)
treebb5ed1c7fae352ab394812f5f9a4d4a237051bce
parent8fd0291e7e4ecdd358e4470ef7532bcdfeca2e96 (diff)
downloadqpid-python-8d1976af4c4fc702d57942d6d504059b15fd7720.tar.gz
Tests for changes around QueueSession and TopicSession as per QPID-66
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid/java@472062 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--client/test/src/org/apache/qpid/client/TestAMQConnection.java121
1 files changed, 121 insertions, 0 deletions
diff --git a/client/test/src/org/apache/qpid/client/TestAMQConnection.java b/client/test/src/org/apache/qpid/client/TestAMQConnection.java
new file mode 100644
index 0000000000..d0e1a793f8
--- /dev/null
+++ b/client/test/src/org/apache/qpid/client/TestAMQConnection.java
@@ -0,0 +1,121 @@
+/*
+ *
+ * Copyright (c) 2006 The Apache Software Foundation
+ *
+ * Licensed 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.client;
+
+import org.junit.*;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.url.URLSyntaxException;
+import junit.framework.JUnit4TestAdapter;
+
+import javax.jms.*;
+
+public class TestAMQConnection {
+
+ private static AMQConnection _connection;
+ private static AMQTopic _topic;
+ private static AMQQueue _queue;
+ private static QueueSession _queueSession;
+ private static TopicSession _topicSession;
+
+ @BeforeClass
+ public static void setUp() throws AMQException, URLSyntaxException, JMSException {
+ //initialise the variables we need for testing
+ startVmBrokers();
+ _connection = new AMQConnection("vm://:1", "guest", "guest", "fred", "/test");
+ _topic = new AMQTopic("mytopic");
+ _queue = new AMQQueue("myqueue");
+ }
+
+ /**
+ * Simple tests to check we can create TopicSession and QueueSession ok
+ * And that they throw exceptions where appropriate as per JMS spec
+ */
+
+ @Test
+ public void testCreateQueueSession() throws JMSException
+ {
+ _queueSession = _connection.createQueueSession(false, AMQSession.NO_ACKNOWLEDGE);
+ }
+
+ @Test
+ public void testCreateTopicSession() throws JMSException
+ {
+ _topicSession = _connection.createTopicSession(false, AMQSession.NO_ACKNOWLEDGE);
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testTopicSessionCreateBrowser() throws JMSException {
+ _topicSession.createBrowser(_queue);
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testTopicSessionCreateQueue() throws JMSException {
+ _topicSession.createQueue("abc");
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testTopicSessionCreateTemporaryQueue() throws JMSException {
+ _topicSession.createTemporaryQueue();
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testQueueSessionCreateTemporaryTopic() throws JMSException {
+ _queueSession.createTemporaryTopic();
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testQueueSessionCreateTopic() throws JMSException {
+ _queueSession.createTopic("abc");
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testQueueSessionDurableSubscriber() throws JMSException {
+ _queueSession.createDurableSubscriber(_topic,"abc");
+ }
+
+ @Test(expected=javax.jms.IllegalStateException.class)
+ public void testQueueSessionUnsubscribe() throws JMSException {
+ _queueSession.unsubscribe("abc");
+ }
+
+ @AfterClass
+ public static void stopVmBrokers()
+ {
+ TransportConnection.killVMBroker(1);
+ }
+
+ public static junit.framework.Test suite()
+ {
+ return new JUnit4TestAdapter(TestAMQConnection.class);
+ }
+
+ private static void startVmBrokers()
+ {
+ try
+ {
+ TransportConnection.createVMBroker(1);
+ }
+ catch (AMQVMBrokerCreationException e)
+ {
+ Assert.fail("Unable to create VM Broker: " + e.getMessage());
+ }
+ }
+
+}