vmassol     2003/06/07 06:07:52

  Modified:    samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit
                        TestSetURL.java
               framework/src/java/share/org/apache/cactus/server
                        AbstractHttpServletRequestWrapper.java
               documentation/docs/xdocs changes.xml
  Log:
  Fixed HttpServletRequestWrapper behaviors when using null values in the setURL call.
  
  Revision  Changes    Path
  1.8       +3 -1      
jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestSetURL.java
  
  Index: TestSetURL.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestSetURL.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestSetURL.java   7 Jun 2003 11:26:05 -0000       1.7
  +++ TestSetURL.java   7 Jun 2003 13:07:51 -0000       1.8
  @@ -253,6 +253,8 @@
        */
       public void testSimulatedURLNullValues()
       {
  +        assertNotNull(request.getServerName());
  +        assertTrue(request.getServerPort() > 0);
           assertNotNull(request.getContextPath());       
           assertNotNull(request.getServletPath());       
           assertEquals("", request.getPathInfo());       
  
  
  
  1.16      +12 -16    
jakarta-cactus/framework/src/java/share/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java
  
  Index: AbstractHttpServletRequestWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/AbstractHttpServletRequestWrapper.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AbstractHttpServletRequestWrapper.java    7 Jun 2003 11:26:05 -0000       1.15
  +++ AbstractHttpServletRequestWrapper.java    7 Jun 2003 13:07:51 -0000       1.16
  @@ -215,42 +215,38 @@
   
       /**
        * @return the server name from the simulated URL or the real server name
  -     *         if a simulation URL has not been defined.
  +     *         if a simulation URL has not been defined. If the server name
  +     *         defined in the simulation URL is null, return the real server
  +     *         name.
        */
       public String getServerName()
       {
  -        String result;
  +        String result = this.request.getServerName();
   
  -        if (this.url != null)
  +        if ((this.url != null) && (this.url.getHost() != null))
           {
               result = this.url.getHost();
               LOGGER.debug("Using simulated server name : [" + result + "]");
           }
  -        else
  -        {
  -            result = this.request.getServerName();
  -        }
   
           return result;
       }
   
       /**
        * @return the server port number from the simulated URL or the real server
  -     *         port number if a simulation URL has not been defined. If not
  -     *         port is defined, then port 80 is returned.
  +     *         port number if a simulation URL has not been defined. If no
  +     *         port is defined in the simulation URL, then port 80 is returned.
  +     *         If the server name has been defined with a null value in
  +     *         in the simulation URL, return the real server port. 
        */
       public int getServerPort()
       {
  -        int result;
  +        int result = this.request.getServerPort();
   
  -        if (this.url != null)
  +        if ((this.url != null) && (this.url.getServerName() != null))
           {
               result = (this.url.getPort() == -1) ? 80 : this.url.getPort();
               LOGGER.debug("Using simulated server port : [" + result + "]");
  -        }
  -        else
  -        {
  -            result = this.request.getServerPort();
           }
   
           return result;
  
  
  
  1.102     +5 -3      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.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- changes.xml       7 Jun 2003 11:35:42 -0000       1.101
  +++ changes.xml       7 Jun 2003 13:07:51 -0000       1.102
  @@ -77,11 +77,13 @@
           </action>
           <action dev="VMA" type="fix">
             When a simulation URL is used and null values are passed for the
  -          Context Path and Servlet Path parameters, calls to Cactus
  +          Server name, Context Path and Servlet Path parameters, calls to 
  +          Cactus <code>HttpServletRequestWrapper.getServerName()</code>,
  +          <code>HttpServletRequestWrapper.getServerPort()</code>,
             <code>HttpServletRequestWrapper.getContextPath()</code> and
             <code>HttpServletRequestWrapper.getServletPath()</code> now correctly
  -          return the Context Path and Servlet Path from the original Request
  -          (and not the wrapped one) handled by the Servlet Redirector.
  +          return the values from the original Request object
  +          (and not the wrapped one), handled by the Servlet Redirector.
           </action>
           <action dev="VMA" type="update">
             Added verification code in Cactus to verify that the parameters 
  
  
  

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

Reply via email to