[rhmessaging-commits] rhmessaging commits: r4140 - store/trunk/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Jul 21 11:55:07 EDT 2010


Author: rgemmell
Date: 2010-07-21 11:55:06 -0400 (Wed, 21 Jul 2010)
New Revision: 4140

Modified:
   store/trunk/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java
Log:
Update selector durability test to check message count instead of using a consumer which could recreate the selector


Modified: store/trunk/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java
===================================================================
--- store/trunk/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java	2010-07-21 14:12:55 UTC (rev 4139)
+++ store/trunk/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBUpgradeTest.java	2010-07-21 15:55:06 UTC (rev 4140)
@@ -72,8 +72,8 @@
     @Override
     public void setUp() throws Exception
     {
-        assertNotNull("QPID_WORK must be set", System.getProperty("QPID_WORK"));
-        assertNotNull("QPID_HOME must be set", System.getProperty("QPID_WORK"));
+        assertNotNull("QPID_WORK must be set", QPID_WORK_ORIG);
+        assertNotNull("QPID_HOME must be set", QPID_HOME);
 
         if(! isExternalBroker())
         {
@@ -135,28 +135,54 @@
 
     /**
      * Test that the selector applied to the DurableSubscription was successfully
-     * transfered to the new store, and functions as expected with continued use.
+     * transfered to the new store, and functions as expected with continued use
+     * by monitoring message count while sending new messages to the topic.
      */
     public void testSelectorDurability() throws Exception
     {
-        // Create a connection and start it
-        TopicConnection connection = (TopicConnection) getConnection();
-        connection.start();
+        JMXTestUtils jmxUtils = null;
+        try
+        {
+            jmxUtils = new JMXTestUtils(this, "guest", "guest");
+            jmxUtils.open();
+        }
+        catch (Exception e)
+        {
+            fail("Unable to establish JMX connection, test cannot proceed");
+        }
 
-        // Drain the subscription of existing messages
-        consumeDurableSubscriptionMessages(connection);
+        try
+        {
+            ManagedQueue dursubQueue = jmxUtils.getManagedQueue("clientid" + "-" + SUB_NAME);
+            assertEquals("DurableSubscription backing queue should have 1 message on it initially", 
+                          new Integer(1), dursubQueue.getMessageCount());
+            
+            // Create a connection and start it
+            TopicConnection connection = (TopicConnection) getConnection();
+            connection.start();
+            
+            // Send messages which don't match and do match the selector, checking message count
+            TopicSession pubSession = connection.createTopicSession(true, org.apache.qpid.jms.Session.SESSION_TRANSACTED);
+            Topic topic = pubSession.createTopic(TOPIC_NAME);
+            TopicPublisher publisher = pubSession.createPublisher(topic);
+            
+            BDBStoreUpgradeTestPreparer.publishMessages(pubSession, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "false");
+            pubSession.commit();
+            assertEquals("DurableSubscription backing queue should still have 1 message on it", 
+                        new Integer(1), dursubQueue.getMessageCount());
+            
+            BDBStoreUpgradeTestPreparer.publishMessages(pubSession, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "true");
+            pubSession.commit();
+            assertEquals("DurableSubscription backing queue should now have 2 messages on it", 
+                        new Integer(2), dursubQueue.getMessageCount());
 
-        // Send messages which don't match and do match the selector 
-        TopicSession pubSession = connection.createTopicSession(true, org.apache.qpid.jms.Session.SESSION_TRANSACTED);
-        Topic topic = pubSession.createTopic(TOPIC_NAME);
-        TopicPublisher publisher = pubSession.createPublisher(topic);
-        BDBStoreUpgradeTestPreparer.publishMessages(pubSession, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "false");
-        BDBStoreUpgradeTestPreparer.publishMessages(pubSession, publisher, topic, DeliveryMode.PERSISTENT, 1*1024, 1, "true");
-        pubSession.commit();
-        pubSession.close();
-
-        // Verify the matching message is received correctly
-        consumeDurableSubscriptionMessages(connection);
+            dursubQueue.clearQueue();
+            pubSession.close();
+        }
+        finally
+        {
+            jmxUtils.close();
+        }
     }
 
     /**



More information about the rhmessaging-commits mailing list