[prev in list] [next in list] [prev in thread] [next in thread]
List: jboss-cvs-commits
Subject: [jboss-cvs] jboss-jms/tests/src/org/jboss/test/messaging/jms ...
From: Ovidiu Feodorov <ovidiu.feodorov () jboss ! com>
Date: 2006-01-31 23:37:18
Message-ID: E1F453m-00023C-BL () committer01 ! frg ! pub ! inap ! atl ! jboss ! com
[Download RAW message or body]
User: ovidiu
Date: 06/01/31 18:37:18
Modified: tests/src/org/jboss/test/messaging/jms
DurableSubscriptionTest.java
MessageConsumerTest.java PersistenceTest.java
Log:
- Clarified the distinction between destination undeployment/re-deployment and \
destination drop. Added a test case that checks whether the current convention is \
enforced. Currently, is not possible to drop destinations, they will be always \
"re-deployed" or "activated". See http://jira.jboss.org/jira/browse/JBMESSAGING-220
- Move various tests under the correct packages.
Revision Changes Path
1.6 +111 -49 \
jboss-jms/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DurableSubscriptionTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-jms/tests/src/org/jboss/test/messaging/jms/DurableSubscriptionTest.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- DurableSubscriptionTest.java 31 Jan 2006 05:43:01 -0000 1.5
+++ DurableSubscriptionTest.java 31 Jan 2006 23:37:18 -0000 1.6
@@ -36,7 +36,7 @@
import javax.jms.TextMessage;
import javax.jms.Message;
import javax.jms.InvalidDestinationException;
-import javax.management.ObjectName;
+import javax.jms.JMSException;
import java.util.Set;
@@ -46,7 +46,7 @@
*
* @author <a href="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
*
- * $Id: DurableSubscriptionTest.java,v 1.5 2006/01/31 05:43:01 ovidiu Exp $
+ * $Id: DurableSubscriptionTest.java,v 1.6 2006/01/31 23:37:18 ovidiu Exp $
*/
public class DurableSubscriptionTest extends MessagingTestCase
{
@@ -106,10 +106,29 @@
s.createDurableSubscriber(topic, "monicabelucci");
+
+ Set subs = (Set)ServerManagement.
+ invoke(ServerManagement.getDurableSubscriptionStoreObjectName(),
+ "getSubscriptions",
+ new Object[] { "brookeburke" },
+ new String[] { "java.lang.String" });
+
+ assertEquals(1, subs.size());
+ assertEquals("monicabelucci", subs.iterator().next());
+
prod.send(s.createTextMessage("k"));
conn.close();
+ subs = (Set)ServerManagement.
+ invoke(ServerManagement.getDurableSubscriptionStoreObjectName(),
+ "getSubscriptions",
+ new Object[] { "brookeburke" },
+ new String[] { "java.lang.String" });
+
+ assertEquals(1, subs.size());
+ assertEquals("monicabelucci", subs.iterator().next());
+
conn = cf.createConnection();
conn.setClientID("brookeburke");
@@ -122,7 +141,6 @@
TextMessage tm = (TextMessage)durable.receive();
assertEquals("k", tm.getText());
-
Message m = durable.receive(1000);
assertNull(m);
}
@@ -134,18 +152,8 @@
*
* Test with a different topic (a redeployed topic is a different topic).
*/
- public void testDurableSubscriptionOnTopicRedeployment() throws Exception
- {
- try
+ public void testDurableSubscriptionOnNewTopic() throws Exception
{
- ic.lookup("/topic/CompletelyNewTopic");
- fail("should throw exception, topic shouldn't be deployed on the \
server");
- }
- catch(NamingException e)
- {
- // OK
- }
-
ServerManagement.deployTopic("CompletelyNewTopic");
ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
@@ -164,27 +172,15 @@
conn.close();
- ServerManagement.undeployTopic("CompletelyNewTopic");
-
- try
- {
- topic = (Topic)ic.lookup("/topic/CompletelyNewTopic");
- fail("should throw exception");
- }
- catch(NamingException e)
- {
- // OK
- }
-
- ServerManagement.deployTopic("CompletelyNewTopic");
+ ServerManagement.deployTopic("CompletelyNewTopic2");
- topic = (Topic)ic.lookup("/topic/CompletelyNewTopic");
+ Topic topic2 = (Topic)ic.lookup("/topic/CompletelyNewTopic2");
conn = cf.createConnection();
conn.setClientID("brookeburke");
s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- MessageConsumer durable = s.createDurableSubscriber(topic, "monicabelucci");
+ MessageConsumer durable = s.createDurableSubscriber(topic2, \
"monicabelucci");
conn.start();
@@ -192,6 +188,7 @@
assertNull(m);
ServerManagement.undeployTopic("CompletelyNewTopic");
+ ServerManagement.undeployTopic("CompletelyNewTopic2");
}
/**
@@ -336,11 +333,17 @@
}
}
- public void testDurableSubscriptionCleanup() throws Exception
+ /**
+ * Topic undeployment/redeployment has an activation/deactivation semantic, so \
undeploying a + * topic for which there are durable subscriptions preserves the \
content of those durable + * subscriptions, which can be then access upon topic \
redeployment. + * @throws Exception
+ */
+ public void testDurableSubscriptionOnTopicRedeployment() throws Exception
{
try
{
- ic.lookup("/topic/AnotherCompletelyNewTopic");
+ ic.lookup("/topic/TopicToBeRedeployed");
fail("should throw exception, topic shouldn't be deployed on the \
server"); }
catch(NamingException e)
@@ -348,39 +351,98 @@
// OK
}
- ServerManagement.deployTopic("AnotherCompletelyNewTopic");
+ ServerManagement.deployTopic("TopicToBeRedeployed");
ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
- Topic topic = (Topic)ic.lookup("/topic/AnotherCompletelyNewTopic");
- Connection conn = cf.createConnection();
+ Topic topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
- conn.setClientID("blahblah");
+ Connection conn = cf.createConnection();
+ conn.setClientID("brookeburke");
Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
- s.createDurableSubscriber(topic, "ak47");
+ MessageProducer prod = s.createProducer(topic);
+ prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+ MessageConsumer ds = s.createDurableSubscriber(topic, "monicabelucci");
+ conn.start();
+
+ prod.send(s.createTextMessage("one"));
+ prod.send(s.createTextMessage("two"));
+
+ ServerManagement.undeployTopic("TopicToBeRedeployed");
+ log.debug("topic undeployed");
+
+ try
+ {
+ topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
+ fail("should throw exception");
+ }
+ catch(NamingException e)
+ {
+ // OK
+ }
+
+ TextMessage tm = (TextMessage)ds.receive();
+ assertEquals("one", tm.getText());
+ conn.close();
+
+ conn = cf.createConnection();
+ conn.setClientID("brookeburke");
+
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ try
+ {
+ s.createDurableSubscriber(topic, "monicabelucci");
+ fail("should throw exception");
+ }
+ catch(JMSException e)
+ {
+ // OK
+ }
+
+ ServerManagement.deployTopic("TopicToBeRedeployed");
+ log.debug("topic redeployed");
+
+ // since redeployment has an activation semantic, I expect to find the \
messages there +
+ topic = (Topic)ic.lookup("/topic/TopicToBeRedeployed");
+ ds = s.createDurableSubscriber(topic, "monicabelucci");
+ conn.start();
+
+ tm = (TextMessage)ds.receive();
+ assertEquals("two", tm.getText());
conn.close();
+ ServerManagement.undeployTopic("TopicToBeRedeployed");
+ }
- ObjectName dsson = ServerManagement.getDurableSubscriptionStoreObjectName();
+ public void testUnsubscribeDurableSubscription() throws Exception
+ {
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("ConnectionFactory");
+ Topic topic = (Topic)ic.lookup("/topic/Topic");
+
+ Connection conn = cf.createConnection();
+ conn.setClientID("ak47");
+
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ s.createDurableSubscriber(topic, "uzzi");
+ MessageProducer prod = s.createProducer(topic);
+ prod.setDeliveryMode(DeliveryMode.PERSISTENT);
- Set dsnames = (Set)ServerManagement.invoke(dsson, "listSubscriptions",
- new Object[] { "blahblah" },
- new String[] { \
"java.lang.String}"}); + prod.send(s.createTextMessage("one"));
- assertEquals(1, dsnames.size());
- assertEquals("ak47", dsnames.iterator().next());
+ log.debug("unsubscribing ...");
- ServerManagement.undeployTopic("AnotherCompletelyNewTopic");
+ s.unsubscribe("uzzi");
- // the durable subscription should be cleared from memory
+ log.debug("resubscribing ...");
- dsson = ServerManagement.getDurableSubscriptionStoreObjectName();
+ MessageConsumer ds = s.createDurableSubscriber(topic, "uzzi");
+ conn.start();
- dsnames = (Set)ServerManagement.invoke(dsson, "listSubscriptions",
- new Object[] { "blahblah" },
- new String[] { "java.lang.String}"});
+ assertNull(ds.receive(1000));
- assertTrue(dsnames.isEmpty());
+ conn.close();
}
}
1.78 +33 -13 \
jboss-jms/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MessageConsumerTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-jms/tests/src/org/jboss/test/messaging/jms/MessageConsumerTest.java,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -b -r1.77 -r1.78
--- MessageConsumerTest.java 25 Jan 2006 16:57:08 -0000 1.77
+++ MessageConsumerTest.java 31 Jan 2006 23:37:18 -0000 1.78
@@ -65,9 +65,9 @@
/**
* @author <a href="mailto:ovidiu@jboss.org">Ovidiu Feodorov</a>
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
- * @version <tt>$Revision: 1.77 $</tt>
+ * @version <tt>$Revision: 1.78 $</tt>
*
- * $Id: MessageConsumerTest.java,v 1.77 2006/01/25 16:57:08 ovidiu Exp $
+ * $Id: MessageConsumerTest.java,v 1.78 2006/01/31 23:37:18 ovidiu Exp $
*/
public class MessageConsumerTest extends MessagingTestCase
{
@@ -2332,18 +2332,23 @@
Connection conn5 = null;
Connection conn6 = null;
+ Session sess1 = null;
+ Session sess3 = null;
+ Session sess4 = null;
+ Session sess6 = null;
+
try
{
- //Create a durable subscriber on one connection and close it
+ // Create a durable subscriber on one connection and close it
conn1 = cf.createConnection();
conn1.setClientID(CLIENT_ID1);
- Session sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ sess1 = conn1.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer durable = sess1.createDurableSubscriber(topic, \
"mySubscription"); conn1.close();
- //Send some messages on another connection and close it
+ // Send some messages on another connection and close it
conn2 = cf.createConnection();
conn2.setClientID(CLIENT_ID1);
Session sess2 = conn2.createSession(false, Session.AUTO_ACKNOWLEDGE);
@@ -2357,11 +2362,11 @@
}
conn2.close();
- //Receive the messages on another connection
+ // Receive the messages on another connection
conn3 = cf.createConnection();
conn3.setClientID(CLIENT_ID1);
conn3.start();
- Session sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ sess3 = conn3.createSession(false, Session.AUTO_ACKNOWLEDGE);
durable = sess3.createDurableSubscriber(topic, "mySubscription");
int count = 0;
while (true)
@@ -2377,37 +2382,42 @@
assertEquals(NUM_MESSAGES, count);
conn3.close();
- //Try and receive them again
+ // Try and receive them again
conn4 = cf.createConnection();
conn4.setClientID(CLIENT_ID1);
conn4.start();
- Session sess4 = conn4.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ sess4 = conn4.createSession(false, Session.AUTO_ACKNOWLEDGE);
durable = sess4.createDurableSubscriber(topic, "mySubscription");
TextMessage tm = (TextMessage)durable.receive(1000);
assertNull(tm);
conn4.close();
- //Send some more messages and unsubscribe
+ // Send some more messages and unsubscribe
conn5 = cf.createConnection();
conn5.setClientID(CLIENT_ID1);
conn5.start();
Session sess5 = conn5.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer prod5 = sess5.createProducer(topic);
prod5.setDeliveryMode(DeliveryMode.PERSISTENT);
+
+ log.debug("sending.1 " + NUM_MESSAGES + " messages");
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm2 = sess5.createTextMessage("hello");
prod5.send(topic, tm2);
}
+
+ log.debug("unsubscribing mySubscription");
sess5.unsubscribe("mySubscription");
+ log.debug("unsubscribing done");
conn5.close();
- //Resubscribe with the same name
+ // Resubscribe with the same name
conn6 = cf.createConnection();
conn6.setClientID(CLIENT_ID1);
conn6.start();
- Session sess6 = conn6.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ sess6 = conn6.createSession(false, Session.AUTO_ACKNOWLEDGE);
durable = sess6.createDurableSubscriber(topic, "mySubscription");
TextMessage tm3 = (TextMessage)durable.receive(1000);
@@ -2435,6 +2445,10 @@
{
conn5.close();
}
+ if (sess6 != null)
+ {
+ sess6.unsubscribe("mySubscription");
+ }
if (conn6 != null)
{
conn6.close();
@@ -2463,13 +2477,17 @@
prod.setDeliveryMode(DeliveryMode.PERSISTENT);
+ log.debug("creating durable subscription");
MessageConsumer durable = sess1.createDurableSubscriber(topic, \
"mySubscription"); + log.debug("durable subscription created");
conn1.start();
final int NUM_MESSAGES = 2;
+ log.debug("sending messages ...");
+
for (int i = 0; i < NUM_MESSAGES; i++)
{
TextMessage tm = sess1.createTextMessage("hello");
@@ -2478,6 +2496,8 @@
final int NUM_TO_RECEIVE = NUM_MESSAGES - 1;
+ log.debug("receiving messages ...");
+
for (int i = 0; i < NUM_TO_RECEIVE; i++)
{
TextMessage tm = (TextMessage)durable.receive(3000);
@@ -2496,7 +2516,7 @@
// Re-subscribe to the subscription
- log.trace("Resubscribing");
+ log.trace("resubscribing");
MessageConsumer durable2 = sess2.createDurableSubscriber(topic, \
"mySubscription");
1.13 +2 -2 \
jboss-jms/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: PersistenceTest.java
===================================================================
RCS file: /cvsroot/jboss/jboss-jms/tests/src/org/jboss/test/messaging/jms/PersistenceTest.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- PersistenceTest.java 31 Jan 2006 04:36:04 -0000 1.12
+++ PersistenceTest.java 31 Jan 2006 23:37:18 -0000 1.13
@@ -39,7 +39,7 @@
/**
* @author <a href="mailto:tim.fox@jboss.com">Tim Fox</a>
*
- * $Id: PersistenceTest.java,v 1.12 2006/01/31 04:36:04 ovidiu Exp $
+ * $Id: PersistenceTest.java,v 1.13 2006/01/31 23:37:18 ovidiu Exp $
*/
public class PersistenceTest extends MessagingTestCase
{
@@ -363,7 +363,7 @@
}
/*
- * Test durable subscription state survives a restart
+ * Test durable subscription state survives a server crash
*/
public void testDurableSubscriptionPersistence_1() throws Exception
{
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic