Tomakehurst Wiremock. Tries to connect to 8080. Connection refused

痴心易碎 提交于 2019-12-25 01:25:55

问题


@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\"}")));
            ;

Got error:

org.apache.http.conn.HttpHostConnectException: Connect to localhost:8080 [localhost/127.0.0.1] failed: Connection refused (Connection refused)

What is missed of any?

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"

回答1:


UPDATE:

https://github.com/tomakehurst/wiremock/issues/369

added: WireMock.configureFor("localhost", 10021);

before wireMockServer.start();

Then that error is gone. It passed to next lines.

P.S. Got some new thing..but that is different issue.



来源:https://stackoverflow.com/questions/58168813/tomakehurst-wiremock-tries-to-connect-to-8080-connection-refused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!