I'm trying to use PageTester
in conjunction with spring security but am running into this exception:
java.lang.RuntimeException: java.io.IOException: Can only process HttpServletRequest
I think there is a solution (as below) but does anyone know how I can use the following contribution so that it gets called only during tests?
public static void contributeRequestHandler(OrderedConfiguration<RequestFilter> config, final RequestGlobals requestGlobals) {
RequestFilter filter = new RequestFilter() {
public boolean service(Request request, Response response,
RequestHandler handler) throws IOException {
requestGlobals.storeServletRequestResponse(mock(HttpServletRequest.class), mock(HttpServletResponse.class));
return handler.service(request, response);
}
};
config.add("EnsureNonNullHttpRequestAndResponse", filter, "before:*");
}