#70 HttpServletRequestSimulator.getParameterMap(): wrong values

open
nobody
None
5
2004-12-23
2004-12-23
No

HttpServletSimulator.getParameterMap() returns a map
that doesn't conform to the spec.

The spec at
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/ServletRequest.html#getParameterMap\()
says:
"The values in the parameter map are of type String array."

However, in the current implementation, the map's
values type sometimes is String, not String[]. If you
run this unit test, you will see that it fails:

public void testHttpServletRequestSimulator() {
request.addParameter("foo", "bar");
try {
Map params = request.getParameterMap();
String[] value = (String[])params.get("foo");
assertEquals("bar", value[0]);
} catch (ClassCastException e) {
fail();
}
}

(request is a previously set up
HttpServletRequestSimulator object).

Discussion


Log in to post a comment.