java Wiremock java
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java Wiremock java相关的知识,希望对你有一定的参考价值。
usage
def expectedResponsePath = stubSoap(
"/CS/EQ/WSCodeClickPaymentFields/WSCodeClickPaymentFields11",
routeId, externalSystem
)
package ru.alfabank.mobile.fields.controller
import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock
import org.springframework.http.HttpStatus
import ru.alfabank.mobile.tests.WebIntegrationTest
import static com.github.tomakehurst.wiremock.client.WireMock.*
import static ru.alfabank.api.utils.fs.StringLoader.fromClasspath
@AutoConfigureWireMock(port = 31238)
class BaseIntegrationTest extends WebIntegrationTest {
protected static def stubSoap(String url, String routeId, String system) {
stubFor post(urlEqualTo(url))
.withRequestBody(equalToXml(fromClasspath("/__files/expected-request/${routeId}-${system}-request.xml")))
.willReturn(
aResponse()
.withStatus(HttpStatus.OK.value())
.withHeader("Content-Type", "application/xml;charset=UTF-8")
.withBodyFile("ws-response/${routeId}-${system}-response.xml"))
return "/__files/expected-response/${routeId}-${system}-response.json"
}
}
以上是关于java Wiremock java的主要内容,如果未能解决你的问题,请参考以下文章
在 Java 中将 WireMock 与 SOAP Web 服务一起使用
(07)使用WireMock快速伪造REST服务
(07)使用WireMock快速伪造REST服务
使用WireMock伪造REST服务
自动化测试:wiremock api全解析
自动化测试:wiremock api全解析