craigmcc    2002/06/15 17:37:12

  Modified:    .        build.xml
               conf/test cactus.properties
               src/test/org/apache/struts/action TestActionServlet.java
               src/test/org/apache/struts/config TestApplicationConfig.java
  Log:
  Update the tests so that "ant test" will at least compile and run (some
  changes for the Struts 1.1 version of ActionServlet were needed.
  
  The test configuration assumes Cactus version 1.3 has been installed,
  and you have "cactus.home" pointing at the installation directory.
  
  The test for ActionServlet is still commented out -- it tries to go
  to the servlet redirector even though it hasn't been installed yet.
  
  Revision  Changes    Path
  1.69      +24 -4     jakarta-struts/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/build.xml,v
  retrieving revision 1.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- build.xml 15 Jun 2002 23:12:31 -0000      1.68
  +++ build.xml 16 Jun 2002 00:37:12 -0000      1.69
  @@ -218,7 +218,6 @@
     <path id="test.classpath">
       <pathelement location="${build.home}/library/classes"/>
       <pathelement location="${build.home}/test/classes"/>
  -    <pathelement location="${cactus.jar}"/>
       <pathelement location="${commons-beanutils.jar}"/>
       <pathelement location="${commons-collections.jar}"/>
       <pathelement location="${commons-dbcp.jar}"/>
  @@ -228,11 +227,13 @@
       <pathelement location="${commons-services.jar}"/>
       <pathelement location="${commons-validator.jar}"/>
       <pathelement location="${jakarta-oro.jar}"/>
  -    <pathelement location="${servlet.jar}"/>
  -    <pathelement location="${junit.jar}"/>
       <pathelement location="${jdbc20ext.jar}"/>
       <pathelement location="${servlet.jar}"/>
       <pathelement location="${xerces.jar}"/>
  +    <fileset dir="${cactus.home}/lib">
  +      <exclude name="log4j*.jar"/>
  +      <include name="*.jar"/>
  +    </fileset>
     </path>
   
     <!-- Should all tests fail if one does? -->
  @@ -707,7 +708,9 @@
   
       <!-- ========== Non-Cactus Unit Tests ================================= -->
   
  -    <target name="test" depends="test.compile,test.config"
  +    <target name="test" depends="test.compile,
  +                                 test.action,
  +                                 test.config"
        description="Run all non-Cactus based unit tests">
       </target>
   
  @@ -723,7 +726,24 @@
         <copy   todir="${build.home}/test/classes">
           <fileset dir="${src.test.dir}" excludes="**/*.java"/>
         </copy>
  +      <copy   todir="${build.home}/test/classes">
  +        <fileset dir="${conf.test.dir}" includes="cactus.properties"/>
  +      </copy>
  +    </target>
  +
  +
  +    <target name="test.action">
  +      <echo message="Running Action Package tests ..."/>
  +      <echo message="^^^^ Disabled due to Cactus-reported errors for now"/>
  +<!--
  +      <java classname="${test.runner}" fork="yes"
  +          failonerror="${test.failonerror}">
  +        <arg value="org.apache.struts.action.TestActionServlet"/>
  +        <classpath refid="test.classpath"/>
  +      </java>
  +-->
       </target>
  +
   
       <target name="test.config">
         <echo message="Running Config Package tests ..."/>
  
  
  
  1.2       +6 -13     jakarta-struts/conf/test/cactus.properties
  
  Index: cactus.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/conf/test/cactus.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- cactus.properties 6 May 2001 12:07:32 -0000       1.1
  +++ cactus.properties 16 Jun 2002 00:37:12 -0000      1.2
  @@ -1,14 +1,7 @@
  -# Configuration file for J2EEUnit.
  -
  -# Each project using J2EEUnit need to have such a file put in the CLASSPATH
  -# (Meaning the directory containgin this file should be in the CLASSPATH, not
  -# the file itself of course ... :) )
  -
  -# Defines the URLs that will be used by J2EEUnit to call it's redirectors
  -# (Servlet and JSP). You need to specify in these URLs the webapp context
  -# that you use for your application. In the example below, the context is
  -# "test".
  -
  -cactus.servletRedirectorURL = http://localhost:8080/test/ServletRedirector
  -cactus.jspRedirectorURL = http://localhost:8080/test/JspRedirector
  +# Configuration file for Cactus Testing of Struts 1.1
   
  +cactus.contextURL = http://localhost:8080/test
  +cactus.enableLogging = false
  +cactus.filterRedirectorName = FilterRedirector
  +cactus.jspRedirectorName = JspRedirector
  +cactus.servletRedirectorName = ServletRedirector
  
  
  
  1.3       +38 -4     
jakarta-struts/src/test/org/apache/struts/action/TestActionServlet.java
  
  Index: TestActionServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/test/org/apache/struts/action/TestActionServlet.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestActionServlet.java    26 Dec 2001 21:55:55 -0000      1.2
  +++ TestActionServlet.java    16 Jun 2002 00:37:12 -0000      1.3
  @@ -59,6 +59,8 @@
   import junit.framework.*;
   import org.apache.cactus.*;
   
  +import org.apache.struts.util.MessageResources;
  +
   /**
    * Suite of unit tests for the
    * <code>org.apache.struts.action.ActionServlet</code> class.
  @@ -95,12 +97,41 @@
           return new TestSuite(TestActionServlet.class);
       }
   
  +
  +    // ----------------------------- initInternal() and destroyInternal() tests
  +
  +
  +    /**
  +     * Verify that we can initialize and destroy our internal message
  +     * resources object.
  +     */
  +    public void testInitDestroyInternal() {
  +
  +        ActionServlet servlet = new ActionServlet();
  +        try {
  +            servlet.initInternal();
  +        } catch (ServletException e) {
  +            fail("initInternal() threw exception: " + e);
  +        }
  +        assertTrue("internal was initialized",
  +                   servlet.getInternal() != null);
  +        assertTrue("internal of correct type",
  +                   servlet.getInternal() instanceof MessageResources);
  +        servlet.destroyInternal();
  +        assertTrue("internal was destroyed",
  +                   servlet.getInternal() == null);
  +
  +    }
  +
  +
  +
       //----- Test initApplication() method --------------------------------------
   
       /**
        * Verify that nothing happens if no "application" property is defined in
        * the servlet configuration.
        */
  +    /*
       public void testInitApplicationNull() throws ServletException
       {
           ActionServlet servlet = new ActionServlet();
  @@ -111,13 +142,15 @@
   
           // As no "application" object is found in the servlet config, no
           // attribute should be set in the context
  -        assert(config.getServletContext().getAttribute(Action.MESSAGES_KEY) == 
null);
  +        assertTrue(config.getServletContext().getAttribute(Action.MESSAGES_KEY) == 
null);
       }
  +    */
   
       /**
        * Verify that eveything is fine when only a "application" parameter is
        * defined in the servlet configuration.
        */
  +    /*
       public void testInitApplicationOk1() throws ServletException
       {
           // initialize config
  @@ -129,13 +162,14 @@
           // Test the initApplication() method
           servlet.initApplication();
   
  -        assert(servlet.application != null);
  -        assert(servlet.application.getReturnNull() == true);
  +        assertTrue(servlet.application != null);
  +        assertTrue(servlet.application.getReturnNull() == true);
   
  -        assert(config.getServletContext().getAttribute(Action.MESSAGES_KEY) != 
null);
  +        assertTrue(config.getServletContext().getAttribute(Action.MESSAGES_KEY) != 
null);
           assertEquals(servlet.application, 
config.getServletContext().getAttribute(Action.MESSAGES_KEY));
   
       }
  +    */
   
       // [...]
   }
  
  
  
  1.2       +8 -4      
jakarta-struts/src/test/org/apache/struts/config/TestApplicationConfig.java
  
  Index: TestApplicationConfig.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/test/org/apache/struts/config/TestApplicationConfig.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestApplicationConfig.java        26 Dec 2001 21:55:55 -0000      1.1
  +++ TestApplicationConfig.java        16 Jun 2002 00:37:12 -0000      1.2
  @@ -57,6 +57,7 @@
   
   
   import java.io.InputStream;
  +import java.util.Map;
   import java.net.URL;
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -107,7 +108,7 @@
        */
       public void setUp() {
   
  -        config = new ApplicationConfig("", null);
  +        config = new ApplicationConfig("");
   
       }
   
  @@ -144,7 +145,6 @@
           // Prepare a Digester for parsing a struts-config.xml file
           Digester digester = new Digester();
           digester.push(config);
  -        digester.setDebug(0);
           digester.setNamespaceAware(true);
           digester.setValidating(true);
           digester.addRuleSet(new ConfigRuleSet());
  @@ -170,9 +170,13 @@
           DataSourceConfig dsc =
               config.findDataSourceConfig(Action.DATA_SOURCE_KEY);
           assertNotNull("Found our data source configuration", dsc);
  +        assertEquals("Data source driverClass",
  +                     "org.postgresql.Driver",
  +                     (String) dsc.getProperties().get("driverClass"));
  +
           assertEquals("Data source description",
                        "Example Data Source Configuration",
  -                     dsc.getDescription());
  +                     (String) dsc.getProperties().get("description"));
   
           FormBeanConfig fbcs[] = config.findFormBeanConfigs();
           assertNotNull("Found our form bean configurations", fbcs);
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to