User: chirino
Date: 01/12/08 20:17:13
Modified: src/main/org/jboss/test/jbossmq/test
JBossMQUnitTestCase.java
Log:
Added a test to see if NoLocal works.
Revision Changes Path
1.5 +47 -0
jbosstest/src/main/org/jboss/test/jbossmq/test/JBossMQUnitTestCase.java
Index: JBossMQUnitTestCase.java
===================================================================
RCS file:
/cvsroot/jboss/jbosstest/src/main/org/jboss/test/jbossmq/test/JBossMQUnitTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- JBossMQUnitTestCase.java 2001/11/10 21:38:07 1.4
+++ JBossMQUnitTestCase.java 2001/12/09 04:17:13 1.5
@@ -445,6 +445,53 @@
topicConnection.close();
getLog().debug("Topic test passed");
}
+ /**
+ * Test to seeif the NoLocal feature of topics works.
+ * Messages published from the same connection should not
+ * be received by Subscribers on the same connection.
+ */
+ public void testTopicNoLocal() throws Exception {
+ getLog().debug("Starting Topic test");
+
+ TopicConnectionFactory topicFactory =
(TopicConnectionFactory)context.lookup(TOPIC_FACTORY);
+ TopicConnection topicConnection1 = topicFactory.createTopicConnection();
+ topicConnection1.start();
+ TopicConnection topicConnection2 = topicFactory.createTopicConnection();
+ topicConnection2.start();
+
+ // We don't want local messages on this topic.
+ TopicSession session1 = topicConnection1.createTopicSession(true,
Session.AUTO_ACKNOWLEDGE);
+ Topic topic = (Topic)context.lookup(TEST_TOPIC);
+ TopicSubscriber sub = session1.createSubscriber(topic);
+ TopicPublisher sender1 = session1.createPublisher(topic);
+
+ //Now a sender
+ TopicSession session2 = topicConnection2.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
+ TopicPublisher sender2 = session2.createPublisher(topic);
+
+ drainMessagesForTopic(sub);
+
+ //send some messages
+ sender1.publish(session1.createTextMessage("Local Message"));
+ sender2.publish(session2.createTextMessage("Remote Message"));
+
+ // Get the messages, we should get the remote message
+ // but not the local message
+ TextMessage msg1 = (TextMessage)sub.receive(2000);
+ assertTrue("Did not get any messages", msg1!=null);
+ if( msg1 != null ) {
+ assertTrue("Got a local message", !msg1.getText().equals("Local
Message"));
+
+ }
+ TextMessage msg2 = (TextMessage)sub.receive(2000);
+ assertTrue("Got an extra message. msg1:"+msg1+", msg2:"+msg2, msg2==null);
+
+ topicConnection1.stop();
+ topicConnection1.close();
+ topicConnection2.stop();
+ topicConnection2.close();
+ getLog().debug("Topic test passed");
+ }
public static Test suite() throws Exception
{
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development