【发布时间】:2017-08-04 09:02:22
【问题描述】:
我有一些旧测试正在调用一些 Web 服务。之前网络服务没有安全性。现在已经添加了基本的 http 身份验证,因此测试失败了。测试使用 org.springframework.ws.test.server.MockWebServiceClient
测试示例:
@Autowired
MockWebServiceClient mockClient
def "import valid entity"() {
setup:
def request = loadEntitesToRequest(validEntityFile)
Source requestPayload = createStringSourceFromObject(request)
when: 'Endpoint is requested to import valid entity'
mockClient.sendRequest(withPayload(requestPayload)).andExpect(new ResponseMatcher() {
void match(WebServiceMessage req, WebServiceMessage resp) {
EntityImportResponse response = marshaller.unmarshal(resp.payloadSource)
assert response.errorMessage.isEmpty()
assert response.isSuccess()
}
})
then: 'Entity is successfully imported'
noExceptionThrown()
}
有什么方法可以向这个客户端添加基本的 http auth 吗?我知道如何将它添加到 WebServiceTemplate 但为此我还没有找到任何方法。
【问题讨论】:
-
问题出在哪里?您有使用它的测试,然后查看这些测试
-
您应该重新表述您的问题。正如它所问的那样,要理解你在问什么并不容易。
标签: java spring groovy spring-ws http-authentication