commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestWebappPostMethod.java
Date Fri, 12 Sep 2003 07:34:16 GMT
olegk       2003/09/12 00:34:16

  Modified:    httpclient/src/java/org/apache/commons/httpclient/methods
                        PostMethod.java
               httpclient/src/test/org/apache/commons/httpclient
                        TestWebappPostMethod.java
  Log:
  PR #22969 (return value of PostMethod#removeParameter)
  PR #22970 (PostMethod#setParameter)
  
  - PostMethod#setParameter return value fix
  - PostMethod#setParameter correcly overwrites existing parameters
  
  Contributed by Oleg Kalnichevski
  Reviewed by Michael Becke
  
  Revision  Changes    Path
  1.49      +6 -6      jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java
  
  Index: PostMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/methods/PostMethod.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- PostMethod.java	9 Aug 2003 19:37:58 -0000	1.48
  +++ PostMethod.java	12 Sep 2003 07:34:16 -0000	1.49
  @@ -226,7 +226,7 @@
       public void setParameter(String parameterName, String parameterValue) {
           LOG.trace("enter PostMethod.setParameter(String, String)");
   
  -        removeParameter(parameterName, parameterValue);
  +        removeParameter(parameterName);
           addParameter(parameterName, parameterValue);
       }
   
  @@ -371,7 +371,7 @@
               throw new IllegalArgumentException(
                   "Argument passed to removeParameter(String) cannot be null");
           }
  -        boolean removed = true;
  +        boolean removed = false;
           Iterator iter = this.params.iterator();
   
           while (iter.hasNext()) {
  
  
  
  1.4       +29 -4     jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappPostMethod.java
  
  Index: TestWebappPostMethod.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/httpclient/src/test/org/apache/commons/httpclient/TestWebappPostMethod.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestWebappPostMethod.java	5 Mar 2003 04:02:56 -0000	1.3
  +++ TestWebappPostMethod.java	12 Sep 2003 07:34:16 -0000	1.4
  @@ -224,5 +224,30 @@
           verifyParams(method);
       }
   
  +    /**
  +     * Test the return value of the PostMethod#removeParameter.
  +     */
  +    public void testRemoveParameterReturnValue() throws Exception {
  +        PostMethod method = new PostMethod(paramsPath);
  +
  +        method.addParameter("param", "whatever");
  +        assertTrue("Return value of the method is expected to be true", method.removeParameter("param"));
  +        assertFalse("Return value of the method is expected to be false", method.removeParameter("param"));
  +    }
  +
  +    /**
  +     * Test if setParameter overwrites existing parameter values.
  +     */
  +    public void testAddParameterFollowedBySetParameter() throws Exception {
  +        PostMethod method = new PostMethod(paramsPath);
  +
  +        method.addParameter("param", "a");
  +        method.addParameter("param", "b");
  +        method.addParameter("param", "c");
  +        assertEquals("param=a&param=b&param=c", method.getRequestBodyAsString());
  +        method.setParameter("param", "a");
  +        assertEquals("param=a", method.getRequestBodyAsString());
  +    }
  +
   }
   
  
  
  

Mime
View raw message