[jboss-cvs] JBossAS SVN: r83643 - in projects/bootstrap/trunk: src/main/java/org/jboss/bootstrap and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Jan 30 02:48:19 EST 2009


Author: ALRubinger
Date: 2009-01-30 02:48:18 -0500 (Fri, 30 Jan 2009)
New Revision: 83643

Added:
   projects/bootstrap/trunk/src/test/java/org/
   projects/bootstrap/trunk/src/test/java/org/jboss/
   projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/
   projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/GetServerNativeDirPropertyTestCase.java
   projects/bootstrap/trunk/src/test/resources/log4j.xml
Modified:
   projects/bootstrap/trunk/pom.xml
   projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java
Log:
[JBBOOT-6] Tests for BaseServerConfig.getServerNativeDir to use its own properties

Modified: projects/bootstrap/trunk/pom.xml
===================================================================
--- projects/bootstrap/trunk/pom.xml	2009-01-30 07:21:21 UTC (rev 83642)
+++ projects/bootstrap/trunk/pom.xml	2009-01-30 07:48:18 UTC (rev 83643)
@@ -27,6 +27,7 @@
     <version.org.jboss_jboss.vfs>2.0.0.CR5</version.org.jboss_jboss.vfs>
     <version.org.jboss.man_jboss.managed>2.0.0.CR4</version.org.jboss.man_jboss.managed>
     <version.org.jboss.microcontainer_jboss.kernel>2.0.0.CR5</version.org.jboss.microcontainer_jboss.kernel>
+    <version.junit_junit>4.5</version.junit_junit>
   
   </properties>
 
@@ -44,7 +45,29 @@
   </issueManagement>
 
   <!-- Build -->
-  <build></build>
+  <build>
+    <plugins>
+
+      <!-- Surefire (Tests) Plugin -->
+
+      <plugin>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <printSummary>true</printSummary>
+          <!-- To allow override from the command line, see SUREFIRE-319 -->
+          <testFailureIgnore>${maven.test.failure.ignore}</testFailureIgnore>
+          <includes>
+            <include>**/*TestCase.java</include>
+            <include>**/*TestSuite.java</include>
+          </includes>
+          <forkMode>always</forkMode>
+          <argLine>-ea</argLine>
+        </configuration>
+      </plugin>
+
+    </plugins>
+  </build>
   
   <!-- Dependencies -->
   <dependencies>
@@ -68,6 +91,13 @@
       <artifactId>jboss-vfs</artifactId>
       <version>${version.org.jboss_jboss.vfs}</version>
     </dependency>
+    
+    <!-- junit:junit -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${version.junit_junit}</version>
+    </dependency>
 
   </dependencies>
   

Modified: projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java
===================================================================
--- projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java	2009-01-30 07:21:21 UTC (rev 83642)
+++ projects/bootstrap/trunk/src/main/java/org/jboss/bootstrap/BaseServerConfig.java	2009-01-30 07:48:18 UTC (rev 83643)
@@ -366,7 +366,7 @@
    {
       try
       {
-         String fileName = System.getProperty(NATIVE_DIR_PROPERTY);
+         String fileName = this.getNativeDirProperty();
          if (fileName != null)
          {
             URL url = new URL(fileName);
@@ -379,6 +379,19 @@
          throw new RuntimeException(e);
       }
    }
+   
+   /**
+    * Obtains the property value of the native directory
+    * 
+    * Extracted to package-private for testing of
+    * JBBOOT-6
+    * 
+    * @return
+    */
+   String getNativeDirProperty()
+   {
+      return System.getProperty(NATIVE_DIR_PROPERTY);
+   }
 
    /**
     * Get the temporary deployment dir for unpacking

Added: projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/GetServerNativeDirPropertyTestCase.java
===================================================================
--- projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/GetServerNativeDirPropertyTestCase.java	                        (rev 0)
+++ projects/bootstrap/trunk/src/test/java/org/jboss/bootstrap/GetServerNativeDirPropertyTestCase.java	2009-01-30 07:48:18 UTC (rev 83643)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+  *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.bootstrap;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.jboss.bootstrap.spi.ServerConfig;
+import org.junit.Test;
+
+/**
+ * GetServerNativeDirPropertyTestCase
+ * 
+ * Ensures that the SERVER_NATIVE_DIR property
+ * is obtained from internal property set,
+ * not from System properties
+ * 
+ * JBBOOT-6
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class GetServerNativeDirPropertyTestCase
+{
+   //--------------------------------------------------------------------||
+   // Tests -------------------------------------------------------------||
+   //--------------------------------------------------------------------||
+
+   /**
+    * Tests that BaseServerConfig.getNativeDirProperty uses its own properties,
+    * and not that of System.getProperty
+    */
+   @Test
+   public void testGetNativeDirProperty() throws Exception
+   {
+      // Initialize
+      String expectedNativeDir = "expected";
+      String wrongNativeDir = "wrong";
+      URL currentUrl = this.getClass().getProtectionDomain().getCodeSource().getLocation();
+      File currentFile = new File(currentUrl.toURI());
+      File homeFile = new File(currentFile, "jbosshome");
+      File serverFile = new File(homeFile, "server/default");
+
+      // Make server dir
+      if (!serverFile.isDirectory() && !serverFile.mkdirs())
+      {
+         throw new RuntimeException("Could not create/get server directory " + serverFile);
+      }
+
+      // Create properties for the server config
+      Properties configProps = new Properties();
+      configProps.put(ServerConfig.HOME_DIR, currentUrl.toString());
+      configProps.put(ServerConfig.NATIVE_DIR_PROPERTY, expectedNativeDir);
+
+      // Set a system property for native dir
+      System.getProperties().put(ServerConfig.NATIVE_DIR_PROPERTY, wrongNativeDir);
+
+      // Create the config
+      BaseServerConfig config = new BaseServerConfig(configProps);
+
+      // Test the native dir is expected
+      TestCase.assertEquals("NATIVE_DIR was not as passed in properties to config", expectedNativeDir, config
+            .getNativeDirProperty());
+
+   }
+
+}

Added: projects/bootstrap/trunk/src/test/resources/log4j.xml
===================================================================
--- projects/bootstrap/trunk/src/test/resources/log4j.xml	                        (rev 0)
+++ projects/bootstrap/trunk/src/test/resources/log4j.xml	2009-01-30 07:48:18 UTC (rev 83643)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
+  debug="false">
+
+  <!-- ============================== -->
+  <!-- Append messages to the console -->
+  <!-- ============================== -->
+
+  <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+    <param name="Target" value="System.out" />
+
+    <layout class="org.apache.log4j.PatternLayout">
+      <!-- The default pattern: Date Priority [Category] Message\n -->
+      <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n" />
+    </layout>
+  </appender>
+
+
+  <!-- ================ -->
+  <!-- Limit categories -->
+  <!-- ================ -->
+
+  <category name="org.jboss">
+    <priority value="INFO" />
+  </category>
+
+  <category name="org.jnp">
+    <priority value="INFO" />
+  </category>
+
+  <category name="org.jboss.bootstrap">
+    <priority value="ALL" />
+  </category>
+
+  <!-- ======================= -->
+  <!-- Setup the Root category -->
+  <!-- ======================= -->
+
+  <root>
+    <appender-ref ref="CONSOLE" />
+  </root>
+
+</log4j:configuration>




More information about the jboss-cvs-commits mailing list