super();
this.data = data;
}
public void runTestCase(FacesContext context) throws Throwable {
MockHttpServletResponse response = new MockHttpServletResponse() {
/* (non-Javadoc)
* @see org.apache.shale.test.mock.MockHttpServletResponse#addDateHeader(java.lang.String, long)
* Default shale implementation is not thread-safe.
*/
public void addDateHeader(String name, long value) {
SimpleDateFormat format = new SimpleDateFormat(
"EEE, dd MMM yyyy HH:mm:ss zzz");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
addHeader(name, format.format(new Date(value)));
}
//TODO fix when setContentLength in shale-test will start function
// https://issues.apache.org/struts/browse/SHALE-495
public int getContentLength() {
return Integer.parseInt(getHeader("Content-Length"));
}
public void setContentLength(int length) {
addIntHeader("Content-Length", length);
}
};
MockHttpServletRequest req = new MockHttpServletRequest(session);
req.setServletContext(servletContext);
req.setPathElements(request.getContextPath(), request
.getServletPath(), request.getPathInfo(), data);
MockResourceRequest resourceRequest = new MockResourceRequest(req);
service.serviceResource(key, resourceRequest, response);
byte[] content = ((MockServletOutputStream) response
.getOutputStream()).content();
String strContent = new String(content);
assertEquals(strContent, "test");
}