}
protected String getResponse(String path, String method,
Map<String, String> extraParams, String postData, String format,
String contentType) throws Exception {
FakeHttpServletRequest req = new FakeHttpServletRequest();
req.setCharacterEncoding("UTF-8");
req.setPathInfo(path);
req.setParameter("format",format);
req.setParameter("X-HTTP-Method-Override", method);
req.setAttribute(AuthInfo.Attribute.SECURITY_TOKEN.getId(), FAKE_GADGET_TOKEN);
req.setContentType(contentType);
for (Map.Entry<String,String> entry : extraParams.entrySet()) {
req.setParameter(entry.getKey(), entry.getValue());
}
if (!("GET").equals(method) && !("HEAD").equals(method)) {
if (postData == null) {
postData = "";
}
req.setPostData(postData.getBytes());
}
req.setMethod(method);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(outputStream);
EasyMock.expect(res.getWriter()).andReturn(writer);
res.setCharacterEncoding("UTF-8");