Implement support for running the tests when the build output directory has non-defau...
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 28 Apr 2010 18:49:11 +0000 (18:49 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 28 Apr 2010 18:49:11 +0000 (18:49 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@939050 13f79535-47bb-0310-9956-ffa450edef68

build.xml
test/org/apache/catalina/startup/TestTomcat.java
test/org/apache/catalina/startup/TestTomcatSSL.java
test/org/apache/catalina/startup/TomcatBaseTest.java

index 80539f8..2b7f455 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -73,6 +73,7 @@
   <property name="tomcat.release"        value="${tomcat.output}/release"/>
   <property name="tomcat.src.jars"       value="${tomcat.output}/src-jars"/>
   <property name="test.classes"          value="${tomcat.output}/testclasses"/>
+  <property name="test.temp"             value="${tomcat.output}/test-tmp"/>
 
   <!-- Servlet 3.0 spec requires 1.6+ -->
   <property name="compile.source" value="1.6"/>
     <junit printsummary="yes" fork="yes" dir="." showoutput="yes">
       <classpath refid="tomcat.test.classpath" />
 
+      <sysproperty key="tomcat.test.temp" value="${test.temp}" />
+      <sysproperty key="tomcat.test.tomcatbuild" value="${tomcat.build}" />
+
       <formatter type="plain" usefile="true" />
 
       <!-- If test.entry is defined, run a single test, otherwise run all valid tests -->
index 612e08e..12ef7ae 100644 (file)
@@ -185,8 +185,7 @@ public class TestTomcat extends TomcatBaseTest {
     public void testSingleWebapp() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
-        File appDir = 
-            new File("output/build/webapps/examples");
+        File appDir = new File(getBuildDirectory(), "webapps/examples");
         // app dir is relative to server home
         tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
         
@@ -200,8 +199,7 @@ public class TestTomcat extends TomcatBaseTest {
     public void testJsps() throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
-        File appDir = 
-            new File("output/build/webapps/examples");
+        File appDir = new File(getBuildDirectory(), "webapps/examples");
         // app dir is relative to server home
         tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
         
@@ -296,7 +294,7 @@ public class TestTomcat extends TomcatBaseTest {
         
         String contextPath = "/examples";
         
-        File appDir = new File("output/build/webapps" + contextPath);
+        File appDir = new File(getBuildDirectory(), "webapps" + contextPath);
         // app dir is relative to server home
         org.apache.catalina.Context ctx =
             tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
index 637431e..9e17a3c 100644 (file)
@@ -70,9 +70,11 @@ public class TestTomcatSSL extends TomcatBaseTest {
         tomcat.getConnector().setProperty("SSLEnabled", "true");
         tomcat.getConnector().setProperty("sslProtocol",
             "tls");
-        // test runs in output/tmp
-        tomcat.getConnector().setAttribute("keystoreFile", 
-            "../../test/org/apache/catalina/startup/test.keystore");
+
+        File keystoreFile = new File(
+                "test/org/apache/catalina/startup/test.keystore");
+        tomcat.getConnector().setAttribute("keystoreFile",
+                keystoreFile.getAbsolutePath());
     }
     
     public void testSimpleSsl() throws Exception {
@@ -98,8 +100,7 @@ public class TestTomcatSSL extends TomcatBaseTest {
         
         Tomcat tomcat = getTomcatInstance();
 
-        File appDir = 
-            new File("output/build/webapps/examples");
+        File appDir = new File(getBuildDirectory(), "webapps/examples");
         tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
         
         initSsl(tomcat, nio);
@@ -119,8 +120,7 @@ public class TestTomcatSSL extends TomcatBaseTest {
     public void renegotiateFail(boolean nio) throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
-        File appDir = 
-            new File("output/build/webapps/examples");
+        File appDir = new File(getBuildDirectory(), "webapps/examples");
         // app dir is relative to server home
         tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
 
@@ -198,8 +198,7 @@ public class TestTomcatSSL extends TomcatBaseTest {
     public void renegotiateWorks(boolean nio) throws Exception {
         Tomcat tomcat = getTomcatInstance();
 
-        File appDir = 
-            new File("output/build/webapps/examples");
+        File appDir = new File(getBuildDirectory(), "webapps/examples");
         // app dir is relative to server home
         tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());
 
index 167c8ac..53097e7 100644 (file)
@@ -67,7 +67,17 @@ public abstract class TomcatBaseTest extends TestCase {
         port++;
         return getPort();
     }
-    
+
+    /**
+     * Helper method that returns the directory where Tomcat build resides. It
+     * is used to access resources that are part of default Tomcat deployment.
+     * E.g. the examples webapp.
+     */
+    public File getBuildDirectory() {
+        return new File(System.getProperty("tomcat.test.tomcatbuild",
+                "output/build"));
+    }
+
     @Override
     public void setUp() throws Exception {
         // Need to use JULI and to configure a ConsoleHandler so log messages
@@ -77,7 +87,7 @@ public abstract class TomcatBaseTest extends TestCase {
         LogManager.getLogManager().getLogger("").addHandler(
             new ConsoleHandler());
 
-        tempDir = new File("output/tmp");
+        tempDir = new File(System.getProperty("tomcat.test.temp", "output/tmp"));
         tempDir.mkdir();
         File appBase = new File(tempDir, "webapps");
         appBase.mkdir();