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 vm...@apache.org on 2003/08/29 19:17:32 UTC

cvs commit: jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container AbstractContainer.java

vmassol     2003/08/29 10:17:32

  Modified:    integration/ant/src/test/org/apache/cactus/integration/ant/container
                        TestAll.java
               documentation/docs/xdocs changes.xml
               integration/ant/src/java/org/apache/cactus/integration/ant/container
                        AbstractContainer.java
  Added:       integration/ant/src/test/org/apache/cactus/integration/ant/container
                        TestAbstractContainer.java
  Log:
  The problem was that for EAR files the cactus.context filter token was not defined. It is needed by the Orion's application.xml file for example. Thanks to Jonathan Kovacs.
  
  Revision  Changes    Path
  1.4       +3 -12     jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/TestAll.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestAll.java	26 May 2003 13:27:20 -0000	1.3
  +++ TestAll.java	29 Aug 2003 17:17:32 -0000	1.4
  @@ -64,22 +64,12 @@
    * Run all the unit tests for the container support classes.
    *
    * @author <a href="mailto:cmlenz@apache.org">Christopher Lenz</a>
  + * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
    *
    * @version $Id$
    */
   public final class TestAll extends TestCase
   {
  -
  -    /**
  -     * Start the tests.
  -     *
  -     * @param theArgs the arguments. Not used
  -     */
  -    public static void main(String[] theArgs)
  -    {
  -        junit.swingui.TestRunner.main(new String[] {TestAll.class.getName()});
  -    }
  -
       /**
        * @return a test suite (<code>TestSuite</code>) that includes all methods
        *         starting with "test"
  @@ -90,6 +80,7 @@
               "Unit tests for the container support classes");
   
           suite.addTestSuite(TestContainerRunner.class);
  +        suite.addTestSuite(TestAbstractContainer.class);
   
           return suite;
       }
  
  
  
  1.1                  jakarta-cactus/integration/ant/src/test/org/apache/cactus/integration/ant/container/TestAbstractContainer.java
  
  Index: TestAbstractContainer.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Cactus" and "Apache Software
   *    Foundation" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  package org.apache.cactus.integration.ant.container;
  
  import java.io.File;
  import java.io.StringReader;
  import java.util.Vector;
  
  import org.apache.tools.ant.filters.util.ChainReaderHelper;
  import org.apache.tools.ant.types.FilterChain;
  
  import junit.framework.TestCase;
  
  /**
   * Unit tests for {@link AbstractContainer}.
   *  
   * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
   *
   * @version $Id: TestAbstractContainer.java,v 1.1 2003/08/29 17:17:32 vmassol Exp $
   */
  public class TestAbstractContainer extends TestCase
  {
      /**
       * The instance to test
       */
      private AbstractContainer container;
  
      /**
       * @see TestCase#setUp()
       */    
      protected void setUp()
      {
          this.container = new AbstractContainer()
          {
              public String getName()
              {
                  return "test container";
              }
  
              public int getPort()
              {
                  return 8080;
              }
  
              public void startUp()
              {
              }
              
              public void shutDown()
              {                
              }
          };
      }
  
      /**
       * Verify that the Ant filter chain is correctly configured to 
       * replace the "cactus.port" and "cactus.context" tokens.
       *  
       * @throws Exception if an error happens during the test
       */
      public void testCreateFilterChainOk() throws Exception
      {
          File earFile = new File("test.ear");
          this.container.setDeployableFile(earFile);
          String buffer = "@cactus.port@:@cactus.context@";
                          
          FilterChain chain = this.container.createFilterChain();        
  
          ChainReaderHelper helper = new ChainReaderHelper();
          Vector chains = new Vector();
          chains.addElement(chain);
          helper.setFilterChains(chains);
          helper.setPrimaryReader(new StringReader(buffer));
          assertEquals("8080:test", 
              helper.readFully(helper.getAssembledReader()));
      }
  }
  
  
  
  1.130     +7 -1      jakarta-cactus/documentation/docs/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/documentation/docs/xdocs/changes.xml,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- changes.xml	9 Aug 2003 16:48:34 -0000	1.129
  +++ changes.xml	29 Aug 2003 17:17:32 -0000	1.130
  @@ -71,6 +71,12 @@
         </release>
         
         <release version="1.5-rc1" date="in CVS">
  +        <action dev="VMA" type="fix" fixes-bug="22794" due-to="Jonathan Kovacs" due-to-email="jdk@jdk.ca">
  +          In the Ant integration, the <code>cactus.context</code> filter token 
  +          was not correctly defined for EAR files. However, it is needed. For 
  +          example the default Orion's <code>application.xml</code> config file 
  +          provided by Cactus needs it.
  +        </action>
           <action dev="VMA" type="fix" fixes-bug="22249" due-to="James Stangler" due-to-email="jastangler@yahoo.com">
             Fixed the <code>JettyTestSetup</code> class so that it stops the
             running Jetty server at the end of the test suite execution.
  @@ -93,7 +99,7 @@
             In the cactifywar Ant task, changed the default realm name
             that is used when adding Cactus default configuration data.
             It was previously <code>Cactus test realm</code>. It is now 
  -          <code>myrealm</code>. The reason is that the default WebLogic 
  +          <code>myrealm</code>. The reas on is that the default WebLogic 
             configuration creates a <code>myrealm</code> realm and thus
             using this name makes our Cactus configuration for WebLogic 
             much simpler. It doesn't affect the other containers as they
  
  
  
  1.7       +14 -12    jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/AbstractContainer.java
  
  Index: AbstractContainer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/integration/ant/src/java/org/apache/cactus/integration/ant/container/AbstractContainer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- AbstractContainer.java	11 Jun 2003 16:17:26 -0000	1.6
  +++ AbstractContainer.java	29 Aug 2003 17:17:32 -0000	1.7
  @@ -318,23 +318,25 @@
       {
           ReplaceTokens.Token token = null;
           FilterChain filterChain = new FilterChain();
  +
  +        // Token for the cactus port
           ReplaceTokens replacePort = new ReplaceTokens();
           token = new ReplaceTokens.Token();
           token.setKey("cactus.port");
           token.setValue(String.valueOf(getPort()));
           replacePort.addConfiguredToken(token);
           filterChain.addReplaceTokens(replacePort);
  -        if (isWar(getDeployableFile()))
  -        {
  -            ReplaceTokens replaceContext = new ReplaceTokens();
  -            token = new ReplaceTokens.Token();
  -            token.setKey("cactus.context");
  -            String contextPath = getDeployableFile().getName();
  -            contextPath = contextPath.substring(0, contextPath.length() - 4); 
  -            token.setValue(contextPath);
  -            replaceContext.addConfiguredToken(token);
  -            filterChain.addReplaceTokens(replaceContext);
  -        }
  +
  +        // Token for the cactus webapp context 
  +        ReplaceTokens replaceContext = new ReplaceTokens();
  +        token = new ReplaceTokens.Token();
  +        token.setKey("cactus.context");
  +        String contextPath = getDeployableFile().getName();
  +        contextPath = contextPath.substring(0, contextPath.length() - 4); 
  +        token.setValue(contextPath);
  +        replaceContext.addConfiguredToken(token);
  +        filterChain.addReplaceTokens(replaceContext);
  +
           return filterChain;
       }