}
/** See TCK test: topicconntests.connNotStartedTopicTest */
public void testCannotReceiveMessageOnStoppedConnection() throws Exception
{
TopicConnection conn1 = ((TopicConnectionFactory)JMSTestCase.topicCf).createTopicConnection();
TopicConnection conn2 = ((TopicConnectionFactory)JMSTestCase.topicCf).createTopicConnection();
TopicSession sess1 = conn1.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSession sess2 = conn2.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
TopicSubscriber sub1 = sess1.createSubscriber(HornetQServerTestCase.topic1);
TopicSubscriber sub2 = sess2.createSubscriber(HornetQServerTestCase.topic1);
conn1.start();
Connection conn3 = JMSTestCase.cf.createConnection();
Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod = sess3.createProducer(HornetQServerTestCase.topic1);
prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
final int NUM_MESSAGES = 10;
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess3.createTextMessage("hello");
prod.send(tm);
}
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)sub1.receive(500);
ProxyAssertSupport.assertNotNull(tm);
ProxyAssertSupport.assertEquals("hello", tm.getText());
}
Message m = sub2.receive(200);
ProxyAssertSupport.assertNull(m);
conn2.start();
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = (TextMessage)sub2.receive(500);
ProxyAssertSupport.assertNotNull(tm);
ProxyAssertSupport.assertEquals("hello", tm.getText());
}
log.debug("all messages received by sub2");
conn1.close();
conn2.close();
conn3.close();
}