1 24 25 package org.objectweb.jtests.jms.conform.session; 26 27 import org.objectweb.jtests.jms.framework.*; 28 import junit.framework.*; 29 30 import javax.jms.*; 31 32 41 public class UnifiedSessionTest extends UnifiedTestCase { 42 43 46 protected QueueConnection queueConnection; 47 48 51 protected QueueSession queueSession; 52 53 56 protected TopicConnection topicConnection; 57 58 61 protected TopicSession topicSession; 62 63 71 public void testCreateDurableConnectionConsumerOnQueueConnection() { 72 try { 73 queueConnection.createDurableConnectionConsumer(topic, 74 "subscriptionName", 75 "", 76 (ServerSessionPool)null, 77 1); 78 fail("Should throw a javax.jms.IllegalStateException"); 79 } catch (javax.jms.IllegalStateException e) { 80 } catch (JMSException e) { 81 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 82 } 83 } 84 85 93 public void testCreateDurableSubscriberOnQueueSession() { 94 try { 95 queueSession.createDurableSubscriber(topic, 96 "subscriptionName"); 97 fail("Should throw a javax.jms.IllegalStateException"); 98 } catch (javax.jms.IllegalStateException e) { 99 } catch (JMSException e) { 100 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 101 } 102 } 103 104 112 public void testCreateTemporaryTopicOnQueueSession() { 113 try { 114 TemporaryTopic tempTopic = queueSession.createTemporaryTopic(); 115 fail("Should throw a javax.jms.IllegalStateException"); 116 } catch (javax.jms.IllegalStateException e) { 117 } catch (JMSException e) { 118 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 119 } 120 } 121 122 130 public void testCreateTopicOnQueueSession() { 131 try { 132 Topic tempTopic = queueSession.createTopic("topic_name"); 133 fail("Should throw a javax.jms.IllegalStateException"); 134 } catch (javax.jms.IllegalStateException e) { 135 } catch (JMSException e) { 136 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 137 } 138 } 139 140 148 public void testUnsubscribeOnQueueSession() { 149 try { 150 queueSession.unsubscribe("subscriptionName"); 151 fail("Should throw a javax.jms.IllegalStateException"); 152 } catch (javax.jms.IllegalStateException e) { 153 } catch (JMSException e) { 154 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 155 } 156 } 157 158 166 public void testCreateBrowserOnTopicSession() { 167 try { 168 QueueBrowser queueBrowser = topicSession.createBrowser(queue); 169 fail("Should throw a javax.jms.IllegalStateException"); 170 } catch (javax.jms.IllegalStateException e) { 171 } catch (JMSException e) { 172 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 173 } 174 } 175 176 184 public void testCreateQueueOnTopicSession() { 185 try { 186 Queue tempQueue = topicSession.createQueue("queue_name"); 187 fail("Should throw a javax.jms.IllegalStateException"); 188 } catch (javax.jms.IllegalStateException e) { 189 } catch (JMSException e) { 190 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 191 } 192 } 193 194 202 public void testCreateTemporaryQueueOnTopicSession() { 203 try { 204 TemporaryQueue tempQueue = topicSession.createTemporaryQueue(); 205 fail("Should throw a javax.jms.IllegalStateException"); 206 } catch (javax.jms.IllegalStateException e) { 207 } catch (JMSException e) { 208 fail("Should throw a javax.jms.IllegalStateException, not a "+ e); 209 } 210 } 211 212 public void setUp() { 213 super.setUp(); 214 try { 215 queueConnection = queueConnectionFactory.createQueueConnection(); 216 queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); 217 topicConnection = topicConnectionFactory.createTopicConnection(); 218 topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE); 219 220 queueConnection.start(); 221 topicConnection.start(); 222 } catch (Exception e) { 223 e.printStackTrace(); 225 } 226 } 227 228 public void tearDown() { 229 try { 230 queueConnection.close(); 231 topicConnection.close(); 232 } catch (Exception e) { 233 e.printStackTrace(); 235 } finally { 236 queueConnection = null; 237 queueSession = null; 238 topicConnection = null; 239 topicSession = null; 240 super.tearDown(); 241 } 242 } 243 244 247 public static Test suite() { 248 return new TestSuite(UnifiedSessionTest.class); 249 } 250 251 public UnifiedSessionTest(String name) { 252 super(name); 253 } 254 } 255 | Popular Tags |