This is for Mockrunner 0.4 with Java 1.5 and Servlet API 2.4.
There is a bug somewhere in MockPageContext, MockJspWriter and the setup code for those two.
The problem: When I pass a JSP as servlet to BasicServletTestCaseAdapter.createServlet(), then a response is created which contains an MockServletOutputStream as output. The PageContext contains a MockJspWriter and those two are not connected: the MockJspWriter uses a simple StringWriter because it's constructor called without arguments in MockPageContext.
My quick fix was to set jspWriter to null in the constructor and in initialize() and change MockPageContext:getOut() like this:
public JspWriter getOut()
{
if (jspWriter == null)
{
try
{
jspWriter = new MockJspWriter (response.getWriter ());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return jspWriter;
}
Logged In: YES
user_id=804648
Originator: NO
Thanks, will be fixed
Logged In: YES
user_id=606
Originator: YES
Verified with 0.4.1.
The bug is back with MockRunner 0.4.2.
I really suggest to create the JspWriter as late as possible to avoid losing the synchronization between the response and the JspWriter.
Sorry, ignore that comment. I wasn't aware that JspFactory is a global variable (which means all tests receive the same PageContext :-( )