Capturing Response OutputStream
In my Struts action classes I write JSON strings to the Response OutputStream:
_session = UserManagementUtil.getHome(getEnv()).create();
String result = _session.processUser(frm.getString("change"));
OutputStream os = response.getOutputStream();
os.write(result.getBytes());
os.flush();
os.close();
returnnull;
In my Cactus/StrutsTestCase, I would like to capture the response to test the returned JSON, but I haven't figured out how to do it. Cactus gives me access to the Session, Response, Request, and Request Headers, but nothing that I've tried so far gets me the bytes.
I feel like I am missing something obvious, but...
Any help is appreciated.
[813 byte] By [
MartyLa] at [2007-11-27 4:26:44]

# 2
gimbal2 thanks for your response.
My architecture is that the StrutsActions write to the OutputStream so that the response goes directly to an XMLHttpRequest without passing through a JSP, and eliminating the need to set/get Session/Request attributes.
As my application has developed/evolved, I'm finding that I have less and less need for the Struts overhead and I am considering replacing that layer with just a couple of servlets. And I am now wondering if maybe Struts is tripping me up trying to get to Response OutputStream. I'm going to take a closer look at HTTPUnit to see if that testing framework will help in this situation.
Thanks again.