vmassol     01/06/28 14:27:01

  Modified:    cactus/docs/framework/xdocs changes.xml todo.xml
               cactus/src/framework/share/org/apache/commons/cactus
                        ServletTestRequest.java
               cactus/src/sample/share/org/apache/commons/cactus/sample/unit
                        TestServletTestCase4.java
  Log:
  Automatically add the query string parameters defined when using the 
ServletTestRequest.setURL() API to the list of parameters passed to the server 
redirector, so that it won't be necessary to call ServletTestRequest.addParameter() 
for each of these parameters.
  
  Revision  Changes    Path
  1.25      +8 -0      jakarta-commons/cactus/docs/framework/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cactus/docs/framework/xdocs/changes.xml,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- changes.xml       2001/06/27 20:45:29     1.24
  +++ changes.xml       2001/06/28 21:26:58     1.25
  @@ -23,9 +23,17 @@
       </devs>
   
       <release version="1.2 in CVS">
  +      <action dev="VMA" type="add" due-to="Jari Worsley" 
due-to-email="[EMAIL PROTECTED]">
  +        Now all HTTP parameters specified in the URL when using the
  +        <code>ServletTestRequest.setURL()</code> method are automatically
  +        passed as real HTTP parameters to the server side, meaning you don't
  +        have to manually call <code>addParameters()</code>.
  +      </action>
         <action dev="VMA" type="fix" due-to="Kunal Vaishnav" 
due-to-email="[EMAIL PROTECTED]">
           Fixed bug : URL encoding was applied to cookies so that when passing
           a special in a cookie it would get encoded when trying to retrieve it.
  +        Thanks to <link href="mailto:[EMAIL PROTECTED]";>
  +        Jari Worsley</link> for fixing it.
         </action>
       </release>
   
  
  
  
  1.26      +0 -7      jakarta-commons/cactus/docs/framework/xdocs/todo.xml
  
  Index: todo.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/cactus/docs/framework/xdocs/todo.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- todo.xml  2001/06/28 08:21:06     1.25
  +++ todo.xml  2001/06/28 21:26:58     1.26
  @@ -72,13 +72,6 @@
         custommonkey).
       </action>
       <action context="code">
  -      Automatically add the query string parameters defined when using the
  -      <code>ServletTestRequest.setURL()</code> API to the list of parameters
  -      passed to the server redirector, so that it won't be necessary to call
  -      <code>ServletTestRequest.addParameter()</code> for each of these
  -      parameters.
  -    </action>
  -    <action context="code">
         Check why zipped distributable files have a mode of 644 on unix systems
         (it should rather be 755). Thanks to Jason Crickmer.
       </action>
  
  
  
  1.3       +37 -1     
jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/ServletTestRequest.java
  
  Index: ServletTestRequest.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/framework/share/org/apache/commons/cactus/ServletTestRequest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServletTestRequest.java   2001/04/14 18:27:25     1.2
  +++ ServletTestRequest.java   2001/06/28 21:26:59     1.3
  @@ -203,6 +203,10 @@
       {
           m_URL = new ServletURL(theServerName, theContextPath,
               theServletPath, thePathInfo, theQueryString);
  +
  +        // Now automatically add all HTTP parameters to the list of passed
  +        // parameters
  +        addQueryStringParameters(theQueryString);
       }
   
       /**
  @@ -393,5 +397,37 @@
   
           return null;
       }
  +
  +    /**
  +     * Extract the HTTP parameters that might have been specified on the
  +     * query string and add them to the list of parameters to pass to the
  +     * servlet redirector.
  +     *
  +     * @param theQueryString the Query string in the URL to simulate, i.e. this
  +     *                       is the string that will be returned by the
  +     *                       <code>HttpServletResquest.getQueryString()</code>.
  +     *                       Can be null.
  +     */
  +    private void addQueryStringParameters(String theQueryString)
  +    {
  +        if (theQueryString == null) {
  +            return;
  +        }
  +
  +        String nameValue = null;
  +        StringTokenizer tokenizer = new StringTokenizer(theQueryString, "&");
  +        int breakParam = -1;
  +        while (tokenizer.hasMoreTokens()) {
  +            nameValue = tokenizer.nextToken();
  +            breakParam = nameValue.indexOf("=");
  +            if (breakParam != -1) {
  +                addParameter(nameValue.substring(0, breakParam),
  +                    nameValue.substring(breakParam+1));
  +            } else {
  +                throw new RuntimeException("Bad QueryString [" + 
  +                    theQueryString + "] NameValue pair: [" + nameValue + "]");
  +            }
  +        }
  +    }
   
  -}
  \ No newline at end of file
  +}
  
  
  
  1.2       +12 -14    
jakarta-commons/cactus/src/sample/share/org/apache/commons/cactus/sample/unit/TestServletTestCase4.java
  
  Index: TestServletTestCase4.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/sample/share/org/apache/commons/cactus/sample/unit/TestServletTestCase4.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestServletTestCase4.java 2001/04/09 11:52:39     1.1
  +++ TestServletTestCase4.java 2001/06/28 21:27:00     1.2
  @@ -144,7 +144,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 1 of test values (taken from Sun's Servlet API spec)
        *
        * @param theRequest the request object that serves to initialize the
        *                   HTTP connection to the server redirector.
  @@ -156,7 +155,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 1 of test values (taken from Sun's Servlet API spec)
        */
       public void testSimulatedURL1()
       {
  @@ -170,7 +168,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 2 of test values (taken from Sun's Servlet API spec)
        *
        * @param theRequest the request object that serves to initialize the
        *                   HTTP connection to the server redirector.
  @@ -182,7 +179,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 2 of test values (taken from Sun's Servlet API spec)
        */
       public void testSimulatedURL2()
       {
  @@ -198,7 +194,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 3 of test values (taken from Sun's Servlet API spec)
        *
        * @param theRequest the request object that serves to initialize the
        *                   HTTP connection to the server redirector.
  @@ -210,7 +205,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 3 of test values (taken from Sun's Servlet API spec)
        */
       public void testSimulatedURL3()
       {
  @@ -226,7 +220,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 4 of test values (taken from Sun's Servlet API spec)
        *
        * @param theRequest the request object that serves to initialize the
        *                   HTTP connection to the server redirector.
  @@ -238,7 +231,6 @@
   
       /**
        * Verify that we can simulate different parts of the URL.
  -     * Set 4 of test values (taken from Sun's Servlet API spec)
        */
       public void testSimulatedURL4()
       {
  @@ -253,20 +245,23 @@
       //-------------------------------------------------------------------------
   
       /**
  -     * Verify that we can simulate different parts of the URL.
  -     * Set 5 of test values (taken from Sun's Servlet API spec)
  +     * Verify that we can simulate different parts of the URL. Also verify 
  +     * that HTTP parameters put in the simulation URL will be
  +     * available on the server side as real HTTP parameters.
        *
        * @param theRequest the request object that serves to initialize the
        *                   HTTP connection to the server redirector.
        */
       public void beginSimulatedURL5(ServletTestRequest theRequest)
       {
  -        theRequest.setURL("jakarta.apache.org", "/catalog", "/help/feedback.jsp", 
null, "PARAM1=param1&PARAM2=param2");
  +        theRequest.setURL("jakarta.apache.org", "/catalog", 
  +            "/help/feedback.jsp", null, "PARAM1=param1&PARAM2=&PARAM3=param3");
       }
   
       /**
  -     * Verify that we can simulate different parts of the URL.
  -     * Set 5 of test values (taken from Sun's Servlet API spec)
  +     * Verify that we can simulate different parts of the URL. Also verify 
  +     * that HTTP parameters put in the simulation URL will be
  +     * available on the server side as real HTTP parameters.
        */
       public void testSimulatedURL5()
       {
  @@ -276,7 +271,10 @@
           assertEquals("/catalog", request.getContextPath());
           assertEquals("/help/feedback.jsp", request.getServletPath());
           assert(request.getPathInfo() == null);
  -        assertEquals("PARAM1=param1&PARAM2=param2", request.getQueryString());
  +        assertEquals("PARAM1=param1&PARAM2=&PARAM3=param3", 
request.getQueryString());
  +        assertEquals(request.getParameter("PARAM1"), "param1");
  +        assertEquals(request.getParameter("PARAM2"), "");
  +        assertEquals(request.getParameter("PARAM3"), "param3");
       }
   
   }
  
  
  

Reply via email to