我正在尝试将PageTester
与spring安全性结合使用,但遇到了这个异常:
java.lang.RuntimeException: java.io.IOException: Can only process HttpServletRequest
我认为有一个解决方案(如下所示),但有没有人知道如何使用以下贡献,以便只在测试期间调用它?
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:*");
}