[hornetq-commits] JBoss hornetq SVN: r9347 - trunk/tests/src/org/hornetq/tests/integration/jms/server/management.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Jun 21 08:15:34 EDT 2010


Author: jmesnil
Date: 2010-06-21 08:15:34 -0400 (Mon, 21 Jun 2010)
New Revision: 9347

Added:
   trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlRestartTest.java
Log:
JMS queue creation with JMX and server restart

* add test to create a durable queue with JMX, restart the server and check the JMS queue is still there

Added: trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlRestartTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlRestartTest.java	                        (rev 0)
+++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMSServerControlRestartTest.java	2010-06-21 12:15:34 UTC (rev 9347)
@@ -0,0 +1,140 @@
+/*
+ * Copyright 2010 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.jms.server.management;
+
+import javax.jms.Queue;
+
+import junit.framework.Assert;
+
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.core.management.ObjectNameBuilder;
+import org.hornetq.api.jms.management.JMSServerControl;
+import org.hornetq.core.config.Configuration;
+import org.hornetq.core.config.impl.ConfigurationImpl;
+import org.hornetq.core.remoting.impl.invm.InVMAcceptorFactory;
+import org.hornetq.core.server.HornetQServer;
+import org.hornetq.core.server.HornetQServers;
+import org.hornetq.jms.persistence.JMSStorageManager;
+import org.hornetq.jms.persistence.impl.journal.JMSJournalStorageManagerImpl;
+import org.hornetq.jms.server.impl.JMSServerManagerImpl;
+import org.hornetq.tests.integration.management.ManagementControlHelper;
+import org.hornetq.tests.integration.management.ManagementTestBase;
+import org.hornetq.tests.unit.util.InVMContext;
+import org.hornetq.tests.util.RandomUtil;
+import org.hornetq.tests.util.UnitTestCase;
+import org.hornetq.utils.TimeAndCounterIDGenerator;
+
+/**
+ * A JMSServerControlRestartTest
+ *
+ * @author <a href="mailto:jmesnil at redhat.com">Jeff Mesnil</a>
+ *
+ *
+ */
+public class JMSServerControlRestartTest extends ManagementTestBase
+{
+
+   // Constants -----------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   protected InVMContext context;
+
+   private HornetQServer server;
+
+   private JMSServerManagerImpl serverManager;
+
+   // Static --------------------------------------------------------
+
+   // Constructors --------------------------------------------------
+
+   // Public --------------------------------------------------------
+
+   public void testCreateDurableQueueAndRestartServer() throws Exception
+   {
+      String queueName = RandomUtil.randomString();
+      String binding = RandomUtil.randomString();
+
+      UnitTestCase.checkNoBinding(context, binding);
+      checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+      JMSServerControl control = ManagementControlHelper.createJMSServerControl(mbeanServer);
+      control.createQueue(queueName, binding);
+
+      Object o = UnitTestCase.checkBinding(context, binding);
+      Assert.assertTrue(o instanceof Queue);
+      Queue queue = (Queue)o;
+      assertEquals(queueName, queue.getQueueName());
+      checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+      serverManager.stop();
+
+      checkNoBinding(context, binding);
+      checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+
+      serverManager.start();
+
+      o = UnitTestCase.checkBinding(context, binding);
+      Assert.assertTrue(o instanceof Queue);
+      queue = (Queue)o;
+      assertEquals(queueName, queue.getQueueName());
+      checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueName));
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   @Override
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      Configuration conf = new ConfigurationImpl();
+      conf.setSecurityEnabled(false);
+      conf.setJMXManagementEnabled(true);
+      conf.getAcceptorConfigurations().add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
+      server = HornetQServers.newHornetQServer(conf, mbeanServer, false);
+
+      context = new InVMContext();
+      
+      JMSStorageManager storage = new JMSJournalStorageManagerImpl(new TimeAndCounterIDGenerator(),
+                                                 server.getConfiguration(),
+                                                 server.getReplicationManager());
+      
+      serverManager = new JMSServerManagerImpl(server, null, storage);
+      serverManager.setContext(context);
+      serverManager.start();
+      serverManager.activated();
+   }
+
+   @Override
+   protected void tearDown() throws Exception
+   {
+      serverManager.stop();
+
+      server.stop();
+
+      serverManager = null;
+
+      server = null;
+
+      super.tearDown();
+   }
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}



More information about the hornetq-commits mailing list