You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by fe...@apache.org on 2006/04/15 17:07:27 UTC

svn commit: r394301 - in /jakarta/cactus/trunk/integration/ant: ./ src/java/org/apache/cactus/integration/ant/ src/java/org/apache/cactus/integration/ant/util/ src/test-input/org/apache/cactus/integration/ant/ src/test/org/apache/cactus/integration/ant/

Author: felipeal
Date: Sat Apr 15 08:07:26 2006
New Revision: 394301

URL: http://svn.apache.org/viewcvs?rev=394301&view=rev
Log:
CACTUS-151: applied Xuan's final patches; see links below:
  http://issues.apache.org/jira/secure/attachment/12312049/28-08-05_xnguyen(final).tgz
  http://issues.apache.org/jira/secure/attachment/12312050/TestCactusTestTask.java
  http://issues.apache.org/jira/secure/attachment/12312051/test-cactustest.xml
  http://issues.apache.org/jira/browse/CACTUS-151#action_12320346
  http://issues.apache.org/jira/browse/CACTUS-151#action_12320347

Added:
    jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/util/HttpProbe.java
    jakarta/cactus/trunk/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactustest.xml
    jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactusTestTask.java
Modified:
    jakarta/cactus/trunk/integration/ant/build.xml
    jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTestTask.java
    jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestAll.java

Modified: jakarta/cactus/trunk/integration/ant/build.xml
URL: http://svn.apache.org/viewcvs/jakarta/cactus/trunk/integration/ant/build.xml?rev=394301&r1=394300&r2=394301&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/ant/build.xml (original)
+++ jakarta/cactus/trunk/integration/ant/build.xml Sat Apr 15 08:07:26 2006
@@ -144,22 +144,6 @@
     <fileset id="deployment.resources" dir="${src.conf.dir}">
       <include name="*.dtd"/>
     </fileset>
-    <fileset id="container.share.resources" dir="${src.conf.dir}/share">
-      <include name="orion1x/**/*.*"/>
-      <include name="orion2x/**/*.*"/>
-      <include name="resin2x/**/*.*"/>
-      <include name="resin3x/**/*.*"/>
-      <include name="tomcat4x/**/*.*"/>
-      <include name="tomcat5x/**/*.*"/>
-      <include name="weblogic6x/**/*.*"/>
-      <include name="weblogic7x/**/*.*"/>
-    </fileset>
-    <fileset id="container.j2ee12.resources" dir="${src.conf.dir}/j2ee12">
-      <include name="tomcat3x/**/*.*"/>
-    </fileset>
-    <fileset id="container.j2ee13.resources" dir="${src.conf.dir}/j2ee13">
-      <include name="jboss3x/**/*.*"/>
-    </fileset>
   </target>
 
   <target name="compile.main" depends="compile.prepare">
@@ -174,14 +158,10 @@
           value="org.apache.cactus.integration.ant.CactusTestTask"/>
       <entry key="cactifyear"
       	  value="org.apache.cactus.integration.ant.CactifyEarTask"/>
-      <entry key="cactus"
-          value="org.apache.cactus.integration.ant.CactusTask"/>
       <entry key="runservertests"
-          value="org.apache.cactus.integration.ant.RunServerTestsTask"/>
+          value="org.apache.cactus.integration.ant.RunServerTestTask"/>
       <entry key="webxmlmerge"
           value="org.apache.cactus.integration.ant.WebXmlMergeTask"/>
-      <entry key="resin3x"
-          value="org.apache.cactus.integration.ant.container.resin.Resin3xTask"/>
     </propertyfile>
 
     <copy todir="${target.classes.java.dir}">
@@ -194,11 +174,6 @@
     </copy>
 
     <mkdir dir="${target.classes.java.dir}/org/apache/cactus/integration/ant/container/resources"/>
-    <copy todir="${target.classes.java.dir}/org/apache/cactus/integration/ant/container/resources">
-      <fileset refid="container.share.resources"/>
-      <fileset refid="container.j2ee12.resources"/>
-      <fileset refid="container.j2ee13.resources"/>
-    </copy>
 
     <javac srcdir="${src.java.dir}" destdir="${target.classes.java.dir}"
         deprecation="${deprecation}" optimize="${optimize}" 
@@ -243,10 +218,8 @@
           value="org.apache.cactus.integration.ant.CactifyWarTask"/>
       <entry key="cactustests"
           value="org.apache.cactus.integration.ant.CactusTestTask"/>
-      <entry key="cactus"
-          value="org.apache.cactus.integration.ant.CactusTask"/>
       <entry key="runservertests"
-          value="org.apache.cactus.integration.ant.RunServerTestsTask"/>
+          value="org.apache.cactus.integration.ant.RunServerTestTask"/>
       <entry key="webxmlmerge"
           value="org.apache.cactus.integration.ant.WebXmlMergeTask"/>
     </propertyfile>
@@ -261,11 +234,6 @@
     </copy>
 
     <mkdir dir="${target.classes.clover.dir}/org/apache/cactus/integration/ant/container/resources"/>
-    <copy todir="${target.classes.clover.dir}/org/apache/cactus/integration/ant/container/resources">
-      <fileset refid="container.share.resources"/>
-      <fileset refid="container.j2ee12.resources"/>
-      <fileset refid="container.j2ee13.resources"/>
-    </copy>
 
     <javac destdir="${target.classes.clover.dir}"
         deprecation="${deprecation}" optimize="${optimize}"

Modified: jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTestTask.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTestTask.java?rev=394301&r1=394300&r2=394301&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTestTask.java (original)
+++ jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/CactusTestTask.java Sat Apr 15 08:07:26 2006
@@ -1,7 +1,7 @@
 /* 
  * ========================================================================
  * 
- * Copyright 2003-2005 The Apache Software Foundation.
+ * Copyright 2003 The Apache Software Foundation.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -25,11 +25,9 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.MalformedURLException;
-
+import org.apache.cactus.integration.ant.util.HttpProbe;
 import org.apache.cactus.integration.ant.deployment.DeployableFile;
 import org.apache.cactus.integration.ant.deployment.EarParser;
 import org.apache.cactus.integration.ant.deployment.WarParser;
@@ -54,9 +52,19 @@
     /**
      * The servlet port element.
      */
+    private String serverName;
+
+    /**
+     * The servlet port element.
+     */
     private String servletPort;
 
     /**
+     * The context URL element.
+     */
+    private String contextURL;
+
+    /**
      * The testreportDir element.
      */
     private File toDir;
@@ -78,6 +86,12 @@
     private File warFile;
 
     /**
+     * The runLocal element.
+     */
+    private boolean runLocal;
+
+
+    /**
      * The deployable file.
      */
     private DeployableFile deployableFile;
@@ -87,12 +101,12 @@
      * the containers.
      */
     private Path additionalClasspath;
-    
+
     /**
      * Timeout after trying to connect(in ms).
      */
     private long timeout = 180000;
-    
+
     /**
      * The time interval in milliseconds to sleep between polling the container.
      */
@@ -103,7 +117,7 @@
 
     /**
      * Constructor.
-     * 
+     *
      * @throws Exception
      *             If the constructor of JUnitTask throws an exception
      */
@@ -131,25 +145,17 @@
      */
     public void execute() throws BuildException
     {
-        if (this.servletPort == null)
-        {
-             log("Using default servletport=8080", Project.MSG_INFO);
-             servletPort = "8080";
-
-        }
-        if (this.toDir == null)
-        {
-            throw new BuildException(
-                    "You must specify the test report directory");
-
-        }
         if ((this.warFile != null) && (this.earFile != null))
         {
-            throw new BuildException(
+             throw new BuildException(
                     "You must specify either the [warfile] or "
-                            + "the [earfile] attribute but not both");
+                          + "the [earfile] attribute but not both");
+        }
+        if ((this.warFile == null) && (this.earFile == null))
+        {
+            throw new BuildException("You must specify either the [warfile] or "
+                + "the [earfile] attribute");
         }
-
         // Parse deployment descriptors for WAR or EAR files
         if (this.warFile != null)
         {
@@ -162,10 +168,49 @@
 
         addRedirectorNameProperties();
 
+        if (runLocal)
+        {
+           log("Tests run locally", Project.MSG_VERBOSE);
+           super.execute();
+           return;
+        }
+
+        if (this.contextURL == null)
+        {
+            if (this.servletPort == null)
+            {
+                 log("Using default servletport=8080", Project.MSG_INFO);
+                 servletPort = "8080";
+
+            }
+            if (this.serverName == null)
+            {
+                log("Using default servername=localhost", Project.MSG_INFO);
+                serverName = "localhost";
+            }
+        }
+
+        if (this.toDir == null)
+        {
+            throw new BuildException(
+                    "You must specify the test report directory");
+
+        }
+
+
         Variable contextUrlVar = new Variable();
         contextUrlVar.setKey("cactus.contextURL");
-        contextUrlVar.setValue("http://localhost:" + servletPort
-            + "/" + deployableFile.getTestContext());
+        if (this.contextURL != null)
+        {
+           contextUrlVar.setValue(this.contextURL);
+        }
+        else
+        {
+            contextUrlVar.setValue("http://" + this.serverName + ":"
+                    + this.servletPort
+                    + "/" + deployableFile.getTestContext());
+        }
+
         addSysproperty(contextUrlVar);
 
         //Setup logs
@@ -226,22 +271,33 @@
         }
 
     }
-    
+
 
     /**
      * Executes the unit tests in the given container.
-     *  
+     *
      */
     private void testInContainer()
     {
         URL testURL = null;
         try
         {
-            testURL = new URL("http://localhost:" + servletPort 
-                + "/" +  deployableFile.getTestContext()
-                + deployableFile.getServletRedirectorMapping()
-                + "?Cactus_Service=RUN_TEST");
-            
+            if (this.contextURL == null)
+            {
+                testURL = new URL("http://" + this.serverName + ":"
+                        + this.servletPort + "/"
+                        + deployableFile.getTestContext()
+                        + deployableFile.getServletRedirectorMapping()
+                        + "?Cactus_Service=RUN_TEST");
+            }
+            else
+            {
+                testURL = new URL(this.contextURL
+                        + deployableFile.getServletRedirectorMapping()
+                        + "?Cactus_Service=RUN_TEST");
+            }
+
+
         }
         catch (MalformedURLException e)
         {
@@ -250,24 +306,27 @@
         //Ping the container
         //Continuously try calling the test URL until it succeeds or
         // until a timeout is reached (we then throw a build exception).
-        long startTime = System.currentTimeMillis();
-        int responseCode = -1;
-        do
+        try
         {
-            if ((System.currentTimeMillis() - startTime) > this.timeout)
+            HttpProbe httpProbe = new HttpProbe(testURL);
+            if (httpProbe.timeout(this.timeout, this.checkInterval))
             {
                 throw new BuildException("Failed to start the container after "
                     + "more than [" + this.timeout + "] ms. Trying to connect "
-                    + "to the [" + testURL + "] test URL yielded a ["
-                    + responseCode + "] error code. Please run in debug mode "
-                    + "for more details about the error.");
+                    + "to the [" + testURL + "] test URL yielded an "
+                    + "error code. Please run in debug mode for more details  "
+                    + "about the error.");
             }
-            sleep(this.checkInterval);
-            
-            responseCode = testConnectivity(testURL);
-        } while (!isAvailable(responseCode));
+        }
+        catch (InterruptedException ie)
+        {
+            throw new BuildException("Unexpected thread interruption");
+        }
+        catch (IOException io)
+        {
+            throw new BuildException("Http reading exception");
+        }
 
-        
         log("Starting up tests", Project.MSG_VERBOSE);
         try
         {
@@ -294,7 +353,7 @@
      * Sets the enterprise application archive that will be tested. It must
      * already contain the test-cases and the required libraries as a web
      * module.
-     * 
+     *
      * @param theEarFile
      *            The EAR file to set
      */
@@ -311,7 +370,7 @@
     /**
      * Sets the web application archive that will be tested. It must already
      * contain the test-cases and the required libraries.
-     * 
+     *
      * @param theWarFile
      *            The WAR file to set
      */
@@ -326,160 +385,73 @@
     }
 
     /**
-     * Sets the context url that will be tested.
-     * 
-     * @param theServletPort
-     *            The servlet port
-     */
-    public final void setServletPort(String theServletPort)
-    {
-        this.servletPort = theServletPort;
-    }
-
-    /**
-     * Sets the web application archive that should be cactified.
-     * 
-     * @param theToDir
-     *            The test report to set
-     */
-    public final void setToDir(File theToDir)
-    {
-        this.toDir = theToDir;
-    }
-    /**
-     * Sets the web application archive that should be cactified.
-     * 
-     * @param theLogs
-     *            Different logs define
+     * Sets the server host that will be tested.
+     *
+     * @param theServerName
+     *            The server host
      */
-    public final void setLogs(File theLogs)
+    public final void setServerName(String theServerName)
     {
-        this.logs = theLogs;
+        this.serverName = theServerName;
     }
-    // Private Methods ---------------------------------------------------------
 
     /**
-     * Tests whether we are able to connect to the HTTP server identified by the
-     * specified URL.
-     * 
-     * @param theUrl The URL to check
-     * @return the HTTP response code or -1 if no connection could be 
-     *         established
+     * Sets the servlet port that will be tested.
+     *
+     * @param theServletPort
+     *            The servlet port
      */
-    private int testConnectivity(URL theUrl)
+    public final void setServletPort(String theServletPort)
     {
-        int code = -1;
-        HttpURLConnection connection = null;
-        try
-        {
-            connection = (HttpURLConnection) theUrl.openConnection();
-            connection.setRequestProperty("Connection", "close");
-            connection.connect();
-            code = connection.getResponseCode();
-            readFully(connection);
-            connection.disconnect();
-        }
-        catch (IOException e)
-        {
-            log("Get status = " + code  
-                    + " when trying [" + theUrl + "]", Project.MSG_DEBUG);
-
-        }
-        return code;
+        this.servletPort = theServletPort;
     }
 
-
     /**
-     * Tests whether an HTTP return code corresponds to a valid connection
-     * to the test URL or not. Success is 200 up to but excluding 300.
-     * 
-     * @param theCode the HTTP response code to verify
-     * @return <code>true</code> if the test URL could be called without error,
-     *         <code>false</code> otherwise
+     * Sets the context url that will be tested.
+     *
+     * @param theContextURL
+     *            The context url
      */
-    private boolean isAvailable(int theCode)
+    public final void setContextURL(String theContextURL)
     {
-        boolean result;
-        if ((theCode != -1) && (theCode < 300)) 
-        {
-            result = true;            
-        }
-        else
-        {
-            result = false;
-        }
-        return result;
+        this.contextURL = theContextURL;
     }
 
     /**
-     * Retrieves the server name of the container.
-     * 
-     * @param theUrl The URL to retrieve
-     * @return The server name, or <code>null</code> if the server name could 
-     *         not be retrieved
+     * Sets the test report dir.
+     *
+     * @param theToDir
+     *            The test report to set
      */
-    private String retrieveServerName(URL theUrl)
+    public final void setToDir(File theToDir)
     {
-        String retVal = null;
-        try
-        {
-            HttpURLConnection connection = 
-                (HttpURLConnection) theUrl.openConnection();
-            connection.connect();
-            retVal = connection.getHeaderField("Server");
-            connection.disconnect();
-        }
-        catch (IOException e)
-        {
-            log("Could not get server name from [" 
-                + theUrl + "]", Project.MSG_DEBUG);
-        }
-        return retVal;
+        this.toDir = theToDir;
     }
 
     /**
-     * Fully reads the input stream from the passed HTTP URL connection to
-     * prevent (harmless) server-side exception.
+    * Sets the scope of the test.
      *
-     * @param theConnection the HTTP URL connection to read from
-     * @exception IOException if an error happens during the read
+     * @param theRunLocal
+     *            Run Local define
      */
-    static void readFully(HttpURLConnection theConnection)
-                   throws IOException
+    public final void setRunLocal(boolean theRunLocal)
     {
-        // Only read if there is data to read ... The problem is that not
-        // all servers return a content-length header. If there is no header
-        // getContentLength() returns -1. It seems to work and it seems
-        // that all servers that return no content-length header also do
-        // not block on read() operations!
-        if (theConnection.getContentLength() != 0)
-        {
-            byte[] buf = new byte[256];
-            InputStream in = theConnection.getInputStream();
-            while (in.read(buf) != -1)
-            {
-                // Make sure we read all the data in the stream
-            }
-        }
+        this.runLocal = theRunLocal;
     }
 
     /**
-     * Pauses the current thread for the specified amount.
+     * Sets the Logs.
      *
-     * @param theMs The time to sleep in milliseconds
-     * @throws BuildException If the sleeping thread is interrupted
+     * @param theLogs
+     *            Different logs define
      */
-    private void sleep(long theMs) throws BuildException
+    public final void setLogs(File theLogs)
     {
-        try
-        {
-            Thread.sleep(theMs);
-        }
-        catch (InterruptedException e)
-        {
-            throw new BuildException("Interruption during sleep", e);
-        }
+        this.logs = theLogs;
     }
+    // Private Methods ---------------------------------------------------------
+
+
     /**
      * @param theTimeout the timeout after which we stop trying to call the test
      *        URL.
@@ -493,18 +465,18 @@
      */
     public void setupLogs()
     {
-       
+
         if (this.logs == null)
         {
             throw new BuildException("Missing 'logs' attribute");
         }
-        
+
         ResourceBundle bundle = null;
         try
         {
             bundle = new PropertyResourceBundle(
                 new FileInputStream(this.logs));
-        } 
+        }
         catch (IOException e)
         {
             throw new BuildException("Failed to load properties "
@@ -516,10 +488,10 @@
             String key = (String) keys.nextElement();
             Variable var = new Variable();
             var.setKey(key);
-            var.setValue(bundle.getString(key));        
+            var.setValue(bundle.getString(key));
             super.addSysproperty(var);
-            
+
         }
-       
+
     }
 }

Added: jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/util/HttpProbe.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/util/HttpProbe.java?rev=394301&view=auto
==============================================================================
--- jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/util/HttpProbe.java (added)
+++ jakarta/cactus/trunk/integration/ant/src/java/org/apache/cactus/integration/ant/util/HttpProbe.java Sat Apr 15 08:07:26 2006
@@ -0,0 +1,202 @@
+/* 
+ * ========================================================================
+ * 
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.integration.ant.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+/**
+ * Support class that probes a URL. 
+ * 
+ * 
+ * @version $Id: HttpProbe.java,v 1.0 2005/08/29 10:19:57 xnguyen Exp $
+ */
+public class HttpProbe
+{
+
+    // Instance Variables ------------------------------------------------------
+
+    /**
+     * The URL.
+     */
+    private URL url;
+
+    // Constructors ------------------------------------------------------------
+
+    /**
+     * Constructor.
+     * 
+     * @param theUrl The Url
+     */
+    public HttpProbe(URL theUrl) 
+    {
+        this.url = theUrl;
+    }
+    
+    /**
+     * In thread tests whether we are able to connect to the 
+     * HTTP server identified by the
+     * specified URL. The caller thread is blocked.
+     * @param theWaitedTime The time waiting 
+     * @param theCheckedInterval The interval to check
+     * @throws InterruptedException If the current Thread is interupted
+     * @throws IOException If there is error with reading
+     * @return the HTTP response code or -1 if no connection could be
+     *         established
+     */
+    public boolean timeout(long theWaitedTime, long theCheckedInterval)
+        throws InterruptedException, IOException
+    {
+        //Ping the container
+        //Continuously try calling the test URL until it succeeds or
+        // until a timeout is reached (we then throw a build exception).
+        long startTime = System.currentTimeMillis();
+        int responseCode = -1;
+        do
+        {
+            if ((System.currentTimeMillis() - startTime) > theWaitedTime)
+            {
+                return true;
+
+            }
+
+            sleep(theCheckedInterval);
+
+            responseCode = testConnectivity();
+
+
+        } while (!isAvailable(responseCode));
+        
+        return false;
+
+    }
+ 
+ 
+    /**
+     * Tests whether we are able to connect to the HTTP server identified by the
+     * specified URL.
+     * @throws IOException If there is reading error
+     * @return the HTTP response code or -1 if no connection could be
+     *         established
+     */
+    public int testConnectivity() throws IOException
+    {
+        int code = -1;
+        HttpURLConnection connection = null;
+       
+        connection = (HttpURLConnection) url.openConnection();
+        connection.setRequestProperty("Connection", "close");
+        connection.connect();
+        code = connection.getResponseCode();
+        readFully(connection);
+        connection.disconnect();
+      
+        return code;
+    }
+
+
+    /**
+     * Tests whether an HTTP return code corresponds to a valid connection
+     * to the test URL or not. Success is 200 up to but excluding 300.
+     *
+     * @param theCode the HTTP response code to verify
+     * @return <code>true</code> if the test URL could be called without error,
+     *         <code>false</code> otherwise
+     */
+    private boolean isAvailable(int theCode)
+    {
+        boolean result;
+        if ((theCode != -1) && (theCode < 300))
+        {
+            result = true;
+        }
+        else
+        {
+            result = false;
+        }
+        return result;
+    }
+
+    /**
+     * Retrieves the server name of the container.
+     *
+     * @return The server name, or <code>null</code> if the server name could
+     *         not be retrieved
+     * @throws IOException If there is error when reading
+     */
+    private String retrieveServerName() throws IOException
+    {
+        String retVal = null;
+        
+        HttpURLConnection connection =
+            (HttpURLConnection) url.openConnection();
+        connection.connect();
+        retVal = connection.getHeaderField("Server");
+        connection.disconnect();
+       
+        return retVal;
+    }
+
+    /**
+     * Fully reads the input stream from the passed HTTP URL connection to
+     * prevent (harmless) server-side exception.
+     *
+     * @param theConnection the HTTP URL connection to read from
+     * @exception IOException if an error happens during the read
+     */
+    private void readFully(HttpURLConnection theConnection)
+                   throws IOException
+    {
+        // Only read if there is data to read ... The problem is that not
+        // all servers return a content-length header. If there is no header
+        // getContentLength() returns -1. It seems to work and it seems
+        // that all servers that return no content-length header also do
+        // not block on read() operations!
+        if (theConnection.getContentLength() != 0)
+        {
+            byte[] buf = new byte[256];
+            InputStream in = theConnection.getInputStream();
+            while (in.read(buf) != -1)
+            {
+                // Make sure we read all the data in the stream
+            }
+        }
+    }
+
+    /**
+     * Pauses the current thread for the specified amount.
+     *
+     * @param theMs The time to sleep in milliseconds
+     * @throws InterruptedException If the sleeping thread is interrupted
+     */
+    private void sleep(long theMs) throws InterruptedException
+    {
+
+            Thread.sleep(theMs);
+ 
+    }
+
+    // Private Methods ---------------------------------------------------------
+
+
+
+}

Added: jakarta/cactus/trunk/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactustest.xml
URL: http://svn.apache.org/viewcvs/jakarta/cactus/trunk/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactustest.xml?rev=394301&view=auto
==============================================================================
--- jakarta/cactus/trunk/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactustest.xml (added)
+++ jakarta/cactus/trunk/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactustest.xml Sat Apr 15 08:07:26 2006
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+
+<project name="test-cactustest" basedir="." default="setup">
+
+  <target name="testNeitherWarFileNorEarFileSet">
+    <cactustests/>
+  </target>
+
+  <target name="testWarFileNotExisting">
+    <cactustests runlocal="true" warfile="idontexist.war"/>
+  </target>
+
+  <target name="testWarFileNotCactified">
+    <cactustests runlocal="true" warfile="empty.war"/>
+  </target>
+
+  <target name="testWarFileCactified">
+    <cactustests runlocal="true" warfile="cactified.war"/>
+  </target>
+
+  <target name="testEarFileEmpty">
+    <cactustests runlocal="true" earfile="empty.ear"/>
+  </target>
+
+  <target name="testEarFileNotCactified">
+    <cactustests runlocal="true" earfile="notcactified.ear"/>
+  </target>
+
+  <target name="testEarFileCactified">
+    <cactustests runlocal="true" earfile="cactified.ear"/>
+  </target>
+
+</project>

Modified: jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestAll.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestAll.java?rev=394301&r1=394300&r2=394301&view=diff
==============================================================================
--- jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestAll.java (original)
+++ jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestAll.java Sat Apr 15 08:07:26 2006
@@ -37,16 +37,12 @@
     {
         TestSuite suite = new TestSuite(
             "Unit tests for the Ant integration classes");
-
-        suite.addTest(
-            org.apache.cactus.integration.ant.container.TestAll.suite());
         suite.addTest(
             org.apache.cactus.integration.ant.deployment.TestAll.suite());
 
         suite.addTestSuite(TestCactifyWarTask.class);
-        suite.addTestSuite(TestCactusTask.class);
-        suite.addTestSuite(TestContainerSet.class);
-        suite.addTestSuite(TestRunServerTestsTask.class);
+        suite.addTestSuite(TestCactusTestTask.class);
+        //suite.addTestSuite(TestRunServerTestsTask.class);
 
         return suite;
     }

Added: jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactusTestTask.java
URL: http://svn.apache.org/viewcvs/jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactusTestTask.java?rev=394301&view=auto
==============================================================================
--- jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactusTestTask.java (added)
+++ jakarta/cactus/trunk/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactusTestTask.java Sat Apr 15 08:07:26 2006
@@ -0,0 +1,176 @@
+/* 
+ * ========================================================================
+ * 
+ * Copyright 2003 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.integration.ant;
+
+import org.apache.tools.ant.BuildException;
+
+/**
+ * Unit tests for {@link CactusTask}.
+ * 
+ * @version $Id: TestCactusTask.java,v 1.14 2004/02/29 10:21:34 vmassol Exp $
+ */
+public final class TestCactusTestTask extends AntTestCase
+{
+
+    // Constructors ------------------------------------------------------------
+
+    /**
+     * @see AntTestCase#AntTestCase
+     */
+    public TestCactusTestTask()
+    {
+        super("org/apache/cactus/integration/ant/test-cactustest.xml");
+    }
+
+    // TestCase Implementation -------------------------------------------------
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        getProject().addTaskDefinition("cactustests", CactusTestTask.class);
+    }
+
+    // Test Methods ------------------------------------------------------------
+
+    /**
+     * Verifies that the task throws an exception when the warfile attribute 
+     * has not been set.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testNeitherWarFileNorEarFileSet() throws Exception
+    {
+        try
+        {
+            executeTestTarget();
+            fail("Expected BuildException");
+        }
+        catch (BuildException expected)
+        {
+            assertEquals("You must specify either the [warfile] or the "
+                + "[earfile] attribute", expected.getMessage());
+        }
+    }
+
+    /**
+     * Verifies that the task throws an exception when the warfile attribute 
+     * is set to a non-existing file.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testWarFileNotExisting() throws Exception
+    {
+        try
+        {
+            executeTestTarget();
+            fail("Expected BuildException");
+        }
+        catch (BuildException expected)
+        {
+            assertTrue(true);
+        }
+    }
+
+    /**
+     * Verifies that the task throws an exception when the warfile attribute 
+     * is set to a web-app archive that has not been cactified.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testWarFileNotCactified() throws Exception
+    {
+        try
+        {
+            executeTestTarget();
+            fail("Expected BuildException");
+        }
+        catch (BuildException expected)
+        {
+            assertEquals("The WAR has not been cactified",
+                expected.getMessage());
+        }
+    }
+
+    /**
+     * Verifies that the task does nothing if it is given a cactified web
+     * application, but neither tests nor containers.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testWarFileCactified() throws Exception
+    {
+        executeTestTarget();
+    }
+
+    /**
+     * Verifies that the task throws an exception when the earfile attribute 
+     * is set to an empty enterprise application archive.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testEarFileEmpty() throws Exception
+    {
+        try
+        {
+            executeTestTarget();
+            fail("Expected BuildException");
+        }
+        catch (BuildException expected)
+        {
+            assertTrue(true);
+        }
+    }
+
+    /**
+     * Verifies that the task throws an exception when the earfile attribute 
+     * is set to an enterprise application archive that doesn't contain a web
+     * module with the definition of the test redirectors.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testEarFileNotCactified() throws Exception
+    {
+        try
+        {
+            executeTestTarget();
+            fail("Expected BuildException");
+        }
+        catch (BuildException expected)
+        {
+            assertTrue(true);
+        }
+    }
+
+    /**
+     * Verifies that the task does nothing if it is given a cactified enterprise
+     * application, but neither tests nor containers.
+     * 
+     * @throws Exception If an unexpected error occurs
+     */
+    public void testEarFileCactified() throws Exception
+    {
+        executeTestTarget();
+    }
+
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org