Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Cannot Reproduce
-
9.15.0, 10.0.0-M2
-
None
-
None
Description
Background from reading the Wicket code:
In a TC, using WicketTester, set a parameter:
wicketTester.getRequest()
.setParameter(Apponstants.FOO_PARAMETER_NAME, "foo");
Next, try to read that parameter in another class during the running of a test.
This seems to be an issue with the parameter not being found.
ServletWebRequest contains a MockHttpServletRequest through member variable httpServletRequest.
But the method ServletWebRequest.getParameters() ignores the member MockHttpServletRequest.parameters, where 'foo' is located, and instead does this:
public IRequestParameters getRequestParameters()
{ return new CombinedRequestParametersAdapter(new IRequestParameters[]
);
}
You can get to this 'foo' parameter with an explicit cast of ServletWebRequest to (MockHttpServletRequest). But mainline web code should not cast to Mocks of Wicket Tester.
Looking at the getCookies implementation in ServletWebRequest, it goes to a deeper level (into the httpServletRequest):
public List<Cookie> getCookies()
Proposed Solutions:
A) Modify HttpServletRequest to override getRequestParameters so it can retrieve it's own parameters
OR
B) Modify ServletWebRequest to add to the existing getRequestParameters method the parameters inside of this.httpServletRequest such as mockup below (needs work to bring in the map correctly):
public IRequestParameters getRequestParameters()
{ return new CombinedRequestParametersAdapter(new IRequestParameters[]
);
}
Please let me know if there is another combination of API that do allow WicketTester to set Request Parameters in a way readible during TCs through ServletWebRequest.