[jboss-cvs] JBossAS SVN: r87701 - in projects/bootstrap/trunk/impl-as/src: main/java/org/jboss/bootstrap/impl/as/server and 17 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Apr 22 23:57:28 EDT 2009
Author: ALRubinger
Date: 2009-04-22 23:57:27 -0400 (Wed, 22 Apr 2009)
New Revision: 87701
Added:
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/bin/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/client/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/common/lib/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/lib/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/conf/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/data/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deploy/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deployers/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/lib/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/log/work/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/tmp/EMPTY
projects/bootstrap/trunk/impl-as/src/test/resources/org/
projects/bootstrap/trunk/impl-as/src/test/resources/org/jboss/
projects/bootstrap/trunk/impl-as/src/test/resources/org/jboss/version.properties
Modified:
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java
projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java
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/JBossASServerInitializer.java
projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java
Log:
[JBBOOT-31] impl-as work on config validator, server init, config init, and tests to match. Ported Version information into server from legacy.
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/BasicJBossASServerConfig.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -23,6 +23,7 @@
package org.jboss.bootstrap.impl.as.config;
import org.jboss.bootstrap.impl.base.config.AbstractBasicServerConfig;
+import org.jboss.logging.Logger;
/**
* BasicJBossASServerConfig
@@ -36,7 +37,12 @@
implements
JBossASServerConfig
{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+ private static final Logger log = Logger.getLogger(BasicJBossASServerConfig.class);
+
//-------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -100,7 +106,7 @@
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.config.JBossASServerConfig#jbossHome(java.lang.String)
*/
- public JBossASServerConfig jbossHome(final String jbossHome)
+ public JBossASServerConfig jbossHome(final String jbossHome) throws IllegalArgumentException
{
// Set
this.jbossHome = jbossHome;
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializer.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -49,7 +49,7 @@
* Default address which will be set
* if {@link JBossASServerConfig#getBindAddress()} or
* system or configuration property
- * {@link JBossASServerConfig#PROP_KEY_BIND_ADDRESS}
+ * {@link JBossASServerConfig#PROP_KEY_JBOSSAS_BIND_ADDRESS}
* is not defined
*/
String DEFAULT_VALUE_BIND_ADDRESS = "127.0.0.1";
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializerImpl.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -76,12 +76,13 @@
// $JBOSS_HOME
final String pwd = FILE_PRESENT_WORKING_DIRECTORY.getAbsolutePath();
- final String jbossHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSS_HOME,
- JBossASServerConfig.ENV_VAR_JBOSS_HOME, config.getJBossHome(), pwd, configProps);
+ final String currentJBossHome = config.getJBossHome() != null ? config.getJBossHome() : null;
+ final String jbossHome = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME,
+ JBossASServerConfig.ENV_VAR_JBOSSAS_HOME, currentJBossHome, pwd, configProps);
config.jbossHome(jbossHome);
// ${jboss.bind.address}
- final String bindAddress = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_BIND_ADDRESS, config
+ final String bindAddress = this.resolvePropertyValue(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS, config
.getBindAddress(), JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS, configProps);
config.bindAddress(bindAddress);
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidator.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -25,6 +25,7 @@
import org.jboss.bootstrap.impl.base.config.AbstractBasicConfigurationValidator;
import org.jboss.bootstrap.spi.config.ConfigurationValidator;
import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.logging.Logger;
/**
* JBossASConfigurationValidator
@@ -40,6 +41,12 @@
{
//-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASConfigurationValidator.class);
+
+ //-------------------------------------------------------------------------------||
// Overridden Implementations ---------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -49,29 +56,49 @@
@Override
public void validate(JBossASServerConfig config) throws InvalidConfigurationException
{
- // Validate the generic configuration
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Validating Configuration: " + config + " ...");
+ }
+
+ // Validate the super configuration
super.validate(config);
/*
- * Impl-specific
+ * The following properties must be specified
*/
- /*
- * Rules for JBOSS_HOME:
- * 1) Set from environment variable "JBOSS_HOME" if present
- * 2) Set from system property "jboss.home" (overrides environment variable)
- * if present
- * 3) Use config if present
- * 4) Throw InvalidConfigurationException
- */
+ // jboss.home
+ this.require(config.getJBossHome(), JBossASServerConfig.PROP_KEY_JBOSSAS_HOME);
+ // jboss.bind.address
+ this.require(config.getBindAddress(), JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS);
+ // jboss.server.name
+ this.require(config.getServerName(), JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME);
- // Ensure JBOSS_HOME
- // String jbossHome = config.getJBossHome();
- // if(jbossHome)
+ // Log
+ log.debug("Configuration is valid: " + config);
}
//-------------------------------------------------------------------------------||
// Internal Helper Methods ------------------------------------------------------||
//-------------------------------------------------------------------------------||
+ /**
+ * Requires that the specified argument is both non-null and
+ * non-empty.
+ *
+ * @throws InvalidConfigurationException If the specified argument is
+ * either null or empty
+ */
+ private void require(final String arg, final String propertyName) throws InvalidConfigurationException
+ {
+ // If not specified
+ if (arg == null || arg.length() == 0)
+ {
+ // Tell 'em about it
+ throw new InvalidConfigurationException(propertyName + " must be specified");
+ }
+ }
+
}
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/config/JBossASServerConfig.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -42,7 +42,7 @@
* Constant that holds the name of the system or
* configuration property
*/
- String PROP_KEY_BIND_ADDRESS = "jboss.bind.address";
+ String PROP_KEY_JBOSSAS_BIND_ADDRESS = "jboss.bind.address";
/**
* Constant that holds the name of the system or configuration
@@ -56,14 +56,14 @@
* variable which specifies the root of the AS
* installation
*/
- String ENV_VAR_JBOSS_HOME = "JBOSS_HOME";
+ String ENV_VAR_JBOSSAS_HOME = "JBOSS_HOME";
/**
* Constant that holds the name of the system or configuration
* property which specifies the root of the AS
* installation
*/
- String PROP_KEY_JBOSS_HOME = "jboss.home";
+ String PROP_KEY_JBOSSAS_HOME = "jboss.home";
/**
* Constant that holds the name of the system property
@@ -74,8 +74,6 @@
/**
* Constant that holds the name of the system property
* which specifies the home URL for JBossAS.
- *
- * <p>If not set then the value of HOME_DIR will converted into a URL.
*/
String PROP_KEY_JBOSSAS_HOME_URL = "jboss.home.url";
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServer.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -48,7 +48,7 @@
/** @return The server start date */
Date getStartDate();
- /** @return The server version */
+ /** @return The server version, the underlying version expressed as a String */
String getVersion();
/** @return The server version code name */
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-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerImpl.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -31,6 +31,7 @@
import org.jboss.bootstrap.impl.as.config.JBossASServerConfig;
import org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase;
import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.managed.api.annotation.ManagementProperty;
/**
* JBossASServerImpl
@@ -74,12 +75,40 @@
}
//-------------------------------------------------------------------------------||
- // Constructor ------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
//-------------------------------------------------------------------------------||
+ /**
+ * Container for version information.
+ */
+ private final Version version = Version.getInstance();
+
/**
+ * The date in which the server was started
+ */
+ private Date startDate;
+
+ //-------------------------------------------------------------------------------||
+ // Constructors -----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
* Constructor
*
+ * Constructs a new JBossAS Server using a new default configuration,
+ * which will be automatically created and set
+ *
+ * @param config
+ */
+ public JBossASServerImpl() throws IllegalArgumentException
+ {
+ // Use other ctor
+ this(null);
+ }
+
+ /**
+ * Constructor
+ *
* Constructs a new JBossAS Server with the specified underlying configuration
*
* @param config
@@ -96,9 +125,9 @@
}
//-------------------------------------------------------------------------------||
- // Required Implement--ations ---------------------------------------------------||
+ // Required Implementations -----------------------------------------------------||
//-------------------------------------------------------------------------------||
-
+
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.base.server.AbstractServer#getDefaultServerConfigClass()
*/
@@ -108,151 +137,153 @@
return BasicJBossASServerConfig.class;
}
- //-------------------------------------------------------------------------------||
- // Overridden Implementations ---------------------------------------------------||
- //-------------------------------------------------------------------------------||
-
- /*
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * EVERYTHING BELOW THIS LINE IS TODO
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- */
-
/* (non-Javadoc)
- * @see org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase#doShutdown()
- */
- @Override
- protected void doShutdown() throws Exception
- {
- // TODO Auto-generated method stub
- super.doShutdown();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase#doStart()
- */
- @Override
- protected void doStart() throws Exception
- {
- // TODO Auto-generated method stub
- super.doStart();
- }
-
- /* (non-Javadoc)
- * @see org.jboss.bootstrap.spi.server.AbstractServer#start()
- */
- @Override
- public void start() throws IllegalStateException, Exception
- {
- // TODO Auto-generated method stub
- super.start();
-
- //TODO
- // // Send a notification that the startup is complete
- // KernelEventManager eventMgr = this.getKernel().getEventManager();
- // KernelEvent startEvent = new AbstractEvent(eventMgr, START_NOTIFICATION_TYPE, 0, System.currentTimeMillis(),
- // new Long(watch.getLapTime()));
- // eventMgr.fireKernelEvent(startEvent);
- }
-
- /* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildDate()
*/
+ @ManagementProperty(description = "The server build date")
public String getBuildDate()
{
- // TODO Auto-generated method stub
- return null;
+ return version.getBuildDate();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildID()
*/
+ @ManagementProperty(description = "The server build ID")
public String getBuildID()
{
- // TODO Auto-generated method stub
- return null;
+ return version.getBuildID();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildJVM()
*/
+ @ManagementProperty(description = "The server build JVM")
public String getBuildJVM()
{
- // TODO Auto-generated method stub
- return null;
+ return version.getBuildJVM();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildNumber()
*/
+ @ManagementProperty(description = "The server build number")
public String getBuildNumber()
{
- // TODO Auto-generated method stub
- return null;
+ return version.getBuildNumber();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getBuildOS()
*/
+ @ManagementProperty(description = "The server build OS")
public String getBuildOS()
{
- // TODO Auto-generated method stub
- return null;
+ return version.getBuildOS();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getStartDate()
*/
+ @ManagementProperty(description = "The server start time")
public Date getStartDate()
{
- // TODO Auto-generated method stub
- return null;
+ return startDate;
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getVersion()
*/
+ @ManagementProperty(description = "The server version string")
public String getVersion()
{
- // TODO Auto-generated method stub
- return null;
+ return version.toString();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getVersionName()
*/
+ @ManagementProperty(description = "The server version name")
public String getVersionName()
{
- // TODO Auto-generated method stub
- return null;
+ return version.getName();
}
/* (non-Javadoc)
* @see org.jboss.bootstrap.impl.as.server.JBossASServer#getVersionNumber()
*/
+ @ManagementProperty(description = "The server version number string")
public String getVersionNumber()
{
+ return version.getVersionNumber();
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+ /*
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ * EVERYTHING BELOW THIS LINE IS TODO
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ *
+ */
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase#doShutdown()
+ */
+ @Override
+ protected void doShutdown() throws Exception
+ {
// TODO Auto-generated method stub
- return null;
+ super.doShutdown();
}
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.mc.server.AbstractMCServerBase#doStart()
+ */
+ @Override
+ protected void doStart() throws Exception
+ {
+ // Call super
+ super.doStart();
+
+ // Mark the start date
+ this.startDate = new Date();
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.spi.server.AbstractServer#start()
+ */
+ @Override
+ public void start() throws IllegalStateException, Exception
+ {
+ // Call Super
+ super.start();
+
+ //TODO
+ // // Send a notification that the startup is complete
+ // KernelEventManager eventMgr = this.getKernel().getEventManager();
+ // KernelEvent startEvent = new AbstractEvent(eventMgr, START_NOTIFICATION_TYPE, 0, System.currentTimeMillis(),
+ // new Long(watch.getLapTime()));
+ // eventMgr.fireKernelEvent(startEvent);
+ }
+
}
Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializer.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -22,6 +22,10 @@
package org.jboss.bootstrap.impl.as.server;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+
import org.jboss.bootstrap.impl.as.config.JBossASServerConfig;
import org.jboss.bootstrap.impl.base.server.AbstractBasicServerInitializer;
import org.jboss.bootstrap.spi.server.Server;
@@ -56,7 +60,13 @@
public void initialize(Server<JBossASServer, JBossASServerConfig> server) throws IllegalArgumentException,
IllegalStateException
{
- // TODO Auto-generated method stub
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Initializing: " + this + " ...");
+ }
+
+ // Call super
super.initialize(server);
}
@@ -66,11 +76,35 @@
@Override
protected void setSystemProperties(JBossASServerConfig configuration)
{
- // Set
- //TODO
+ // Log
+ if (log.isTraceEnabled())
+ {
+ log.trace("Setting system properties for " + this + " ...");
+ }
- // Invoke super implementation
+ // Super
super.setSystemProperties(configuration);
+
+ // Get values to set
+ final String jbossHome = configuration.getJBossHome();
+ final File jbossHomeFile = new File(jbossHome);
+ final String jbossHomeDir = jbossHomeFile.getAbsolutePath();
+ URL jbossHomeUrl = null;
+ try
+ {
+ jbossHomeUrl = jbossHomeFile.toURI().toURL();
+ }
+ catch (MalformedURLException e)
+ {
+ // Ignore
+ }
+
+ // Set our system properties
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME, jbossHome);
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR, jbossHomeDir);
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL, jbossHomeUrl);
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS, configuration.getBindAddress());
+ this.setSystemProperty(JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME, configuration.getServerName());
}
}
Copied: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java (from rev 87648, projects/bootstrap/trunk/legacy/src/main/java/org/jboss/Version.java)
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -0,0 +1,306 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, 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 java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Provides access to JBoss version (and build) properties.
+ *
+ * @author <a href="mailto:jason at planet57.com">Jason Dillon</a>
+ * @author Scott.Stark at jboss.org
+ * @author <a href="mailto:dimitris at jboss.org">Dimitris Andreadis</a>
+ * @version $Revision: 63730 $
+ */
+public final class Version
+{
+ public final static String VERSION_MAJOR = "version.major";
+ public final static String VERSION_MINOR = "version.minor";
+ public final static String VERSION_REVISION = "version.revision";
+ public final static String VERSION_TAG = "version.tag";
+ public final static String VERSION_NAME = "version.name";
+ public final static String VERSION_CVSTAG = "version.cvstag";
+
+ public final static String BUILD_NUMBER = "build.number";
+ public final static String BUILD_ID = "build.id";
+ public final static String BUILD_DATE = "build.date";
+ public final static String BUILD_JVM_VERSION = "java.vm.version";
+ public final static String BUILD_JVM_VENDOR = "java.vendor";
+ public final static String BUILD_OS = "os.name";
+ public final static String BUILD_OS_ARCH = "os.arch";
+ public final static String BUILD_OS_VERSION = "os.version";
+
+ public static final char DELIMITER_VERSION = '.';
+
+ /**
+ * The single instance.
+ */
+ private static Version instance = null;
+
+ /**
+ * The version properties.
+ */
+ private Properties props;
+
+ /**
+ * Do not allow direct public construction.
+ */
+ private Version()
+ {
+ props = loadProperties();
+ }
+
+ /**
+ * Get the single <tt>Version</tt> instance.
+ *
+ * @return The single <tt>Version</tt> instance.
+ */
+ public static Version getInstance()
+ {
+ if (instance == null)
+ {
+ instance = new Version();
+ }
+ return instance;
+ }
+
+ /**
+ * Returns an unmodifiable map of version properties.
+ *
+ * @return An unmodifiable map of version properties.
+ */
+ public Map<Object, Object> getProperties()
+ {
+ return Collections.unmodifiableMap(props);
+ }
+
+ /**
+ * Returns the value for the given property name.
+ *
+ * @param name - The name of the property.
+ * @return The property value or null if the property is not set.
+ */
+ public String getProperty(final String name)
+ {
+ return props.getProperty(name);
+ }
+
+ /**
+ * Returns the major number of the version.
+ *
+ * @return The major number of the version.
+ */
+ public int getMajor()
+ {
+ return getIntProperty(VERSION_MAJOR);
+ }
+
+ /**
+ * Returns the minor number of the version.
+ *
+ * @return The minor number of the version.
+ */
+ public int getMinor()
+ {
+ return getIntProperty(VERSION_MINOR);
+ }
+
+ /**
+ * Returns the revision number of the version.
+ *
+ * @return The revision number of the version.
+ */
+ public int getRevision()
+ {
+ return getIntProperty(VERSION_REVISION);
+ }
+
+ /**
+ * Returns the tag of the version.
+ *
+ * @return The tag of the version.
+ */
+ public String getTag()
+ {
+ return props.getProperty(VERSION_TAG);
+ }
+ /**
+ * Returns the CVS tag of the version.
+ *
+ * @return The CVS tag of the version.
+ */
+ public String getCvsTag()
+ {
+ return props.getProperty(VERSION_CVSTAG);
+ }
+
+ /**
+ * Returns the name number of the version.
+ *
+ * @return The name of the version.
+ */
+ public String getName()
+ {
+ return props.getProperty(VERSION_NAME);
+ }
+
+ /**
+ * Returns the build identifier for this version.
+ *
+ * @return The build identifier for this version.
+ */
+ public String getBuildID()
+ {
+ return props.getProperty(BUILD_ID);
+ }
+
+ /**
+ * Returns the build number for this version.
+ *
+ * @return The build number for this version.
+ */
+ public String getBuildNumber()
+ {
+ return props.getProperty(BUILD_NUMBER);
+ }
+
+ /**
+ * Returns the build date for this version.
+ *
+ * @return The build date for this version.
+ */
+ public String getBuildDate()
+ {
+ return props.getProperty(BUILD_DATE);
+ }
+
+ /** Returns the BUILD_JVM_VERSION (BUILD_JVM_VENDOR) which should look like:
+ * 1.4.2_05-b04 (Sun Microsystems Inc.).
+ * @return the jvm
+ */
+ public String getBuildJVM()
+ {
+ String vm = props.getProperty(BUILD_JVM_VERSION);
+ String vendor = props.getProperty(BUILD_JVM_VENDOR);
+ return vm + '(' + vendor + ')';
+ }
+
+ /** Returns the BUILD_OS (BUILD_OS_ARCH,BUILD_OS_VERSION) which should look
+ * like:
+ * Windows XP (x86,5.1)
+ * Linux (i386,2.4.21-4.ELsmp)
+ * @return the OS
+ */
+ public String getBuildOS()
+ {
+ String os = props.getProperty(BUILD_OS);
+ String arch = props.getProperty(BUILD_OS_ARCH);
+ String version = props.getProperty(BUILD_OS_VERSION);
+ return os + '(' + arch +',' + version + ')';
+ }
+
+ /**
+ * Returns the full version number, e.g. 5.0.0.GA
+ *
+ * @return The full version number as string
+ */
+ public String getVersionNumber()
+ {
+ StringBuffer buff = new StringBuffer();
+
+ buff.append(getMajor()).append(DELIMITER_VERSION);
+ buff.append(getMinor()).append(DELIMITER_VERSION);
+ buff.append(getRevision()).append(DELIMITER_VERSION);
+ buff.append(getTag());
+
+ return buff.toString();
+ }
+
+ /**
+ * Returns the version information as a string.
+ *
+ * Must contain the version number by contract.
+ *
+ * @return Basic information as a string.
+ */
+ public String toString()
+ {
+ StringBuffer buff = new StringBuffer();
+
+ buff.append(getVersionNumber());
+ buff.append(" (build: SVNTag=");
+ buff.append(getCvsTag());
+ buff.append(" date=");
+ buff.append(getBuildID());
+ buff.append(")");
+
+ return buff.toString();
+ }
+
+ /**
+ * Returns a property value as an int.
+ *
+ * @param name - The name of the property.
+ * @return The property value, or -1 if there was a problem converting
+ * it to an int.
+ */
+ private int getIntProperty(final String name)
+ {
+ try
+ {
+ return Integer.valueOf(props.getProperty(name)).intValue();
+ }
+ catch (Exception e)
+ {
+ return -1;
+ }
+ }
+
+ /**
+ * Load the version properties from a resource.
+ */
+ private Properties loadProperties()
+ {
+ props = new Properties();
+
+ try
+ {
+ InputStream in =
+ Version.class.getResourceAsStream("/org/jboss/version.properties");
+ if( in != null )
+ {
+ props.load(in);
+ in.close();
+ }
+ }
+ catch (IOException e)
+ {
+ throw new Error("Missing version.properties");
+ }
+
+ return props;
+ }
+}
Property changes on: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java 2009-04-23 02:35:52 UTC (rev 87700)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationInitializationTestCase.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -22,6 +22,8 @@
package org.jboss.bootstrap.impl.as.config;
+import java.io.File;
+
import junit.framework.TestCase;
import org.jboss.logging.Logger;
@@ -55,6 +57,11 @@
*/
private static JBossASConfigurationInitializer initializer;
+ /**
+ * Denotes the present working directory
+ */
+ private static final File FILE_PWD = new File(".");
+
//-------------------------------------------------------------------------------||
// Instance Members -------------------------------------------------------------||
//-------------------------------------------------------------------------------||
@@ -101,6 +108,29 @@
//-------------------------------------------------------------------------------||
/**
+ * Ensures that when not explicitly set, the JBOSS_HOME
+ * is defaulted as expected
+ */
+ @Test
+ public void testJBossHomeDefaulted() throws Throwable
+ {
+ // Log
+ log.info("testJBossHomeDefaultsToPwd");
+
+ // Initialize the blank config
+ initializer.initialize(config);
+
+ // Get the expected value
+ final String expected = this.getDefaultJBossHome();
+
+ // Get the actual
+ final String actual = config.getJBossHome();
+
+ // Test
+ TestCase.assertEquals("JBOSS_HOME was not initialized to the proper default", expected, actual);
+ }
+
+ /**
* Ensures that jboss.bind.address defaults to loopback
* @throws Throwable
*/
@@ -146,4 +176,31 @@
TestCase.assertEquals("Server name was not defaulted as expected", expectedServerName, serverName);
}
+ //-------------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Obtains the default JBOSS_HOME value:
+ *
+ * 1) Environment Variable $JBOSS_HOME, or, if not set,
+ * 2) Present working directory
+ *
+ * There's nothing we can do to test the real default, as we cannot
+ * set environment variables from within this test.
+ */
+ private String getDefaultJBossHome()
+ {
+ String jbossHome = FILE_PWD.getAbsolutePath();
+ final String envVarJBossHomeName = JBossASServerConfig.ENV_VAR_JBOSSAS_HOME;
+ final String jbossHomeFromEnvVar = System.getenv(envVarJBossHomeName);
+ if (jbossHomeFromEnvVar != null)
+ {
+ log.warn("This test cannot account for true defaults of JBoss Home, unset environment variable "
+ + envVarJBossHomeName);
+ jbossHome = jbossHomeFromEnvVar;
+ }
+ return jbossHome;
+ }
+
}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/config/JBossASConfigurationValidationTestCase.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -0,0 +1,319 @@
+/*
+ * 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.config;
+
+import java.io.File;
+import java.net.URI;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.spi.config.ConfigurationValidator;
+import org.jboss.bootstrap.spi.config.InvalidConfigurationException;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JBossASConfigurationValidationTestCase
+ *
+ * Tests to ensure that the validation upon
+ * {@link JBossASServerConfig} instances is as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASConfigurationValidationTestCase
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASConfigurationValidationTestCase.class);
+
+ /**
+ * The location of JBoss Home relative to the home of this class
+ */
+ private static final String LOCATION_JBOSS_HOME = "jbossas";
+
+ /**
+ * The location of the bootstrap home, relative to JBoss Home
+ */
+ private static final String LOCATION_BOOTSTRAP_HOME = "server/all/conf";
+
+ /**
+ * Name of the bootstrap file
+ */
+ private static final String BOOTSTRAP_NAME = "bootstrap.xml";
+
+ /**
+ * Validator for the configurations
+ */
+ private static ConfigurationValidator<JBossASServerConfig> validator;
+
+ //-------------------------------------------------------------------------------||
+ // Instance Members -------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private JBossASServerConfig config;
+
+ //-------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Creates the validator before all tests are run
+ */
+ @BeforeClass
+ public static void initValidator()
+ {
+ validator = new JBossASConfigurationValidator();;
+ }
+
+ /**
+ * Creates a new, populated configuration before each test
+ */
+ @Before
+ public void initConfig() throws Throwable
+ {
+ this.config = this.createPopulatedConfig();
+ }
+
+ /**
+ * Clears the config between test runs
+ */
+ @After
+ public void clearConfig()
+ {
+ this.config = null;
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that the fully-populated config
+ * passes validation (a control test)
+ */
+ @Test
+ public void testControl()
+ {
+ // Log
+ log.info("testControl");
+
+ // Get config
+ final JBossASServerConfig config = this.config;
+
+ // Validate
+ try
+ {
+ validator.validate(config);
+
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ TestCase.fail("The control should pass, something is wrong in test setup"
+ + " where a populated config fails validation: " + ice.getMessage());
+ }
+ }
+
+ /**
+ * Ensures that an empty/null JBoss Home fails
+ */
+ @Test
+ public void testNoJBossHomeFails()
+ {
+ // Log
+ log.info("testNoJBossHomeFails");
+
+ // Initialize
+ boolean failed = false;
+
+ // Get config
+ final JBossASServerConfig config = this.config;
+
+ // Clear out
+ config.jbossHome(null);
+
+ // Validate
+ try
+ {
+ validator.validate(config);
+
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ failed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Validation on no JBOSS_HOME should have failed", failed);
+ }
+
+ /**
+ * Ensures that an empty/null Bind Address fails
+ */
+ @Test
+ public void testNoBindAddressFails()
+ {
+ // Log
+ log.info("testNoBindAddressFails");
+
+ // Initialize
+ boolean failed = false;
+
+ // Get config
+ final JBossASServerConfig config = this.config;
+
+ // Clear out
+ config.bindAddress(null);
+
+ // Validate
+ try
+ {
+ validator.validate(config);
+
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ failed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Validation on no bind address should have failed", failed);
+ }
+
+ /**
+ * Ensures that an empty/null Server Name fails
+ */
+ @Test
+ public void testNoServerNameFails()
+ {
+ // Log
+ log.info("testNoServerNameFails");
+
+ // Initialize
+ boolean failed = false;
+
+ // Get config
+ final JBossASServerConfig config = this.config;
+
+ // Clear out
+ config.serverName(null);
+
+ // Validate
+ try
+ {
+ validator.validate(config);
+
+ }
+ catch (InvalidConfigurationException ice)
+ {
+ failed = true;
+ }
+
+ // Test
+ TestCase.assertTrue("Validation on no server name should have failed", failed);
+ }
+
+ //-------------------------------------------------------------------------------||
+ // Internal Helper Methods ------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /**
+ * Creates a new configuration and fully populates it,
+ * returning the result
+ *
+ * @return A new, populated config
+ */
+ private JBossASServerConfig createPopulatedConfig() throws Throwable
+ {
+ // Create
+ final JBossASServerConfig config = new BasicJBossASServerConfig();
+
+ // Get properties
+ final String jbossHome = this.getJBossHome().getAbsolutePath();
+ final URL bootstrapHome = this.getBootstrapHome();
+ final String bootstrapName = BOOTSTRAP_NAME;
+ final String bindAddress = JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS;
+ final String serverName = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
+
+ // Populate
+ config.jbossHome(jbossHome).bootstrapHome(bootstrapHome).bootstrapName(bootstrapName).bindAddress(bindAddress)
+ .serverName(serverName);
+
+ // Return
+ return config;
+
+ }
+
+ /**
+ * Obtains a valid JBOSS_HOME
+ *
+ * @return
+ */
+ private File getJBossHome() throws Throwable
+ {
+ // Get the home
+ final URL homeUrl = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+ final URI homeUri = homeUrl.toURI();
+
+ // Make a file
+ final File homeFile = new File(homeUri);
+
+ // Construct JBOSS_HOME from the right location
+ final File jbossHomeFile = new File(homeFile, LOCATION_JBOSS_HOME);
+ if (!jbossHomeFile.exists())
+ {
+ TestCase.fail("JBOSS_HOME set to improper location, bad test setup: " + jbossHomeFile.getAbsolutePath());
+ }
+
+ // Return
+ return jbossHomeFile;
+ }
+
+ /**
+ * Obtains the Bootstrap Home
+ *
+ * @return
+ * @throws Throwable
+ */
+ private URL getBootstrapHome() throws Throwable
+ {
+ // Get JBOSS_HOME
+ final File jbossHome = this.getJBossHome();
+
+ // Build Bootstrap Home relative to JBOSS_HOME
+ final File bootstrapHome = new File(jbossHome, LOCATION_BOOTSTRAP_HOME);
+
+ // Convert to URL
+ final URL bootstrapHomeUrl = bootstrapHome.toURI().toURL();
+
+ // Return
+ return bootstrapHomeUrl;
+ }
+
+}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerInitializationTestCase.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -0,0 +1,227 @@
+/*
+ * 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 java.io.File;
+import java.net.URL;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.impl.as.config.JBossASConfigurationInitializer;
+import org.jboss.bootstrap.impl.as.config.JBossASServerConfig;
+import org.jboss.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * JBossASServerInitializationTestCase
+ *
+ * Ensures that the JBossAS Server initialization is correct
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASServerInitializationTestCase
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASServerInitializationTestCase.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 createAndInitServer() throws Throwable
+ {
+ // Create a server that skips real start/stop
+ this.server = new NoOpJBossASServer();
+
+ // Initialize via start (Though this is a no-op, so we won't *really* start anything)
+ server.start();
+
+ // Log
+ log.info("Created: " + this.server);
+ }
+
+ @After
+ public void resetServer()
+ {
+ this.server = null;
+ log.info("Cleaned up server to null");
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Ensures that when not explicitly set, the jboss.bind.address
+ * is defaulted as expected
+ */
+ @Test
+ public void testBindAddressDefaulted()
+ {
+ // Log
+ log.info("testBindAddressDefaults");
+
+ // Get an initialized server and config
+ final JBossASServer server = this.server;
+ final JBossASServerConfig configuration = server.getConfiguration();
+
+ // Get the expected value
+ final String expected = JBossASConfigurationInitializer.DEFAULT_VALUE_BIND_ADDRESS;
+
+ // Get the actual
+ final String actual = configuration.getBindAddress();
+
+ // Test
+ TestCase.assertEquals("Bind address was not initialized to the proper default", expected, actual);
+ }
+
+ /**
+ * Ensures that when not explicitly set, the jboss.server.name
+ * is defaulted as expected
+ */
+ @Test
+ public void testServerNameDefaulted()
+ {
+ // Log
+ log.info("testServerNameDefaulted");
+
+ // Get an initialized server and config
+ final JBossASServer server = this.server;
+ final JBossASServerConfig configuration = server.getConfiguration();
+
+ // Get the expected value
+ final String expected = JBossASConfigurationInitializer.DEFAULT_VALUE_SERVER_NAME;
+
+ // Get the actual
+ final String actual = configuration.getServerName();
+
+ // Test
+ TestCase.assertEquals("Server name was not initialized to the proper default", expected, actual);
+ }
+
+ /**
+ * Ensures that the properties backing the configuration are set
+ * both on the configuration itself and in the System props. Upon
+ * cleanup, these properties must be cleared.
+ *
+ * @throws Throwable
+ */
+ /**
+ * @throws Throwable
+ */
+ @Test
+ public void testPropertiesInInitializationLifecycle() throws Throwable
+ {
+
+ // Log
+ log.info("testPropertiesInInitializationLifecycle");
+
+ // Get an initialized server and config
+ final JBossASServer server = this.server;
+ final JBossASServerConfig configuration = server.getConfiguration();
+
+ // Define property keys
+ final String jbossHomePropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_HOME;
+ final String jbossHomeDirPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_DIR;
+ final String jbossHomeUrlPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_HOME_URL;
+ final String bindAddressPropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_BIND_ADDRESS;
+ final String serverNamePropKey = JBossASServerConfig.PROP_KEY_JBOSSAS_SERVER_NAME;
+
+ // Get Properties from Configuration
+ final Map<String, String> properties = configuration.getProperties();
+ final String jbossHomeFromConfProp = properties.get(jbossHomePropKey);
+ final String jbossHomeDirFromConfProp = properties.get(jbossHomeDirPropKey);
+ final String jbossHomeUrlFromConfProp = properties.get(jbossHomeUrlPropKey);
+ final String bindAddressFromConfProp = properties.get(bindAddressPropKey);
+ final String serverNameFromConfProp = properties.get(serverNamePropKey);
+
+ // Get Properties from System
+ final String jbossHomeFromSystem = System.getProperty(jbossHomePropKey);
+ final String jbossHomeDirFromSystem = System.getProperty(jbossHomeDirPropKey);
+ final String jbossHomeUrlFromSystem = System.getProperty(jbossHomeUrlPropKey);
+ final String bindAddressFromSystem = System.getProperty(bindAddressPropKey);
+ final String serverNameFromSystem = System.getProperty(serverNamePropKey);
+
+ // Get Expected Values
+ final String jbossHomeFromConf = configuration.getJBossHome();
+ final File jbossHomeFile = new File(jbossHomeFromConf);
+ final String jbossHomeDirFromConf = jbossHomeFile.getAbsolutePath();
+ final URL jbossHomeUrl = jbossHomeFile.toURI().toURL();
+ final String jbossHomeUrlFromConf = jbossHomeUrl.toExternalForm();
+ final String bindAddressFromConf = configuration.getBindAddress();
+ final String serverNameFromConf = configuration.getServerName();
+
+ // Ensure all equal
+ TestCase.assertEquals("JBoss Home in configuration must match the config property", jbossHomeFromConf,
+ jbossHomeFromConfProp);
+ TestCase.assertEquals("JBoss Home in configuration must match the system property", jbossHomeFromConf,
+ jbossHomeFromSystem);
+ TestCase.assertEquals("JBoss Home Dir in configuration must match the config property", jbossHomeDirFromConf,
+ jbossHomeDirFromConfProp);
+ TestCase.assertEquals("JBoss Home Dir in configuration must match the system property", jbossHomeDirFromConf,
+ jbossHomeDirFromSystem);
+
+ TestCase.assertEquals("JBoss Home URL in configuration must match the config property", jbossHomeUrlFromConf,
+ jbossHomeUrlFromConfProp);
+ TestCase.assertEquals("JBoss Home URL in configuration must match the system property", jbossHomeUrlFromConf,
+ jbossHomeUrlFromSystem);
+
+ TestCase.assertEquals("Bind Address in configuration must match the config property", bindAddressFromConf,
+ bindAddressFromConfProp);
+ TestCase.assertEquals("Bind Address in configuration must match the system property", bindAddressFromConf,
+ bindAddressFromSystem);
+ TestCase.assertEquals("Server name in configuration must match the config property", serverNameFromConf,
+ serverNameFromConfProp);
+ TestCase.assertEquals("Server name in configuration must match the system property", serverNameFromConf,
+ serverNameFromSystem);
+
+ // Cleanup
+ server.shutdown();
+
+ // Get Properties from System
+ final String jbossHomeFromSystemAfterCleanup = System.getProperty(jbossHomePropKey);
+
+ // Ensure all null
+ final String failMessage = "System property should be null after cleanup";
+ TestCase.assertNull(failMessage, jbossHomeFromSystemAfterCleanup);
+
+ }
+}
Added: projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -0,0 +1,251 @@
+/*
+ * 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.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * JBossASServerVersionInformationTestCase
+ *
+ * Tests to ensure that the server reports version information
+ * as expected
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossASServerVersionInformationTestCase
+{
+ //-------------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossASServerVersionInformationTestCase.class);
+
+ /**
+ * The server to test
+ */
+ private static JBossASServer server;
+
+ /*
+ * Test expected values; these must match the contents of the test
+ * version.properties under src/test/resources/org/jboss
+ */
+
+ private static final String EXPECTED_VERSION_MAJOR = "1";
+
+ private static final String EXPECTED_VERSION_MINOR = "2";
+
+ private static final String EXPECTED_VERSION_REVISION = "3";
+
+ private static final String EXPECTED_VERSION_TAG = "VersionTag";
+
+ private static final String EXPECTED_VERSION_NUMBER = EXPECTED_VERSION_MAJOR + Version.DELIMITER_VERSION
+ + EXPECTED_VERSION_MINOR + Version.DELIMITER_VERSION + EXPECTED_VERSION_REVISION + Version.DELIMITER_VERSION
+ + EXPECTED_VERSION_TAG;
+
+ private static final String EXPECTED_VERSION_NAME = "VersionName";
+
+ private static final String EXPECTED_BUILD_NUMBER = "BuildNumber";
+
+ private static final String EXPECTED_BUILD_VENDOR = "JavaVendor";
+
+ private static final String EXPECTED_BUILD_VERSION = "JavaVMVersion";
+
+ private static final String EXPECTED_BUILD_ID = "BuildID";
+
+ private static final String EXPECTED_BUILD_DATE = "BuildDate";
+
+ private static final String EXPECTED_OS_NAME = "OSName";
+
+ private static final String EXPECTED_OS_ARCH = "OSArch";
+
+ private static final String EXPECTED_OS_VERSION = "OSVersion";
+
+ //-------------------------------------------------------------------------------------||
+ // Lifecycle --------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ @BeforeClass
+ public static void createInitializer() throws Throwable
+ {
+ server = new JBossASServerImpl();
+ log.info("Created: " + server);
+ }
+
+ //-------------------------------------------------------------------------------------||
+ // Tests ------------------------------------------------------------------------------||
+ //-------------------------------------------------------------------------------------||
+
+ /**
+ * Asserts the server reports the
+ * version
+ */
+ @Test
+ public void testServerReportsVersion()
+ {
+ // Log
+ log.info("testServerReportsVersion");
+
+ // Get
+ final String version = server.getVersion();
+ log.info("Version: " + version);
+
+ // Test
+ TestCase.assertTrue("Version number not found within the version String", version
+ .contains(EXPECTED_VERSION_NUMBER));
+ }
+
+ /**
+ * Asserts the server reports the
+ * version number
+ */
+ @Test
+ public void testServerReportsVersionNumber()
+ {
+ // Log
+ log.info("testServerReportsVersionNumber");
+
+ // Get
+ final String versionNumber = server.getVersionNumber();
+ log.info("Version Number: " + versionNumber);
+
+ // Test
+ TestCase.assertEquals("Version number was not as expected", EXPECTED_VERSION_NUMBER, versionNumber);
+ }
+
+ /**
+ * Asserts the server reports the
+ * version name
+ */
+ @Test
+ public void testServerReportsVersionName()
+ {
+ // Log
+ log.info("testServerReportsVersionName");
+
+ // Get
+ final String versionName = server.getVersionName();
+ log.info("Version Name: " + versionName);
+
+ // Test
+ TestCase.assertEquals("Version name was not as expected", EXPECTED_VERSION_NAME, versionName);
+ }
+
+ /**
+ * Asserts the server reports the
+ * build number
+ */
+ @Test
+ public void testServerReportsBuildNumber()
+ {
+ // Log
+ log.info("testServerReportsBuildNumber");
+
+ // Get
+ final String buildNumber = server.getBuildNumber();
+ log.info("Build Number: " + buildNumber);
+
+ // Test
+ TestCase.assertEquals("Build Number was not as expected", EXPECTED_BUILD_NUMBER, buildNumber);
+ }
+
+ /**
+ * Asserts the server reports the
+ * build ID
+ */
+ @Test
+ public void testServerReportsBuildID()
+ {
+ // Log
+ log.info("testServerReportsBuildID");
+
+ // Get
+ final String actual = server.getBuildID();
+ log.info("Build ID: " + actual);
+
+ // Test
+ TestCase.assertEquals("Build ID was not as expected", EXPECTED_BUILD_ID, actual);
+ }
+
+ /**
+ * Asserts the server reports the
+ * build Date
+ */
+ @Test
+ public void testServerReportsBuildDate()
+ {
+ // Log
+ log.info("testServerReportsBuildDate");
+
+ // Get
+ final String actual = server.getBuildDate();
+ log.info("Build Date: " + actual);
+
+ // Test
+ TestCase.assertEquals("Build Date was not as expected", EXPECTED_BUILD_DATE, actual);
+ }
+
+ /**
+ * Asserts the server reports the
+ * build JVM
+ */
+ @Test
+ public void testServerReportsBuildJVM()
+ {
+ // Log
+ log.info("testServerReportsBuildJVM");
+
+ // Get
+ final String actual = server.getBuildJVM();
+ log.info("Build JVM: " + actual);
+
+ // Test
+ TestCase.assertTrue("Build JVM must contain JVM Vendor", actual.contains(EXPECTED_BUILD_VENDOR));
+ TestCase.assertTrue("Build JVM must contain JVM Version", actual.contains(EXPECTED_BUILD_VERSION));
+ }
+
+ /**
+ * Asserts the server reports the
+ * build operating system
+ */
+ @Test
+ public void testServerReportsBuildOS()
+ {
+ // Log
+ log.info("testServerReportsBuildOS");
+
+ // Get
+ final String actual = server.getBuildOS();
+ log.info("Build OS: " + actual);
+
+ // Test
+ TestCase.assertTrue("Build OS must contain OS Name", actual.contains(EXPECTED_OS_NAME));
+ TestCase.assertTrue("Build OS must contain OS Arch", actual.contains(EXPECTED_OS_ARCH));
+ TestCase.assertTrue("Build OS must contain OS Version", actual.contains(EXPECTED_OS_VERSION));
+ }
+
+}
Added: 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 (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/NoOpJBossASServer.java 2009-04-23 03:57:27 UTC (rev 87701)
@@ -0,0 +1,68 @@
+/*
+ * 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 org.jboss.logging.Logger;
+
+/**
+ * NoOpJBossASServer
+ *
+ * An implementation of an AS Server which doesn't truly start,
+ * but performs all other lifecycle activities
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class NoOpJBossASServer extends JBossASServerImpl implements JBossASServer
+{
+ //-------------------------------------------------------------------------------||
+ // Class Members ----------------------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(NoOpJBossASServer.class);
+
+ //-------------------------------------------------------------------------------||
+ // Overridden Implementations ---------------------------------------------------||
+ //-------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServerImpl#doShutdown()
+ */
+ @Override
+ protected void doShutdown() throws Exception
+ {
+ // NOOP
+ log.info("NOOP Shutdown");
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.bootstrap.impl.as.server.JBossASServerImpl#doStart()
+ */
+ @Override
+ protected void doStart() throws Exception
+ {
+ // NOOP
+ log.info("NOOP Startup");
+ }
+
+}
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/bin/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/client/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/common/lib/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/lib/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/conf/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/data/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deploy/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/deployers/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/lib/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/log/work/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/jbossas/server/all/tmp/EMPTY
===================================================================
Added: projects/bootstrap/trunk/impl-as/src/test/resources/org/jboss/version.properties
===================================================================
--- projects/bootstrap/trunk/impl-as/src/test/resources/org/jboss/version.properties (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/test/resources/org/jboss/version.properties 2009-04-23 03:57:27 UTC (rev 87701)
@@ -0,0 +1,31 @@
+# Version Properties used in testing only
+
+# The version of the server
+version.major=1
+version.minor=2
+version.revision=3
+version.tag=VersionTag
+version.name=VersionName
+version.cvstag=VersionCVSTag
+
+# Build identifiers
+build.number=BuildNumber
+build.id=BuildID
+build.date=BuildDate
+build.time=BuildTime
+build.day=BuildDay
+
+# Information about Java version used to compile
+java.version=JavaVersion
+java.vendor=JavaVendor
+java.vm.specification.version=JavaVMSpecVersion
+java.vm.version=JavaVMVersion
+java.vm.name=JavaVMName
+java.vm.info=JavaVMInfo
+java.specification.version=JavaSpecVersion
+java.class.version=JavaClassVersion
+
+# Information about the OS the server was compiled on
+os.name=OSName
+os.arch=OSArch
+os.version=OSVersion
More information about the jboss-cvs-commits
mailing list