我希望为API创建一个Stub,并希望验证服务器返回的API调用和响应。为此,我实现了WireMock示例:
import org.junit.Rule;
import org.junit.Test;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
public class MockTestDemo {
private static final int WIREMOCK_PORT = 8080;
@Rule
public WireMockRule wireMockRule = new Wire
我需要模拟假客户端,并且我尝试使用How to write integration tests with spring-cloud-netflix and feign中举例说明的Wiremock 然而,在调用stubFor时,我得到了以下错误 java.net.SocketException: Connection reset
at java.base/java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.base/java.net.SocketInputStream.read(SocketI
我正在尝试使用WireMock实现基本的查询参数。以下是我的代码
stubFor(get(urlEqualTo("/getWithQueryParam?searchFor=WireMock"))
.withQueryParam("searchFor" ,equalTo("WireMock"))
.willReturn(aResponse()
.withStatusMessage("This Page is Authenticated And having query Para
我创建了这个Dockerfile,并根据来自的示例将其复制到目录中。
FROM openjdk:8-jre-alpine
ENV WIREMOCK_VERSION 2.27.1
RUN apk add --update openssl
# fix "No Server ALPNProcessors" when using https
RUN apk add --update libc6-compat
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib/ld-linux-x86-64.so.2
假设应用程序依赖于外部服务器,上的REST服务。为了进行测试,我想在JUnit环境中模拟外部rest调用(通过Wiremock)。启动单独的服务器会消耗时间,而且并不容易。使用WiremockRule似乎是正确的方向。创建模拟控制器并不是一种优雅的方法,因为Wiremock是可用的。
例如get( "");
PS:当然,我知道我可以通过Mockito模拟REST调用。
用Wiremock模拟本地主机是一种简单的方法。如何使用该代码来模拟、其他服务器、和服务?我从流行的Baeldung示例中复制了部分内容。
public class WireMockDemo {
@Rul
在我的机器人android测试中尝试启动一个WireMockServer时,得到了下面的堆栈跟踪。可能是Apache客户端的两个版本之间的冲突,但我还没有解决它。有什么想法吗?
java.lang.NoSuchMethodError: org.apache.http.conn.ssl.SSLSocketFactory.<init>
at com.github.tomakehurst.wiremock.http.HttpClientFactory.createSslSocketFactory(HttpClientFactory.java:110)
at com.github.toma