From 1b3a76fe43ebac4e717a9adaa6b7900715f09c87 Mon Sep 17 00:00:00 2001 From: Marnie McCormack Date: Tue, 7 Nov 2006 11:10:08 +0000 Subject: Tests for changes around QueueSession and TopicSession as per QPID-66 git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@472062 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/client/TestAMQConnection.java | 121 +++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 java/client/test/src/org/apache/qpid/client/TestAMQConnection.java (limited to 'java/client/test/src') diff --git a/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java b/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java new file mode 100644 index 0000000000..d0e1a793f8 --- /dev/null +++ b/java/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()); + } + } + +} -- cgit v1.2.1