进行本机测试时连接拒绝 wiremock Quarkus:连接到 localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1]

Connection refused to wiremock when doing native test Quarkus : Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1]

我在将 Wiremock 与 Quarkus 结合使用时遇到问题。启动集成测试时(本机模式)。

Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connexion refusée (Connection refused)
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connexion refusée (Connection refused)
    at app//org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:156)
    at app//org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:376)
    at app//org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:393)
    at app//org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    at app//org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at app//org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at app//org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at app//org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
    at app//com.github.tomakehurst.wiremock.client.HttpAdminClient.safelyExecuteRequest(HttpAdminClient.java:473)
    at app//com.github.tomakehurst.wiremock.client.HttpAdminClient.executeRequest(HttpAdminClient.java:454)
    at app//com.github.tomakehurst.wiremock.client.HttpAdminClient.addStubMapping(HttpAdminClient.java:131)
    at app//com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:298)
    at app//com.github.tomakehurst.wiremock.client.WireMock.register(WireMock.java:293)
    at app//com.github.tomakehurst.wiremock.client.WireMock.givenThat(WireMock.java:104)
    at app//com.api.lambda.adapter.LambdaHandlerTest.initWiremock(LambdaHandlerTest.java:44)
package com.api.lambda.adapter;

import io.quarkus.test.junit.QuarkusIntegrationTest;

@QuarkusIntegrationTest
public class LambdaHandlerNativeTest extends LambdaHandlerTest {

    // Execute the same tests but in native mode.
}

有什么想法吗?

调查后不要忘记像我一样将 @QuarkusTestResource 添加到本机测试 class,其中 MockStackExtension 是您的 QuarkusTestResourceLifecycleManager 实现。

@QuarkusIntegrationTest
@QuarkusTestResource(MockStackExtension.class)
public class LambdaHandlerNativeTest extends LambdaHandlerTest {

    // Execute the same tests but in native mode.
}