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 cm...@apache.org on 2003/05/13 12:40:53 UTC

cvs commit: jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant TestCactifyWarTask.java

cmlenz      2003/05/13 03:40:53

  Modified:    integration/ant/src/test-input/org/apache/cactus/integration/ant
                        test-cactifywar.xml
               integration/ant/src/test/org/apache/cactus/integration/ant
                        TestCactifyWarTask.java
  Log:
  Adapt tests to the fact that 'srcfile' is now optional.
  Add tests for the use of <cactifywar> without a 'srcfile' attribute
  
  Revision  Changes    Path
  1.2       +11 -1     jakarta-cactus/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactifywar.xml
  
  Index: test-cactifywar.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/test-input/org/apache/cactus/integration/ant/test-cactifywar.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- test-cactifywar.xml	13 May 2003 10:15:26 -0000	1.1
  +++ test-cactifywar.xml	13 May 2003 10:40:53 -0000	1.2
  @@ -14,7 +14,7 @@
       </xmlcatalog>
     </target>
   
  -  <target name="testSrcFileNotSet">
  +  <target name="testNeitherSrcFileNorVersionSet">
       <cactifywar destfile="destfile.war"/>
     </target>
   
  @@ -39,6 +39,16 @@
           destfile="${work.dir}/destfile.war">
         <xmlcatalog refid="j2ee.dtds"/>
       </cactifywar>
  +  </target>
  +
  +  <target name="testDefaultRedirectorsNewWar22">
  +    <cactifywar version="2.2"
  +        destfile="${work.dir}/destfile.war"/>
  +  </target>
  +
  +  <target name="testDefaultRedirectorsNewWar23">
  +    <cactifywar version="2.3"
  +        destfile="${work.dir}/destfile.war"/>
     </target>
   
     <target name="tearDown">
  
  
  
  1.2       +71 -7     jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactifyWarTask.java
  
  Index: TestCactifyWarTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/TestCactifyWarTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCactifyWarTask.java	13 May 2003 10:15:26 -0000	1.1
  +++ TestCactifyWarTask.java	13 May 2003 10:40:53 -0000	1.2
  @@ -64,6 +64,7 @@
   
   import org.apache.cactus.integration.ant.webxml.WebXml;
   import org.apache.cactus.integration.ant.webxml.WebXmlIo;
  +import org.apache.cactus.integration.ant.webxml.WebXmlVersion;
   import org.apache.tools.ant.BuildException;
   import org.xml.sax.EntityResolver;
   import org.xml.sax.InputSource;
  @@ -132,12 +133,12 @@
       // Test Methods ------------------------------------------------------------
   
       /**
  -     * Verifies that the task throws an exception when the srcfile attribute 
  -     * has not been set.
  +     * Verifies that the task throws an exception when neither the srcfile
  +     * nor the version attribute has been set.
        * 
        * @throws Exception If an unexpected error occurs
        */
  -    public void testSrcFileNotSet() throws Exception
  +    public void testNeitherSrcFileNorVersionSet() throws Exception
       {
           try
           {
  @@ -146,8 +147,8 @@
           }
           catch (BuildException expected)
           {
  -            assertEquals("The [srcfile] attribute is required",
  -                expected.getMessage());
  +            assertEquals("You need to specify either the [srcfile] or the "
  +                + "[version] attribute", expected.getMessage());
           }
       }
   
  @@ -204,7 +205,7 @@
           {
               destWar.close();
           }
  -   }
  +    }
   
       /**
        * Tests whether the Cactus test redirectors are correctly added to the 
  @@ -253,6 +254,69 @@
               WebXml webXml = WebXmlIo.parseWebXml(destWar,
                   new NullEntityResolver());
               
  +            assertServletMapping(webXml,
  +                "org.apache.cactus.server.ServletTestRedirector",
  +                "/ServletRedirector");
  +            assertJspMapping(webXml, "/jspRedirector.jsp", "/JspRedirector");
  +            assertFilterMapping(webXml,
  +                "org.apache.cactus.server.FilterTestRedirector",
  +                "/FilterRedirector");
  +        }
  +        finally
  +        {
  +            destWar.close();
  +        }
  +    }
  +
  +    /**
  +     * Tests whether the Cactus test redirectors are correctly added to the 
  +     * descriptor of a WAR when no srcfile attribute had been set, and the 
  +     * version has been set to 2.2.
  +     * 
  +     * @throws Exception If an unexpected error occurs
  +     */
  +    public void testDefaultRedirectorsNewWar22() throws Exception
  +    {
  +        executeTestTarget();
  +
  +        File destFile = getProject().resolveFile("work/destfile.war");
  +        JarFile destWar = new JarFile(destFile);
  +        try
  +        {
  +            WebXml webXml = WebXmlIo.parseWebXml(destWar,
  +                new NullEntityResolver());
  +            assertEquals(WebXmlVersion.V2_2, webXml.getVersion());
  +            assertServletMapping(webXml,
  +                "org.apache.cactus.server.ServletTestRedirector",
  +                "/ServletRedirector");
  +            assertJspMapping(webXml, "/jspRedirector.jsp", "/JspRedirector");
  +            assertTrue("Filter test redirector should not have been defined",
  +                !webXml.getFilterNames().hasNext());
  +        }
  +        finally
  +        {
  +            destWar.close();
  +        }
  +    }
  +
  +    /**
  +     * Tests whether the Cactus test redirectors are correctly added to the 
  +     * descriptor of a WAR when no srcfile attribute had been set, and the 
  +     * version has been set to 2.3.
  +     * 
  +     * @throws Exception If an unexpected error occurs
  +     */
  +    public void testDefaultRedirectorsNewWar23() throws Exception
  +    {
  +        executeTestTarget();
  +
  +        File destFile = getProject().resolveFile("work/destfile.war");
  +        JarFile destWar = new JarFile(destFile);
  +        try
  +        {
  +            WebXml webXml = WebXmlIo.parseWebXml(destWar,
  +                new NullEntityResolver());
  +            assertEquals(WebXmlVersion.V2_3, webXml.getVersion());
               assertServletMapping(webXml,
                   "org.apache.cactus.server.ServletTestRedirector",
                   "/ServletRedirector");
  
  
  

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