开发者

Tapestry 5: contributeRequestHandler in unit tests only

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜