[jboss-cvs] JBoss Messaging SVN: r1792 - trunk/tests/src/org/jboss/test/messaging/util
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Dec 14 05:50:20 EST 2006
Author: ovidiu.feodorov at jboss.com
Date: 2006-12-14 05:50:19 -0500 (Thu, 14 Dec 2006)
New Revision: 1792
Added:
trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java
Log:
added an usage example for spawning new remote test servers
Added: trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java 2006-12-14 10:47:31 UTC (rev 1791)
+++ trunk/tests/src/org/jboss/test/messaging/util/ServerManagementTest.java 2006-12-14 10:50:19 UTC (rev 1792)
@@ -0,0 +1,127 @@
+/**
+ * JBoss, Home of Professional Open Source
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.test.messaging.util;
+
+import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.tools.ServerManagement;
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import javax.management.ObjectName;
+
+/**
+ * @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version <tt>$Revision$</tt>
+ *
+ * $Id$
+ */
+public class ServerManagementTest extends MessagingTestCase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ public ServerManagementTest(String name)
+ {
+ super(name);
+ }
+
+ // Public --------------------------------------------------------
+
+ public void testFailureToSpawnStartedServer() throws Exception
+ {
+ try
+ {
+ ServerManagement.start("all", 0);
+
+ try
+ {
+ ServerManagement.spawn(0);
+ fail("It should have failed!");
+ }
+ catch(Exception e)
+ {
+ // OK
+ }
+ }
+ finally
+ {
+ ServerManagement.stop(0);
+ }
+ }
+
+ public void testFailureToSpawnExistingRemoteServer() throws Exception
+ {
+ if (ServerManagement.isLocal())
+ {
+ // irrelevant for a colocated configuration
+ return;
+ }
+
+ // this assumes that the remote server 0 has been started externally by and or by a script
+
+ try
+ {
+ ServerManagement.spawn(0);
+ fail("This should have failed!");
+ }
+ catch(Exception e)
+ {
+ // OK
+ }
+ }
+
+ public void testSimpleSpawn() throws Exception
+ {
+ try
+ {
+ ServerManagement.spawn(7);
+
+ ServerManagement.start("all", 7);
+
+ Integer index = (Integer)ServerManagement.
+ getAttribute(7, new ObjectName("jboss.messaging:service=ServerPeer"), "serverPeerID");
+
+ assertEquals(7, index.intValue());
+
+ InitialContext ic = new InitialContext(ServerManagement.getJNDIEnvironment(7));
+
+ ic.bind("/xxx", "yyy");
+
+ assertEquals("yyy", ic.lookup("/xxx"));
+ }
+ finally
+ {
+ ServerManagement.kill(7);
+ }
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ log.debug("setup done");
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
More information about the jboss-cvs-commits
mailing list