我希望为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
我创建了这个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
目前,我正在尝试在映射中自定义WireMock状态代码。
我想做点类似的事。
"response" : {
"status" :"{{#if true}}200{{/if}}{{else}} 204 {{/if}}",
...
...
...
}
这样做时,我会得到以下错误。
Cannot deserialize value of type `int` from String "{{#if true}}200{{/if}}{{else}} Not found {{/if}}":
我正在使用Spring Boot编写一套微服务,并且需要运行一些BDD样式的集成测试,以测试彼此独立的微服务。为了弄清楚是怎么做的,我用Spring Cloud contract在其中一个生产者上写了一个非常简单的契约。这就是它: org.springframework.cloud.contract.spec.Contract.make {
description("Contract for the command endpoint where a consumer can send the service individual commands")
我需要模拟假客户端,并且我尝试使用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
我有以下情况:
@Transactional
@SpringBootTest
@ActiveProfiles("test")
@AutoConfigureMockMvc
@AutoConfigureWireMock(port = 0)
public abstract class IntegrationTest {
}
public class Test1 extends IntegrationTest {
// Tests that use WireMock
}
@ActiveProfiles("specific-case-test") // This