Tomakehurst Wiremock.尝试连接到8080.连接被拒绝 [英] Tomakehurst Wiremock. Tries to connect to 8080. Connection refused

查看:355
本文介绍了Tomakehurst Wiremock.尝试连接到8080.连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@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 4WireMockRule都可以很好地工作.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆