[hornetq-commits] JBoss hornetq SVN: r10963 - in branches/Branch_2_2_EAP: tests/src/org/hornetq/tests/integration/client and 1 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Fri Jul 8 13:28:42 EDT 2011


Author: clebert.suconic at jboss.com
Date: 2011-07-08 13:28:41 -0400 (Fri, 08 Jul 2011)
New Revision: 10963

Added:
   branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
Modified:
   branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
   branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java
Log:
HORNETQ-735 - fixing HTML counter

Modified: branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java
===================================================================
--- branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2011-07-08 11:10:17 UTC (rev 10962)
+++ branches/Branch_2_2_EAP/src/main/org/hornetq/core/server/impl/HornetQServerImpl.java	2011-07-08 17:28:41 UTC (rev 10963)
@@ -72,6 +72,7 @@
 import org.hornetq.core.postoffice.Binding;
 import org.hornetq.core.postoffice.DuplicateIDCache;
 import org.hornetq.core.postoffice.PostOffice;
+import org.hornetq.core.postoffice.QueueBinding;
 import org.hornetq.core.postoffice.impl.DivertBinding;
 import org.hornetq.core.postoffice.impl.LocalQueueBinding;
 import org.hornetq.core.postoffice.impl.PostOfficeImpl;
@@ -1694,13 +1695,13 @@
                              final boolean temporary,
                              final boolean ignoreIfExists) throws Exception
    {
-      Binding binding = postOffice.getBinding(queueName);
+      QueueBinding binding = (QueueBinding)postOffice.getBinding(queueName);
 
       if (binding != null)
       {
          if (ignoreIfExists)
          {
-            return null;
+            return binding.getQueue();
          }
          else
          {

Added: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java	                        (rev 0)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/integration/client/JMSMessageCounterTest.java	2011-07-08 17:28:41 UTC (rev 10963)
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied.  See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+package org.hornetq.tests.integration.client;
+
+import javax.jms.Connection;
+import javax.jms.MessageProducer;
+import javax.jms.Queue;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.hornetq.api.core.SimpleString;
+import org.hornetq.api.core.management.ResourceNames;
+import org.hornetq.api.jms.management.JMSQueueControl;
+import org.hornetq.core.logging.Logger;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ * @author <a href="mailto:clebert.suconic at jboss.org">Clebert Suconic</a>
+ */
+public class JMSMessageCounterTest extends JMSTestBase
+{
+   private static final Logger log = Logger.getLogger(JMSMessageCounterTest.class);
+
+   private final SimpleString QUEUE = new SimpleString("ConsumerTestQueue");
+   
+   
+
+   protected boolean usePersistence()
+   {
+      return true;
+   }
+
+
+
+   public void testMessageCounter() throws Exception
+   {
+
+      Connection conn = cf.createConnection();
+      Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      Queue queue = createQueue(true, "Test");
+      
+      MessageProducer producer = sess.createProducer(queue);
+
+      final int numMessages = 100;
+
+      for (int i = 0; i < numMessages; i++)
+      {
+         TextMessage mess = sess.createTextMessage("msg" + i);
+         producer.send(mess);
+      }
+      
+      conn.close();
+      
+      JMSQueueControl control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+      assertNotNull(control);
+      
+      System.out.println(control.listMessageCounterAsHTML());
+      
+      jmsServer.stop();
+      
+      restartServer();
+      
+      control = (JMSQueueControl)server.getManagementService().getResource(ResourceNames.JMS_QUEUE + queue.getQueueName());
+      assertNotNull(control);
+      
+      System.out.println(control.listMessageCounterAsHTML());
+
+
+   }
+
+}

Modified: branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java
===================================================================
--- branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java	2011-07-08 11:10:17 UTC (rev 10962)
+++ branches/Branch_2_2_EAP/tests/src/org/hornetq/tests/util/JMSTestBase.java	2011-07-08 17:28:41 UTC (rev 10963)
@@ -89,14 +89,28 @@
     */
    protected Queue createQueue(final String name) throws Exception, NamingException
    {
-      jmsServer.createQueue(false, name, null, true, "/jms/" + name);
+      return createQueue(false, name);
+   }
 
+   protected Topic createTopic(final String name) throws Exception, NamingException
+   {
+      return createTopic(false, name);
+   }
+
+   /**
+    * @throws Exception
+    * @throws NamingException
+    */
+   protected Queue createQueue(final boolean storeConfig, final String name) throws Exception, NamingException
+   {
+      jmsServer.createQueue(storeConfig, name, null, true, "/jms/" + name);
+
       return (Queue)context.lookup("/jms/" + name);
    }
 
-   protected Topic createTopic(final String name) throws Exception, NamingException
+   protected Topic createTopic(final boolean storeConfig, final String name) throws Exception, NamingException
    {
-      jmsServer.createTopic(false, name, "/jms/" + name);
+      jmsServer.createTopic(storeConfig, name, "/jms/" + name);
 
       return (Topic)context.lookup("/jms/" + name);
    }
@@ -136,10 +150,10 @@
 
    protected void restartServer() throws Exception
    {
+      context = new InVMContext();
+      jmsServer.setContext(context);
       jmsServer.start();
       jmsServer.activated();
-      context = new InVMContext();
-      jmsServer.setContext(context);
       registerConnectionFactory();
    }
 



More information about the hornetq-commits mailing list