* @see AbstractWebTestCaller#setTestCaseFields(AbstractTestCase)
*/
protected void setTestCaseFields(AbstractTestCase theTestInstance)
throws Exception
{
ServletTestCase servletInstance = (ServletTestCase) theTestInstance;
ServletImplicitObjects servletImplicitObjects =
(ServletImplicitObjects) this.webImplicitObjects;
// Sets the request field of the test case class
// ---------------------------------------------
// Extract from the HTTP request the URL to simulate (if any)
HttpServletRequest request =
servletImplicitObjects.getHttpServletRequest();
ServletURL url = ServletURL.loadFromRequest(request);
Field requestField = servletInstance.getClass().getField("request");
requestField.set(servletInstance,
new HttpServletRequestWrapper(request, url));
// Set the response field of the test case class
// ---------------------------------------------
Field responseField = servletInstance.getClass().getField("response");
responseField.set(servletInstance,
servletImplicitObjects.getHttpServletResponse());
// Set the config field of the test case class
// -------------------------------------------
Field configField = servletInstance.getClass().getField("config");
configField.set(servletInstance,
new ServletConfigWrapper(
servletImplicitObjects.getServletConfig()));
// Set the session field of the test case class
// --------------------------------------------
// Create a Session object if the auto session flag is on
if (isAutoSession()) {
HttpSession session =
servletImplicitObjects.getHttpServletRequest().getSession(true);
Field sessionField = servletInstance.getClass().getField("session");
sessionField.set(servletInstance, session);
}
}