Author: marnie
Date: Tue Nov  7 03:10:08 2006
New Revision: 472062

URL: http://svn.apache.org/viewvc?view=rev&rev=472062
Log:
Tests for changes around QueueSession and TopicSession as per QPID-66

Added:
    
incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java

Added: 
incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java?view=auto&rev=472062
==============================================================================
--- 
incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java
 (added)
+++ 
incubator/qpid/trunk/qpid/java/client/test/src/org/apache/qpid/client/TestAMQConnection.java
 Tue Nov  7 03:10:08 2006
@@ -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());
+        }
+    }
+
+}


Reply via email to