You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2003/09/12 09:33:20 UTC
cvs commit: jakarta-commons/httpclient/src/test/org/apache/commons/httpclient TestWebappPostMethod.java
olegk 2003/09/12 00:33:20
Modified: httpclient/src/java/org/apache/commons/httpclient/methods
Tag: HTTPCLIENT_2_0_BRANCH PostMethod.java
httpclient/src/test/org/apache/commons/httpclient Tag:
HTTPCLIENT_2_0_BRANCH 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
No revision
No revision
1.45.2.3 +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.45.2.2
retrieving revision 1.45.2.3
diff -u -r1.45.2.2 -r1.45.2.3
--- PostMethod.java 9 Aug 2003 19:36:39 -0000 1.45.2.2
+++ PostMethod.java 12 Sep 2003 07:33:20 -0000 1.45.2.3
@@ -253,7 +253,7 @@
public void setParameter(String parameterName, String parameterValue) {
LOG.trace("enter PostMethod.setParameter(String, String)");
- removeParameter(parameterName, parameterValue);
+ removeParameter(parameterName);
addParameter(parameterName, parameterValue);
}
@@ -398,7 +398,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()) {
No revision
No revision
1.3.2.1 +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.3.2.1
diff -u -r1.3 -r1.3.2.1
--- TestWebappPostMethod.java 5 Mar 2003 04:02:56 -0000 1.3
+++ TestWebappPostMethod.java 12 Sep 2003 07:33:20 -0000 1.3.2.1
@@ -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¶m=b¶m=c", method.getRequestBodyAsString());
+ method.setParameter("param", "a");
+ assertEquals("param=a", method.getRequestBodyAsString());
+ }
+
}