Tapestry 5:仅在单元测试中贡献请求处理程序
我尝试将 PageTester 与 spring security 结合使用,但遇到了此异常:
java.lang.RuntimeException: java.io.IOException: Can only process HttpServletRequest
I认为有一个解决方案(如下),但有谁知道我如何使用以下贡献,以便仅在测试期间调用它?
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:*");
}
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:*");
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 PageTester 构造函数中提供额外的模块。您使用的是哪个版本?
you can provide extra modules in the PageTester constructor. which version are you using ?