[jboss-cvs] JBossAS SVN: r84764 - in projects/bootstrap/trunk/src: test/java/org/jboss/bootstrap/test/jboot11/unit and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 25 15:18:20 EST 2009


Author: ALRubinger
Date: 2009-02-25 15:18:20 -0500 (Wed, 25 Feb 2009)
New Revision: 84764

Added:
   projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FileFromServerConfigPropertyTestCase.java
Removed:
   projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FilePropertiesTestCase.java
Modified:
   projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java
Log:
[JBBOOT-11] Expand upon test case, ensure File objects may be constructed from ServerConfig properties

Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java	2009-02-25 20:12:23 UTC (rev 84763)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java	2009-02-25 20:18:20 UTC (rev 84764)
@@ -49,6 +49,7 @@
 import org.jboss.util.platform.Java;
 import org.jboss.virtual.VFS;
 import org.jboss.virtual.VirtualFile;
+import org.jboss.virtual.VFSUtils;
 
 /**
  * A container for the basic configuration elements required to create
@@ -130,7 +131,7 @@
       homeDir = getFile(ServerConfig.HOME_DIR);
       if (homeDir == null)
          throw new Exception("Missing configuration value for: " + ServerConfig.HOME_DIR);
-      System.setProperty(ServerConfig.HOME_DIR, homeDir.toString());
+      System.setProperty(ServerConfig.HOME_DIR, toPathName(homeDir));
       // Setup the SERVER_HOME_DIR system property
       getServerHomeDir();
 
@@ -282,7 +283,7 @@
             {
                throw new RuntimeException(e);
             }
-            System.setProperty(ServerConfig.SERVER_BASE_DIR, serverBaseDir.toString());
+            System.setProperty(ServerConfig.SERVER_BASE_DIR, toPathName(serverBaseDir));
          }
       }
       return serverBaseDir;
@@ -306,7 +307,7 @@
             {
                throw new RuntimeException(e);
             }
-            System.setProperty(ServerConfig.SERVER_HOME_DIR, serverHomeDir.toString());
+            System.setProperty(ServerConfig.SERVER_HOME_DIR, toPathName(serverHomeDir));
          }
       }
       return serverHomeDir;
@@ -338,7 +339,7 @@
             {
                throw new RuntimeException(e);
             }
-            System.setProperty(ServerConfig.SERVER_LOG_DIR, serverLogDir.toString());
+            System.setProperty(ServerConfig.SERVER_LOG_DIR, toPathName(serverLogDir));
          }
       }
       return serverLogDir;
@@ -367,7 +368,7 @@
             {
                throw new RuntimeException(e);
             }
-            System.setProperty(ServerConfig.SERVER_TEMP_DIR, serverTempDir.toString());
+            System.setProperty(ServerConfig.SERVER_TEMP_DIR, toPathName(serverTempDir));
          }
       }
       return serverTempDir;
@@ -396,7 +397,7 @@
             {
                throw new RuntimeException(e);
             }
-            System.setProperty(ServerConfig.SERVER_DATA_DIR, serverDataDir.toString());
+            System.setProperty(ServerConfig.SERVER_DATA_DIR, toPathName(serverDataDir));
          }
       }
       return serverDataDir;
@@ -869,4 +870,22 @@
          return f;
       }
    }
+
+   private static String toPathName(VirtualFile virtualFile)
+   {
+      String path = null;
+      try
+      {
+         path = new File(VFSUtils.getRealURL(virtualFile).toURI()).getAbsolutePath();
+      }
+      catch (URISyntaxException e)
+      {
+         throw new RuntimeException(e);
+      }
+      catch (IOException e)
+      {
+         throw new RuntimeException(e);
+      }
+      return path;
+   }
 }

Copied: projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FileFromServerConfigPropertyTestCase.java (from rev 84762, projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FilePropertiesTestCase.java)
===================================================================
--- projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FileFromServerConfigPropertyTestCase.java	                        (rev 0)
+++ projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FileFromServerConfigPropertyTestCase.java	2009-02-25 20:18:20 UTC (rev 84764)
@@ -0,0 +1,174 @@
+/*
+ * 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.test.jboot11.unit;
+
+import java.io.File;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.microcontainer.ServerImpl;
+import org.jboss.bootstrap.spi.Server;
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.jboss.bootstrap.test.common.ServerConfigUtil;
+import org.jboss.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * FileFromServerConfigPropertyTestCase
+ * 
+ * Tests to ensure that File objects may be constructed from
+ * the properties made by the ServerConfig
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class FileFromServerConfigPropertyTestCase
+{
+
+   //-----------------------------------------------------------------------------||
+   // Class Members --------------------------------------------------------------||
+   //-----------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(FileFromServerConfigPropertyTestCase.class);
+
+   //-----------------------------------------------------------------------------||
+   // Lifecycle Methods ----------------------------------------------------------||
+   //-----------------------------------------------------------------------------||
+
+   /**
+    * Runs once before the suite, initializes the Server such that
+    * the requisite System Properties are put in place
+    */
+   @BeforeClass
+   public static void initServerToMakeProperties() throws Throwable
+   {
+      // Create properties (and JBOSS_HOME)
+      final Properties props = new Properties();
+      props.put(ServerConfig.HOME_DIR, ServerConfigUtil.getJBossHomeFromCurrentLocation("jbossas").toURL()
+            .toExternalForm());
+
+      // Create and perform minimal initialization upon a new server
+      final Server server = new ServerImpl();
+      server.init(props);
+   }
+
+   //-----------------------------------------------------------------------------||
+   // Tests ----------------------------------------------------------------------||
+   //-----------------------------------------------------------------------------||
+
+   /**
+    * Ensures that a valid File may be made from
+    * jboss.server.base.dir
+    *  
+    * @throws Exception
+    */
+   @Test
+   public void testFileFromJbossHomeDirProperty() throws Exception
+   {
+      this.ensureFileFromPropertyExists(ServerConfig.HOME_DIR);
+   }
+
+   /**
+    * Ensures that a valid File may be made from
+    * jboss.home
+    *  
+    * @throws Exception
+    */
+   @Test
+   public void testFileFromServerBaseDirProperty() throws Exception
+   {
+      this.ensureFileFromPropertyExists(ServerConfig.SERVER_BASE_DIR);
+   }
+
+   /**
+    * Ensures that a valid File may be made from
+    * jboss.server.home.dir
+    *  
+    * @throws Exception
+    */
+   @Test
+   public void testFileFromServerHomeDirProperty() throws Exception
+   {
+      this.ensureFileFromPropertyExists(ServerConfig.SERVER_HOME_DIR);
+   }
+
+   /**
+    * Ensures that a valid File may be made from
+    * jboss.server.log.dir
+    *  
+    * @throws Exception
+    */
+   @Test
+   public void testFileFromServerLogDirProperty() throws Exception
+   {
+      this.ensureFileFromPropertyExists(ServerConfig.SERVER_LOG_DIR);
+   }
+
+   /**
+    * Ensures that a valid File may be made from
+    * jboss.server.temp.dir
+    *  
+    * @throws Exception
+    */
+   @Test
+   public void testFileFromServerTempDirProperty() throws Exception
+   {
+      this.ensureFileFromPropertyExists(ServerConfig.SERVER_TEMP_DIR);
+   }
+
+   /**
+    * Ensures that a valid File may be made from
+    * jboss.server.data.dir
+    *  
+    * @throws Exception
+    */
+   @Test
+   public void testFileFromServerDataDirProperty() throws Exception
+   {
+      this.ensureFileFromPropertyExists(ServerConfig.SERVER_DATA_DIR);
+   }
+
+   //-----------------------------------------------------------------------------||
+   // Internal Helper Methods ----------------------------------------------------||
+   //-----------------------------------------------------------------------------||
+
+   /**
+    * Ensures that a File may be constructed from the value of specified
+    * System Property name, and that it exists
+    */
+   public void ensureFileFromPropertyExists(final String propertyName) throws Exception
+   {
+
+      // Get the system property
+      final String propertyValue = System.getProperty(propertyName);
+      log.info(propertyName + " is: " + propertyValue);
+
+      // Make a File, ensure it exists
+      File fileFromPropertyValue = new File(propertyValue);
+      TestCase.assertTrue(propertyName + " could not be made into a " + File.class.getName() + ": "
+            + fileFromPropertyValue.getAbsolutePath(), fileFromPropertyValue.exists());
+
+   }
+
+}


Property changes on: projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FileFromServerConfigPropertyTestCase.java
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FilePropertiesTestCase.java
===================================================================
--- projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FilePropertiesTestCase.java	2009-02-25 20:12:23 UTC (rev 84763)
+++ projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/test/jboot11/unit/FilePropertiesTestCase.java	2009-02-25 20:18:20 UTC (rev 84764)
@@ -1,70 +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.test.jboot11.unit;
-
-import java.io.File;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.jboss.bootstrap.microcontainer.ServerImpl;
-import org.jboss.bootstrap.spi.Server;
-import org.jboss.bootstrap.spi.ServerConfig;
-import org.jboss.bootstrap.test.common.ServerConfigUtil;
-import org.jboss.logging.Logger;
-import org.junit.Test;
-
-/**
- * FilePropertiesTestCase
- *
- * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
- * @version $Revision: $
- */
-public class FilePropertiesTestCase
-{
-
-   private static final Logger log = Logger.getLogger(FilePropertiesTestCase.class);
-
-   @Test
-   public void testFileFromServerDataDirProperty() throws Exception
-   {
-
-      // Create properties (and JBOSS_HOME)
-      Properties props = new Properties();
-      props.put(ServerConfig.HOME_DIR, ServerConfigUtil.getJBossHomeFromCurrentLocation("jbossas").toURL()
-            .toExternalForm());
-
-      // Create and perform minimal initialization upon a new server
-      Server server = new ServerImpl();
-      server.init(props);
-
-      // Attempt to create a file from the System Property for jboss.server.data.dir
-      String serverDataDirPropName = ServerConfig.SERVER_DATA_DIR;
-      String serverDataDirString = System.getProperty(serverDataDirPropName);
-      log.info(serverDataDirPropName + " is: " + serverDataDirString);
-
-      File serverDataDir = new File(serverDataDirString);
-      TestCase.assertTrue("Server data dir does not exist: " + serverDataDir.getAbsolutePath(), serverDataDir.exists());
-
-   }
-
-}




More information about the jboss-cvs-commits mailing list