Wiremock - 连接被拒绝 - JUnit5

Wiremock - Connection Refused - JUnit5

我有一个存根,我可以在 /__admin/ 下看到,但是当进行任何类型的休息调用时,__admin/requests 或 __admin/[=21 中都没有注册=] 我觉得很奇怪。 Wiremock 是否未能拦截请求?

简化代码:

class MyTestClass {

    @Test
    void testStuff(){
        WireMock.configureFor("localhost", 9050); // Running in docker with custom port
        WireMock.reset();

        stubFor(
            get("/getStuff?include-archived=yes")
                .withPort(<myServicePort>)
                .willReturn(
                    aResponse()
                        .withHeader("Content-Type", "application/json")
                        .withStatus(200)
            )
        );
    }
}

错误:

Error has been observed at the following site(s): *__checkpoint ⇢ Request to GET http://localhost:<myServicePort>/getStuff?include-archived=yes [DefaultWebClient]

...

[org.springframework.web.servlet.mvc.method.annotation.ExceptionHandlerExceptionResolver] : Resolved [org.springframework.web.reactive.function.client.WebClientRequestException: Connection refused: no further information: localhost/127.0.0.1:<myServicePort>; nested exception is io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: localhost/127.0.0.1:<myServicePort>]

终于找到了问题,我试图拦截的端口没有在容器中打开,因此我在 __admin/requests 或 __admin/[=12 中没有任何条目=]