Tomakehurst Wiremock.尝试连接到8080.连接被拒绝 [英] Tomakehurst Wiremock. Tries to connect to 8080. Connection refused
问题描述
@Test
void resourceTo_Wired_ClientCall() {
wireMockServer = new WireMockServer(options().port(10021));
wireMockServer.start();
final MappingBuilder stubBuilder = get(urlMatching("http://demo1096495.mockable.io/client1"));
stubFor(stubBuilder
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Type", "application/json")
.withBody("{\"something\":\"test-wired\"}")));
;
出现错误:
org.apache.http.conn.HttpHostConnectException:连接到 本地主机:8080 [本地主机/127.0.0.1]失败:连接被拒绝 (连接被拒绝)
org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
有什么遗漏的?
P.S.我在junit 5
和spring boot中使用WireMockServer
. junit 4
和WireMockRule
都可以很好地工作.
P.S. I use WireMockServer
with junit 5
and spring boot. with junit 4
and WireMockRule
all works well.
testCompile "com.github.tomakehurst:wiremock-jre8:2.24.1"
推荐答案
更新:
https://github.com/tomakehurst/wiremock/issues/369
添加:WireMock.configureFor("localhost", 10021);
在wireMockServer.start();
然后该错误消失了.它传递到下一行.
Then that error is gone. It passed to next lines.
P.S. 有一些新东西..但这是另外一个问题.
P.S. Got some new thing..but that is different issue.
这篇关于Tomakehurst Wiremock.尝试连接到8080.连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!