[jboss-cvs] JBossAS SVN: r89301 - in projects/bootstrap/trunk: impl-as/src/test/java/org/jboss/bootstrap/impl/as/server and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri May 22 16:08:02 EDT 2009
Author: ALRubinger
Date: 2009-05-22 16:08:02 -0400 (Fri, 22 May 2009)
New Revision: 89301
Added:
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java
Modified:
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServer.java
Log:
[JBBOOT-79] Add some temporary support for JBossASServer.isStarted
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java 2009-05-22 19:41:02 UTC (rev 89300)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java 2009-05-22 20:08:02 UTC (rev 89301)
@@ -53,13 +53,7 @@
* @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
* @version $Revision: $
*/
- at ManagementObject(
- name="jboss.system:type=MCServer",
- isRuntime=true,
- properties=ManagementProperties.EXPLICIT,
- description="the MCServer bootstrap view",
- componentType=@ManagementComponent(type="MCBean", subtype="*")
- )
+ at ManagementObject(name = "jboss.system:type=MCServer", isRuntime = true, properties = ManagementProperties.EXPLICIT, description = "the MCServer bootstrap view", componentType = @ManagementComponent(type = "MCBean", subtype = "*"))
public class JBossASServerImpl extends AbstractMCServerBase<JBossASServer, JBossASServerConfig>
implements
JBossASServer
@@ -269,6 +263,20 @@
return this.metadata;
}
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.as.server.JBossASServer#isStarted()
+ */
+ /*
+ * JBBOOT-80 Remove this when jboss-bootstrap is for AS6 only (no
+ * more AS5.x support)
+ */
+ @Deprecated
+ public boolean isStarted()
+ {
+ final LifecycleState state = this.getState();
+ return state.equals(LifecycleState.STARTED);
+ }
+
//-------------------------------------------------------------------------------||
// Overridden Implementations ---------------------------------------------------||
//-------------------------------------------------------------------------------||
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerOperationsTestCase.java 2009-05-22 20:08:02 UTC (rev 89301)
@@ -0,0 +1,121 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, 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.bootstrap.impl.as.server;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.impl.as.common.TestUtils;
+import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
+import org.jboss.bootstrap.spi.as.server.JBossASServer;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * JBossASServerOperationsTestCase
+ *
+ * Tests operations specific to the JBossASServer
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASServerOperationsTestCase
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASServerOperationsTestCase.class);
+
+ //-------------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Server which, for each test, will be newly-created
+ * and initialized from a default configuration
+ */
+ private JBossASServer server;
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @Before
+ public void createServerAndSetJbossHome() throws Throwable
+ {
+ // Create a server that skips real start/stop
+ this.server = new NoOpJBossASServer();
+
+ // Get the configuration
+ final JBossASServerConfig configuration = this.server.getConfiguration();
+
+ // Set some JBOSS_HOME explicitly so the tests are reproducible
+ // (environment properties cannot be mutated via the test env, and we need
+ // to be sure no $JBOSS_HOME default is picked up)
+ configuration.jbossHome(TestUtils.getJBossHome());
+
+ // Log
+ log.info("Created: " + this.server);
+ }
+
+ @After
+ public void resetServer()
+ {
+ this.server = null;
+ log.info("Cleaned up server to null");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that "isStarted" returns true when the server is started, and false otherwise
+ *
+ * JBBOOT-79
+ *
+ * This test may be removed when JBBOOT-80 is completed.
+ */
+ @Test
+ public void testIsStarted() throws Throwable
+ {
+ // Log
+ log.info("testIsStarted");
+
+ // Test not started
+ final boolean startedBefore = server.isStarted();
+ TestCase.assertFalse("Server should not report as started before it has been", startedBefore);
+
+ // Start
+ server.start();
+
+ // Test started
+ final boolean startedAfter = server.isStarted();
+ TestCase.assertTrue("Server should report as started after start lifecycle has been called", startedAfter);
+
+ // Shutdown
+ server.shutdown();
+ }
+}
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java 2009-05-22 19:41:02 UTC (rev 89300)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java 2009-05-22 20:08:02 UTC (rev 89301)
@@ -51,10 +51,7 @@
*/
public NoOpJBossASServer()
{
- super();
- this.setConfigInitializer(null);
- this.setServerInitializer(null);
- this.setValidator(null);
+ this(false);
}
/**
Modified: projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServer.java
===================================================================
--- projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServer.java 2009-05-22 19:41:02 UTC (rev 89300)
+++ projects/bootstrap/trunk/spi-as/src/main/java/org/jboss/bootstrap/spi/as/server/JBossASServer.java 2009-05-22 20:08:02 UTC (rev 89301)
@@ -27,6 +27,7 @@
import org.jboss.bootstrap.spi.as.config.JBossASServerConfig;
import org.jboss.bootstrap.spi.mc.server.MCBasedServer;
+import org.jboss.bootstrap.spi.server.Server;
/**
* JBossASServer
@@ -77,4 +78,16 @@
* @return A possibly empty map of configuration metadata
*/
Map<String, Object> getMetaData();
+
+ /**
+ * Returns whether or not the server is started.
+ *
+ * JBBOOT-80
+ * @return
+ * @deprecated Should be removed when we won't be targeting
+ * jboss-bootstrap for AS 5.x anymore. AS6 will not support
+ * this invocation, instead we should use {@link Server#getState()}
+ */
+ @Deprecated
+ boolean isStarted();
}
More information about the jboss-cvs-commits
mailing list