[jboss-cvs] JBossAS SVN: r76539 - in projects/server-manager/trunk: src/test/java and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 31 18:08:32 EDT 2008
Author: ALRubinger
Date: 2008-07-31 18:08:32 -0400 (Thu, 31 Jul 2008)
New Revision: 76539
Added:
projects/server-manager/trunk/src/test/java/org/
projects/server-manager/trunk/src/test/java/org/jboss/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/StartStopTest.java
Modified:
projects/server-manager/trunk/pom.xml
Log:
[JBASM-9] Add tests to start/stop AS
Modified: projects/server-manager/trunk/pom.xml
===================================================================
--- projects/server-manager/trunk/pom.xml 2008-07-31 22:00:07 UTC (rev 76538)
+++ projects/server-manager/trunk/pom.xml 2008-07-31 22:08:32 UTC (rev 76539)
@@ -32,4 +32,13 @@
<!-- Build Configuration -->
<build />
+ <!-- Dependencies -->
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ </dependency>
+ </dependencies>
+
</project>
\ No newline at end of file
Added: projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/StartStopTest.java
===================================================================
--- projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/StartStopTest.java (rev 0)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/StartStopTest.java 2008-07-31 22:08:32 UTC (rev 76539)
@@ -0,0 +1,171 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jbossas.servermanager.test;
+
+import junit.framework.TestCase;
+
+import org.jboss.jbossas.servermanager.Server;
+import org.jboss.jbossas.servermanager.ServerController;
+import org.jboss.jbossas.servermanager.ServerManager;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * StartStopTest
+ *
+ * Simple tests to check that the server may be started and stopped,
+ * and further that the ServerController may query as to the state
+ * of AS
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class StartStopTest
+{
+
+ //----------------------------------------------------------------------------------||
+ // Class Members -------------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ /*
+ * Environment Variables
+ */
+
+ private static final String ENV_VAR_JAVA_HOME = "JAVA_HOME";
+
+ private static final String ENV_VAR_JBOSS_HOME = "JBOSS_HOME";
+
+ /**
+ * The Configuration Name to use
+ *
+ * For this, "default" will suffice as we're only testing the
+ * start/stop of AS, not its full complement
+ */
+ private static final String SERVER_NAME = "default";
+
+ /**
+ * The ServerManager for all Servers used in testing
+ */
+ private static ServerManager serverManager;
+
+ //----------------------------------------------------------------------------------||
+ // Tests ---------------------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ /**
+ * Tests that the server has successfully started, and that
+ * the ServerController can properly query its state
+ */
+ @Test
+ public void testStart() throws Throwable
+ {
+ // Obtain the server
+ ServerManager manager = getServerManager();
+ Server server = manager.getServer(SERVER_NAME);
+
+ // Ensure we read that it's up
+ TestCase.assertTrue("The server has not been started.", ServerController.isServerStarted(server));
+ }
+
+ /**
+ * Tests a full roundtrip of started > stopped > restarted,
+ * with proper state queries along the way
+ *
+ * @throws Throwable
+ */
+ @Test
+ public void testRestart() throws Throwable
+ {
+ // Obtain the server
+ ServerManager manager = getServerManager();
+ Server server = manager.getServer(SERVER_NAME);
+
+ // Ensure we read that it's up
+ TestCase.assertTrue("The server has not been started.", ServerController.isServerStarted(server));
+
+ // Bring the server down
+ ServerController.stopServer(server, manager);
+
+ // Ensure we read it's down
+ TestCase.assertTrue("The server should have been shutdown", !ServerController.isServerStarted(server));
+
+ // Restart
+ ServerController.startServer(server, manager);
+
+ // Ensure we read that it's up
+ TestCase.assertTrue("The server has not been restarted.", ServerController.isServerStarted(server));
+ }
+
+ /**
+ * Lifecycle Start
+ *
+ * Starts the JBossAS "all" Configuration
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+ // Create ServerManager
+ ServerManager serverManager = new ServerManager();
+ setServerManager(serverManager);
+
+ // Set JVM / JBOSS_HOME
+ serverManager.setJavaHome(getJavaHome());
+ serverManager.setJbossHome(getJbossHome());
+
+ // Create the Server
+ Server server = new Server();
+ server.setName(SERVER_NAME);
+
+ // Add a Server to the Manager
+ serverManager.addServer(server);
+
+ // Start the Server
+ ServerController.startServer(server, serverManager);
+ }
+
+ //----------------------------------------------------------------------------------||
+ // Internal Helper Methods ---------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ protected static String getJavaHome()
+ {
+ return System.getenv(ENV_VAR_JAVA_HOME);
+ }
+
+ protected static String getJbossHome()
+ {
+ return System.getenv(ENV_VAR_JBOSS_HOME);
+ }
+
+ private static ServerManager getServerManager()
+ {
+ return serverManager;
+ }
+
+ private static void setServerManager(ServerManager serverManager)
+ {
+ StartStopTest.serverManager = serverManager;
+ }
+
+}
More information about the jboss-cvs-commits
mailing list