[jboss-cvs] JBossAS SVN: r92334 - in projects/bootstrap/trunk: impl-as/src/test/java/org/jboss/bootstrap/impl/as/server and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Aug 14 01:12:43 EDT 2009


Author: johnbailey
Date: 2009-08-14 01:12:41 -0400 (Fri, 14 Aug 2009)
New Revision: 92334

Added:
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/ASVersion.java
   projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java
   projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractVersion.java
   projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCVersion.java
   projects/bootstrap/trunk/impl-mc/src/test/resources/org/
   projects/bootstrap/trunk/impl-mc/src/test/resources/org/jboss/
   projects/bootstrap/trunk/impl-mc/src/test/resources/org/jboss/mc-version.properties
Removed:
   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/server/JBossASServerVersionInformationTestCase.java
Modified:
   projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java
   projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractServer.java
   projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java
Log:
Adjusted server startup complete message to look more like the legacy message.  For JIRA JBBOOT-89

Added: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/ASVersion.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/ASVersion.java	                        (rev 0)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/ASVersion.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -0,0 +1,71 @@
+/*
+ * 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 org.jboss.bootstrap.impl.base.server.AbstractVersion;
+
+/**
+ * Provides access to JBossAS version (and build) properties.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 63730 $
+ */
+public final class ASVersion extends AbstractVersion
+{
+	
+   /**
+   * The single instance.
+   */
+   private static ASVersion instance = null;
+	
+   /**
+   * Get the single <tt>ASVersion</tt> instance.
+   *
+   * @return The single <tt>ASVersion</tt> instance.
+   */
+   public synchronized static ASVersion getInstance()
+   {
+      if (instance == null)
+      {
+         instance = new ASVersion();
+      }
+      return instance;
+   }
+   
+   /**
+    * Do not allow direct public construction.
+    */
+   private ASVersion()
+   {
+   }
+	
+   @Override
+	protected Class<?> getImplClass() {
+		return ASVersion.class;
+	}
+
+	@Override
+	protected String getVersionResourceLocation() {
+		return "/org/jboss/version.properties";
+	}
+
+}

Modified: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java	2009-08-14 04:48:24 UTC (rev 92333)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/AbstractJBossASServerBase.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -99,7 +99,7 @@
    /** 
     * Container for version information. 
     */
-   private final Version version = Version.getInstance();
+   private final ASVersion version = ASVersion.getInstance();
 
    /**
     * The date in which the server was started.  
@@ -396,7 +396,7 @@
    public String toString()
    {
       StringBuilder sb = new StringBuilder();
-      sb.append("JBoss Server[");
+      sb.append("JBossAS [");
       sb.append(this.version.toString());
       sb.append("]");
       return sb.toString();

Deleted: projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java
===================================================================
--- projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java	2009-08-14 04:48:24 UTC (rev 92333)
+++ projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -1,306 +0,0 @@
-/*
- * 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;
-   }
-}

Deleted: 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	2009-08-14 04:48:24 UTC (rev 92333)
+++ projects/bootstrap/trunk/impl-as/src/test/java/org/jboss/bootstrap/impl/as/server/JBossASServerVersionInformationTestCase.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -1,267 +0,0 @@
-/*
- * 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.spi.as.server.JBossASServerProvider;
-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; use the SPI view, not the client view
-    */
-   private static JBossASServerProvider 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));
-   }
-
-   /**
-    * Test that the {@link AbstractJBossASServerBase#toString()} contains the  version
-    * information about the server
-    */
-   @Test
-   public void testServerToStringReportsVersionInfo()
-   {
-      String serverInfo = server.toString();
-      String versionInfo = server.getVersion();
-
-      TestCase.assertNotNull("Version information not available in server", versionInfo);
-      TestCase.assertTrue("toString() of " + server.getClass().getName() + " does not container version information",
-            serverInfo.contains(versionInfo));
-   }
-
-}

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-08-14 05:12:41 UTC (rev 92334)
@@ -0,0 +1,267 @@
+/*
+ * 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.spi.as.server.JBossASServerProvider;
+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; use the SPI view, not the client view
+    */
+   private static JBossASServerProvider 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 + ASVersion.DELIMITER_VERSION
+         + EXPECTED_VERSION_MINOR + ASVersion.DELIMITER_VERSION + EXPECTED_VERSION_REVISION + ASVersion.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));
+   }
+
+   /**
+    * Test that the {@link AbstractJBossASServerBase#toString()} contains the  version
+    * information about the server
+    */
+   @Test
+   public void testServerToStringReportsVersionInfo()
+   {
+      String serverInfo = server.toString();
+      String versionInfo = server.getVersion();
+
+      TestCase.assertNotNull("Version information not available in server", versionInfo);
+      TestCase.assertTrue("toString() of " + server.getClass().getName() + " does not container version information",
+            serverInfo.contains(versionInfo));
+   }
+
+}

Modified: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractServer.java
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractServer.java	2009-08-14 04:48:24 UTC (rev 92333)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractServer.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -444,7 +444,7 @@
                sendStartJmxNotification();
 
                // Done
-               log.info("Started: " + thisRef + " in " + watch);
+               log.info(thisRef + " Started in " + watch);
                setState(LifecycleState.STARTED);
             }
             catch (final Exception e)

Copied: projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractVersion.java (from rev 92321, projects/bootstrap/trunk/impl-as/src/main/java/org/jboss/bootstrap/impl/as/server/Version.java)
===================================================================
--- projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractVersion.java	                        (rev 0)
+++ projects/bootstrap/trunk/impl-base/src/main/java/org/jboss/bootstrap/impl/base/server/AbstractVersion.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -0,0 +1,298 @@
+/*
+ * 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.base.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 abstract class AbstractVersion
+{
+   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 version properties.
+    */
+   private Properties props;
+
+   /**
+    * Do not allow direct public construction.
+    */
+   protected AbstractVersion()
+   {
+      props = loadProperties();
+   }
+
+   /**
+    * 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;
+      }
+   }
+
+   /**
+    * Provides the actual resource to load the properties from
+    * @return String resource path to version properties file
+    */
+   protected abstract String getVersionResourceLocation();
+   
+   /**
+    * Provides the Class to use to use as the classloading base to load the version properties resource from 
+    * @return Class concrete version class
+    */
+   protected abstract Class<?> getImplClass();
+   
+   /**
+    * Load the version properties from a resource.
+    */
+   private Properties loadProperties()
+   {
+      props = new Properties();
+
+      try
+      {
+         InputStream in = getImplClass().getResourceAsStream(getVersionResourceLocation());
+         if( in != null )
+         {
+            props.load(in);
+            in.close();
+         }
+      }
+      catch (IOException e)
+      {
+         throw new Error("Missing version.properties");
+      }
+
+      return props;
+   }
+}

Modified: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java	2009-08-14 04:48:24 UTC (rev 92333)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/AbstractMCServerBase.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -79,6 +79,11 @@
     * The XML Deployer
     */
    private TempBasicXMLDeployer kernelDeployer;
+   
+   /** 
+    * Container for version information. 
+    */
+   private final MCVersion version = MCVersion.getInstance();
 
    //-------------------------------------------------------------------------------------||
    // Constructors -----------------------------------------------------------------------||
@@ -348,4 +353,12 @@
       }
    }
 
+   @Override
+   public String toString() {
+      return new StringBuilder()
+         .append("MCServer [")
+         .append(this.version.toString())
+         .append("]")
+         .toString();
+   }
 }

Added: projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCVersion.java
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCVersion.java	                        (rev 0)
+++ projects/bootstrap/trunk/impl-mc/src/main/java/org/jboss/bootstrap/impl/mc/server/MCVersion.java	2009-08-14 05:12:41 UTC (rev 92334)
@@ -0,0 +1,71 @@
+/*
+ * 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.mc.server;
+
+import org.jboss.bootstrap.impl.base.server.AbstractVersion;
+
+/**
+ * Provides access to JBoss MC version (and build) properties.
+ *
+ * @author <a href="mailto:baileyje at gmail.com">John Bailey</a>
+ * @version $Revision: 63730 $
+ */
+public final class MCVersion extends AbstractVersion
+{
+	
+   /**
+   * The single instance.
+   */
+   private static MCVersion instance = null;
+	
+   /**
+   * Get the single <tt>MCVersion</tt> instance.
+   *
+   * @return The single <tt>MCVersion</tt> instance.
+   */
+   public synchronized static MCVersion getInstance()
+   {
+      if (instance == null)
+      {
+         instance = new MCVersion();
+      }
+      return instance;
+   }
+   
+   /**
+    * Do not allow direct public construction.
+    */
+   private MCVersion()
+   {
+   }
+	
+   @Override
+	protected Class<?> getImplClass() {
+		return MCVersion.class;
+	}
+
+	@Override
+	protected String getVersionResourceLocation() {
+		return "/org/jboss/mc-version.properties";
+	}
+
+}

Added: projects/bootstrap/trunk/impl-mc/src/test/resources/org/jboss/mc-version.properties
===================================================================
--- projects/bootstrap/trunk/impl-mc/src/test/resources/org/jboss/mc-version.properties	                        (rev 0)
+++ projects/bootstrap/trunk/impl-mc/src/test/resources/org/jboss/mc-version.properties	2009-08-14 05:12:41 UTC (rev 92334)
@@ -0,0 +1,62 @@
+# 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
+# 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