Here is the main problem that I have right now. My project that I am working on is using a decent amount of AJAX to get and set values on the fly so that the most up to date information is provided for the user. I am using JSON Objects to transfer the data to and from the server. These JSON Objects are being parsed out into a JSON String that is being set on the response with:
response.getWriter().write(jsonString);
A null value is returned for the mapping and the information is updated on the user's JSP. The problem comes with testing. I do not feel it is enough to just :
and I would like to test the string that is being written to the response. The question is, how do I do that?
Hopefully I haven't fully confused anyone... if so, let me know and I will attempt to draw out a picture that will be better laid out to follow. Also, I apologize for my lack of code formating on this forum. I just signed up 10 minutes ago and as such have no idea what markers I need to use to make the code appear as code.
Thanks in advance!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here is the main problem that I have right now. My project that I am working on is using a decent amount of AJAX to get and set values on the fly so that the most up to date information is provided for the user. I am using JSON Objects to transfer the data to and from the server. These JSON Objects are being parsed out into a JSON String that is being set on the response with:
response.getWriter().write(jsonString);
A null value is returned for the mapping and the information is updated on the user's JSP. The problem comes with testing. I do not feel it is enough to just :
verifyForward("blah");
assertNotNull(getResponse());
and I would like to test the string that is being written to the response. The question is, how do I do that?
Hopefully I haven't fully confused anyone... if so, let me know and I will attempt to draw out a picture that will be better laid out to follow. Also, I apologize for my lack of code formating on this forum. I just signed up 10 minutes ago and as such have no idea what markers I need to use to make the code appear as code.
Thanks in advance!
Off the top of my head assertTrue("The string you expect".equals(response.getWriterBuffer().toString()));
Negative on that, all that shows in the console log is:
org.apache.catalina.connector.CoyoteWriter@1d16e6e
so my assumption would be that the toString() was not overridden to pump out whatever is on the responses Writer object.
How would you possibly go about accessing a standard writer to see what it had in it's buffer? Maybe that could work if I knew how to do that.
Bump this, hopefully someone has some sort of solution. Maybe a dev of the StrutsTestCase if they are still around at all?
Can we see your whole JUnit test class?
I'm facing the same situation. Any lead on this?