开发者

Tapestry 5: contributeRequestHandler in unit tests only

开发者 https://www.devze.com 2022-12-19 07:04 出处:网络
I\'m trying to use PageTester in conjunction with spring security but am running into this exception:

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 o开发者_开发技巧nly 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:*");
 }


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

0

精彩评论

暂无评论...
验证码 换一张
取 消