[jboss-cvs] JBossAS SVN: r79013 - in projects/server-manager/trunk: src/test/java/org/jboss/jbossas/servermanager/test and 13 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 2 05:29:21 EDT 2008
Author: ALRubinger
Date: 2008-10-02 05:29:20 -0400 (Thu, 02 Oct 2008)
New Revision: 79013
Added:
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/common/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/common/AsLifecycleDelegate.java
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorld.java
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorldMBean.java
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/unit/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/unit/JmxInvocationTest.java
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/startstop/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/startstop/unit/
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/startstop/unit/StartStopTest.java
projects/server-manager/trunk/src/test/resources/org/
projects/server-manager/trunk/src/test/resources/org/jboss/
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/META-INF/
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/META-INF/helloworld-service.xml
projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/jmxinvocation-assembly.xml
Removed:
projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/StartStopTest.java
Modified:
projects/server-manager/trunk/pom.xml
Log:
[JBASM-13] Add Unit Test for JMX Invocations, move all JBASM tests to "integration-test" phase
Modified: projects/server-manager/trunk/pom.xml
===================================================================
--- projects/server-manager/trunk/pom.xml 2008-10-02 08:53:48 UTC (rev 79012)
+++ projects/server-manager/trunk/pom.xml 2008-10-02 09:29:20 UTC (rev 79013)
@@ -41,8 +41,72 @@
</properties>
<!-- Build Configuration -->
- <build />
+ <build>
+
+ <plugins>
+
+ <!--
+
+ Configure Surefire to skip in
+ favor of running in integration-test phase
+
+ -->
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ <redirectTestOutputToFile>true</redirectTestOutputToFile>
+ <printSummary>true</printSummary>
+ </configuration>
+ <executions>
+ <execution>
+ <id>surefire-it</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <skip>false</skip>
+ <!-- Include jbossall-client.jar on the CP -->
+ <additionalClasspathElements>
+ <additionalClasspathElement>
+ ${JBOSS_HOME}/client/jbossall-client.jar
+ </additionalClasspathElement>
+ </additionalClasspathElements>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Assembly Plugin (JMX Invocation Test SAR) -->
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <version>2.2-beta-1</version>
+ <executions>
+ <execution>
+ <id>make-assembly</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attached</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <descriptors>
+ <descriptor>
+ src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/jmxinvocation-assembly.xml
+ </descriptor>
+ </descriptors>
+ <attach>true</attach>
+ </configuration>
+ <inherited>false</inherited>
+ </plugin>
+
+ </plugins>
+
+ </build>
+
<!-- Dependencies -->
<dependencies>
Deleted: 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 2008-10-02 08:53:48 UTC (rev 79012)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/StartStopTest.java 2008-10-02 09:29:20 UTC (rev 79013)
@@ -1,194 +0,0 @@
-/*
- * 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.AfterClass;
-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 JBossASs
- *
- * @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);
- }
-
- /**
- * Lifecycle Stop
- *
- * Stops JBossAS
- *
- * @throws Throwable
- */
- @AfterClass
- public static void afterClass() throws Throwable
- {
- // Obtain the server
- ServerManager manager = getServerManager();
- Server server = manager.getServer(SERVER_NAME);
-
- // If started/running
- if (ServerController.isServerStarted(server))
- {
- // Stop
- ServerController.stopServer(server, manager);
- }
- }
-
- //----------------------------------------------------------------------------------||
- // 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;
- }
-
-}
Added: projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/common/AsLifecycleDelegate.java
===================================================================
--- projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/common/AsLifecycleDelegate.java (rev 0)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/common/AsLifecycleDelegate.java 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,137 @@
+/*
+ * 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.common;
+
+import org.jboss.jbossas.servermanager.Server;
+import org.jboss.jbossas.servermanager.ServerController;
+import org.jboss.jbossas.servermanager.ServerManager;
+
+/**
+ * AsLifecycleDelegate
+ *
+ * Support for starting/stopping AS Instances in testing
+ *
+ * @author <a href="mailto:alr at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class AsLifecycleDelegate
+{
+
+ /*
+ * 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
+ */
+ public static final String SERVER_NAME_DEFAULT = "default";
+
+ private ServerManager serverManager;
+
+ /**
+ * Constructor
+ */
+ public AsLifecycleDelegate()
+ {
+ // Create and set a new ServerManager
+ this.setServerManager(new ServerManager());
+ }
+
+ /**
+ * Lifecycle Start
+ *
+ * Starts JBossASs
+ *
+ * @throws Throwable
+ */
+ public void startJbossAs(String serverName) throws Throwable
+ {
+ // Get ServerManager
+ ServerManager manager = this.getServerManager();
+
+ // Set JVM / JBOSS_HOME
+ manager.setJavaHome(getJavaHome());
+ manager.setJbossHome(getJbossHome());
+
+ // Create the Server
+ Server server = new Server();
+ server.setName(serverName);
+
+ // Add a Server to the Manager
+ manager.addServer(server);
+
+ // Start the Server
+ ServerController.startServer(server, manager);
+ }
+
+ /**
+ * Lifecycle Stop
+ *
+ * Stops JBossAS
+ *
+ * @throws Throwable
+ */
+ public void stopJbossAs(String serverName) throws Throwable
+ {
+ // Obtain the server
+ ServerManager manager = this.getServerManager();
+ Server server = manager.getServer(serverName);
+
+ // If started/running
+ if (ServerController.isServerStarted(server))
+ {
+ // Stop
+ ServerController.stopServer(server, manager);
+ }
+ }
+
+ //----------------------------------------------------------------------------------||
+ // Internal Helper Methods ---------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ public static String getJavaHome()
+ {
+ return System.getenv(ENV_VAR_JAVA_HOME);
+ }
+
+ public static String getJbossHome()
+ {
+ return System.getenv(ENV_VAR_JBOSS_HOME);
+ }
+
+ public ServerManager getServerManager()
+ {
+ return serverManager;
+ }
+
+ private void setServerManager(ServerManager manager)
+ {
+ this.serverManager = manager;
+ }
+}
Added: projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorld.java
===================================================================
--- projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorld.java (rev 0)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorld.java 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,45 @@
+/*
+ * 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.jmxinvocation;
+
+/**
+ * HelloWorld
+ *
+ * Implementation of the Hellow World test MBean
+ *
+ * @author <a href="mailto:alr at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class HelloWorld implements HelloWorldMBean
+{
+
+ /**
+ * Returns the contract-defined return value
+ *
+ * @return
+ */
+ public String sayHello()
+ {
+ return HelloWorldMBean.RETURN_VALUE;
+ }
+
+}
Added: projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorldMBean.java
===================================================================
--- projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorldMBean.java (rev 0)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/HelloWorldMBean.java 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,25 @@
+package org.jboss.jbossas.servermanager.test.jmxinvocation;
+
+/**
+ * HelloWorldMBean
+ *
+ * An interface defining a contract for a simple
+ * "Hello World" test service
+ *
+ * @author <a href="mailto:alr at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface HelloWorldMBean
+{
+ /**
+ * The value to be returned by the test method
+ */
+ String RETURN_VALUE = "Hello World";
+
+ /**
+ * Returns the contract-defined return value
+ *
+ * @return
+ */
+ String sayHello();
+}
Added: projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/unit/JmxInvocationTest.java
===================================================================
--- projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/unit/JmxInvocationTest.java (rev 0)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/jmxinvocation/unit/JmxInvocationTest.java 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,199 @@
+/*
+ * 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.jmxinvocation.unit;
+
+import java.io.File;
+
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+import org.jboss.jbossas.servermanager.Server;
+import org.jboss.jbossas.servermanager.ServerController;
+import org.jboss.jbossas.servermanager.ServerManager;
+import org.jboss.jbossas.servermanager.test.common.AsLifecycleDelegate;
+import org.jboss.jbossas.servermanager.test.jmxinvocation.HelloWorldMBean;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JmxInvocationTest
+ *
+ * Tests that generic invocations over the JMX Bus
+ * succeed
+ *
+ * @author <a href="mailto:alr at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JmxInvocationTest
+{
+ //----------------------------------------------------------------------------------||
+ // Class Members -------------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ public static final String SERVER_NAME = AsLifecycleDelegate.SERVER_NAME_DEFAULT;
+
+ public static final String INVOCATION_OBJECT_NAME = "org.jboss.jbossas.servermanager.test.jmxinvocation:service=HelloWorld";
+
+ public static final String INVOCATION_METHOD_NAME = "sayHello";
+
+ /**
+ * Name of the system property denoting the base directory..
+ *
+ * HACK! This binds the Test to Maven
+ */
+ private static final String SYSTEM_PROP_NAME_BASEDIR = "basedir";
+
+ private static final String FILENAME_JMXINVOCATION_TEST = "jmxinvocation";
+
+ /**
+ * AS Lifecycle (Start/Stop) Delegate
+ */
+ private static AsLifecycleDelegate delegate;
+
+ //----------------------------------------------------------------------------------||
+ // Tests ---------------------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ /**
+ * Deploys a test SAR into the running AS instance and invokes upon it,
+ * testing for expected result
+ */
+ @Test
+ public void testJmxInvocation() throws Exception
+ {
+ // Get the Server
+ Server server = getDelegate().getServerManager().getServer(SERVER_NAME);
+
+ /*
+ * Deploy the test SAR into the Server
+ */
+
+ // Construct the deployable path name
+ //TODO This whole section is Hacky as Maven doesn't let you define
+ // an explicit name for your assembly, so we search for the right file by name
+ String baseDirName = this.getBaseDirName();
+ File buildDir = new File(baseDirName + "/target");
+ assert (buildDir != null && buildDir.exists() && buildDir.isDirectory()) : baseDirName
+ + " must be a valid directory";
+ File[] files = buildDir.listFiles();
+ File deployable = null;
+ // For each file in the build directory
+ for (File file : files)
+ {
+ // Look for the deployable one we want by name
+ if (file.getName().contains(FILENAME_JMXINVOCATION_TEST))
+ {
+ deployable = file;
+ }
+ }
+ assert deployable != null : "Deployable file could not be found";
+
+ // Deploy
+ server.deploy(deployable);
+
+ /*
+ * Invoke upon the Server
+ */
+
+ // Construct the ObjectName
+ ObjectName name = new ObjectName(INVOCATION_OBJECT_NAME);
+
+ // Invoke
+ Object result = server.invoke(name, INVOCATION_METHOD_NAME, new Object[]
+ {}, new String[]
+ {});
+
+ /*
+ * Test the invocation result
+ */
+ TestCase.assertNotNull(result);
+ TestCase.assertEquals(HelloWorldMBean.RETURN_VALUE, result);
+ }
+
+ //----------------------------------------------------------------------------------||
+ // LifeCycle Methods ---------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ /**
+ * Lifecycle Start
+ *
+ * Starts JBossAS
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+ getDelegate().startJbossAs(SERVER_NAME);
+ }
+
+ /**
+ * Lifecycle Stop
+ *
+ * Stops JBossAS
+ *
+ * @throws Throwable
+ */
+ @AfterClass
+ public static void afterClass() throws Throwable
+ {
+ // Obtain the server
+ ServerManager manager = delegate.getServerManager();
+ Server server = manager.getServer(SERVER_NAME);
+
+ // If started/running
+ if (ServerController.isServerStarted(server))
+ {
+ getDelegate().stopJbossAs(SERVER_NAME);
+ }
+ }
+
+ //----------------------------------------------------------------------------------||
+ // Internal Helper Methods ---------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ private synchronized static AsLifecycleDelegate getDelegate()
+ {
+ if (delegate == null)
+ {
+ delegate = new AsLifecycleDelegate();
+ }
+ return delegate;
+ }
+
+ private String getBaseDirName()
+ {
+ return this.getSystemProperty(SYSTEM_PROP_NAME_BASEDIR);
+ }
+
+ private String getSystemProperty(String property)
+ {
+ String baseDir = System.getProperty(property);
+ assert baseDir != null && baseDir.length() > 0 : "System property \"" + property
+ + "\" must be specified for this test to complete normally - "
+ + "it is populated by Maven automatically in mvn environments";
+ return baseDir;
+ }
+
+}
Added: projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/startstop/unit/StartStopTest.java
===================================================================
--- projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/startstop/unit/StartStopTest.java (rev 0)
+++ projects/server-manager/trunk/src/test/java/org/jboss/jbossas/servermanager/test/startstop/unit/StartStopTest.java 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,159 @@
+/*
+ * 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.startstop.unit;
+
+import junit.framework.TestCase;
+
+import org.jboss.jbossas.servermanager.Server;
+import org.jboss.jbossas.servermanager.ServerController;
+import org.jboss.jbossas.servermanager.ServerManager;
+import org.jboss.jbossas.servermanager.test.common.AsLifecycleDelegate;
+import org.junit.AfterClass;
+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:alr at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class StartStopTest
+{
+
+ //----------------------------------------------------------------------------------||
+ // Class Members -------------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ public static final String SERVER_NAME = AsLifecycleDelegate.SERVER_NAME_DEFAULT;
+
+ /**
+ * AS Lifecycle (Start/Stop) Delegate
+ */
+ private static AsLifecycleDelegate delegate;
+
+ //----------------------------------------------------------------------------------||
+ // 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 = getDelegate().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 = getDelegate().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 Methods ---------------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ /**
+ * Lifecycle Start
+ *
+ * Starts JBossAS
+ *
+ * @throws Throwable
+ */
+ @BeforeClass
+ public static void beforeClass() throws Throwable
+ {
+
+ getDelegate().startJbossAs(SERVER_NAME);
+
+ }
+
+ /**
+ * Lifecycle Stop
+ *
+ * Stops JBossAS
+ *
+ * @throws Throwable
+ */
+ @AfterClass
+ public static void afterClass() throws Throwable
+ {
+ // Obtain the server
+ ServerManager manager = delegate.getServerManager();
+ Server server = manager.getServer(SERVER_NAME);
+
+ // If started/running
+ if (ServerController.isServerStarted(server))
+ {
+ getDelegate().stopJbossAs(SERVER_NAME);
+ }
+ }
+
+ //----------------------------------------------------------------------------------||
+ // Internal Helper Methods ---------------------------------------------------------||
+ //----------------------------------------------------------------------------------||
+
+ private synchronized static AsLifecycleDelegate getDelegate()
+ {
+ if (delegate == null)
+ {
+ delegate = new AsLifecycleDelegate();
+ }
+ return delegate;
+ }
+
+}
Added: projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/META-INF/helloworld-service.xml
===================================================================
--- projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/META-INF/helloworld-service.xml (rev 0)
+++ projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/META-INF/helloworld-service.xml 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,9 @@
+<!--
+
+ Descriptor for the "HelloWorld" test MBean
+
+-->
+
+<mbean
+ code="org.jboss.jbossas.servermanager.test.jmxinvocation.HelloWorld"
+ name="org.jboss.jbossas.servermanager.test.jmxinvocation:service=HelloWorld" />
\ No newline at end of file
Added: projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/jmxinvocation-assembly.xml
===================================================================
--- projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/jmxinvocation-assembly.xml (rev 0)
+++ projects/server-manager/trunk/src/test/resources/org/jboss/jbossas/servermanager/test/jmxinvocation/jmxinvocation-assembly.xml 2008-10-02 09:29:20 UTC (rev 79013)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ vi:ts=2:sw=2:expandtab:
+-->
+<assembly xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.0.0.xsd">
+ <id>jmxinvocation-test</id>
+ <formats>
+ <format>jar</format>
+ </formats>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <fileSets>
+ <fileSet>
+ <directory>target/test-classes</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>org/jboss/jbossas/servermanager/test/jmxinvocation/*.class</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>target/test-classes/org/jboss/jbossas/servermanager/test/jmxinvocation</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>META-INF/*</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list