From do-not-reply at jboss.org Mon Jun 21 08:15:34 2010 Content-Type: multipart/mixed; boundary="===============0163904592723044102==" MIME-Version: 1.0 From: do-not-reply at jboss.org To: hornetq-commits at lists.jboss.org Subject: [hornetq-commits] JBoss hornetq SVN: r9347 - trunk/tests/src/org/hornetq/tests/integration/jms/server/management. Date: Mon, 21 Jun 2010 08:15:34 -0400 Message-ID: <201006211215.o5LCFYmY018307@svn01.web.mwc.hst.phx2.redhat.com> --===============0163904592723044102== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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/JMSS= erverControlRestartTest.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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMS= ServerControlRestartTest.java (rev 0) +++ trunk/tests/src/org/hornetq/tests/integration/jms/server/management/JMS= ServerControlRestartTest.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.JMSJournalStorageManagerIm= pl; +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 Jeff Mesnil + * + * + */ +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 =3D RandomUtil.randomString(); + String binding =3D RandomUtil.randomString(); + + UnitTestCase.checkNoBinding(context, binding); + checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queu= eName)); + + JMSServerControl control =3D ManagementControlHelper.createJMSServer= Control(mbeanServer); + control.createQueue(queueName, binding); + + Object o =3D UnitTestCase.checkBinding(context, binding); + Assert.assertTrue(o instanceof Queue); + Queue queue =3D (Queue)o; + assertEquals(queueName, queue.getQueueName()); + checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueN= ame)); + + serverManager.stop(); + + checkNoBinding(context, binding); + checkNoResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queu= eName)); + + serverManager.start(); + + o =3D UnitTestCase.checkBinding(context, binding); + Assert.assertTrue(o instanceof Queue); + queue =3D (Queue)o; + assertEquals(queueName, queue.getQueueName()); + checkResource(ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queueN= ame)); + } + + // Package protected --------------------------------------------- + + // Protected ----------------------------------------------------- + + @Override + protected void setUp() throws Exception + { + super.setUp(); + + Configuration conf =3D new ConfigurationImpl(); + conf.setSecurityEnabled(false); + conf.setJMXManagementEnabled(true); + conf.getAcceptorConfigurations().add(new TransportConfiguration(InVM= AcceptorFactory.class.getName())); + server =3D HornetQServers.newHornetQServer(conf, mbeanServer, false); + + context =3D new InVMContext(); + = + JMSStorageManager storage =3D new JMSJournalStorageManagerImpl(new T= imeAndCounterIDGenerator(), + server.getConfiguration(), + server.getReplicationMana= ger()); + = + serverManager =3D new JMSServerManagerImpl(server, null, storage); + serverManager.setContext(context); + serverManager.start(); + serverManager.activated(); + } + + @Override + protected void tearDown() throws Exception + { + serverManager.stop(); + + server.stop(); + + serverManager =3D null; + + server =3D null; + + super.tearDown(); + } + + // Private ------------------------------------------------------- + + // Inner classes ------------------------------------------------- + +} --===============0163904592723044102==--