views:

111

answers:

1

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:*");
 }
+2  A: 

you can provide extra modules in the PageTester constructor. which version are you using ?

Stefan De Boey
Ah yes, of course - I should have looked at the documentation more closely :)
no prob, did your solution to mock http request for spring security work as you desribed? (just in case i ever need to integrate spring-security)
Stefan De Boey