It appears the isCommitted() flag of a
HttpServletResponse won't be set to true after a page
has been succesfully written to/generated (either by
writing to the response's output stream or by
redirecting to a JSP). For reproducing this, just
output response.isCommitted() in doGet()/doPost() after
writing to the output stream or calling
getServletContext().getRequestDispatcher("/some/where/else").forward(req,res).
It's always false.
I've solved this for me with the following patch (see
also the attached file).
diff -u -r
/usr/local/src/httpunit-1.6.2/src/com/meterware/servletunit/RequestDispatcherImpl.java
src/com/meterware/servletunit/RequestDispatcherImpl.java
---
/usr/local/src/httpunit-1.6.2/src/com/meterware/servletunit/RequestDispatcherImpl.java
Sun Mar 26 22:16:46 2006
+++
src/com/meterware/servletunit/RequestDispatcherImpl.java
Fri Aug 4 03:14:20 2006
@@ -52,6 +52,7 @@
public void forward( ServletRequest request,
ServletResponse response ) throws ServletException,
IOException {
response.reset();
_servletMetaData.getServlet().service(
DispatchedRequestWrapper.createForwardRequestWrapper(
(HttpServletRequest) request, this ), response );
+ response.flushBuffer();
}
diff -u -r
/usr/local/src/httpunit-1.6.2/src/com/meterware/servletunit/ServletUnitHttpResponse.java
src/com/meterware/servletunit/ServletUnitHttpResponse.java
---
/usr/local/src/httpunit-1.6.2/src/com/meterware/servletunit/ServletUnitHttpResponse.java
Sun Mar 26 22:16:48 2006
+++
src/com/meterware/servletunit/ServletUnitHttpResponse.java
Fri Aug 4 03:25:01 2006
@@ -268,6 +268,7 @@
_outputStream = new ByteArrayOutputStream();
_servletStream = new
ServletUnitOutputStream( _outputStream );
}
+ _committed = true;
return _servletStream;
}
@@ -303,6 +304,7 @@
_outputStream = new ByteArrayOutputStream();
_writer = new PrintWriter( new
OutputStreamWriter( _outputStream,
getCharacterEncoding() ) );
}
+ _committed = true;
return _writer;
}
Logged In: YES
user_id=1220573
Originator: NO
Dear httpunit user!
Thank you for your bug report. We appreciate the time and effort you are putting into this.
Please supply a testcase with the expected result for the bug report that you are asking a solution for and we'll look into implementing it. For a start you might want to get the trunk version from the subversion repository (see https://sourceforge.net/svn/?group_id=6550\)
and have a look at the source code of some of the more than 700 JUnit based testcase in there.
If you do not use or have subversion tool you can still directly browse our test cases via:
http://httpunit.svn.sourceforge.net/viewvc/httpunit/trunk/httpunit/test/com/meterware/httpunit/
Looking into one or more of the Junit Java source files
should give you a clue on what a proper testcase for httpunit looks like, often you will probably only have to "clone" an existing testcase and modify it slightly to your needs.
When you are ready you might want to attach the testcase (and if you already have started implementing a solution for it it also the actual code) to the patch section of the sourceforge.net tracker for patches of the httpunit project at
https://sourceforge.net/tracker/?atid=306550&group_id=6550&func=browse.
The main communication about further details of the development is via the httpunit developer mailinglist. You are most welcome to sign up via
https://lists.sourceforge.net/lists/listinfo/httpunit-develop
Yours
The httpunit developer team
(Russell, Wolfgang, Mark, Patrick and Tim as of 2008-04)
Logged In: YES
user_id=1220573
Originator: NO
Dear Olaf,
thank you for your bug report and patch.
I've added a test cased trying to interpret what you intended.
The test cases seems to proove what you are saying (for one of the two cases):
see http://httpunit.svn.sourceforge.net/viewvc/httpunit?view=rev&revision=938
Unfortunately your patches would brake other test cases of the HttpUnit Suite.
Could you please supply an improved test case (with the forward case) and possibly an improved patch?
I'm looking forward to your contribution and collaboration!
Yours
Wolfgang
Logged In: YES
user_id=1312539
Originator: NO
This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).