我无法让我的测试运行,因为MockRestServiceServer更改了requestfactory,因此执行以下操作并不起作用。
restTemplate.setRequestFactory(new SimpleClientHttpRequestFactory(new AcceptAllHostnameVerifier()));
mockRestServiceServer = MockRestServiceServer.createServer(restTemplate);
这是源构造函数:
public static MockRestServiceServer createServer(RestTemplate restTemplate) {
Assert.notNull(restTemplate, "'restTemplate' must not be null");
MockRestServiceServer mockServer = new MockRestServiceServer();
RequestMatcherClientHttpRequestFactory factory = mockServer.new RequestMatcherClientHttpRequestFactory();
restTemplate.setRequestFactory(factory);
return mockServer;
无论如何都要在MockRestServiceServer上设置请求工厂,以便我的测试运行?