WireMock-连接拒绝-Junit5
我有一个可以在/__管理员/__管理员下看到的存根,但是在__admin/requests或__Admin/request/nocted/noteed中进行任何rest呼叫时,我觉得很奇怪。 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)
)
);
}
}
错误:
在以下站点上观察到错误: *__检查点⇢ 请求获取 http:// localhost:&lt; myServiceport&gt;/getStuff?include-archive = yes [DefaultWebClient]
...
[org.springframework.web.servlet.mvc.method.annotation.exceptionhandlerexceptionResolver] :解决 [org.springframework.web.reactive.function.client.webclientrequestexexception: 连接拒绝:没有更多信息: localhost/127.0.0.1:&lt; myServiceport&gt;;嵌套异常是 io.netty.channel.AbstractChannel $ entotatedConnectException:Connection 拒绝:没有更多信息:localhost/127.0.0.1:&lt; myServiceport&gt;]
I have a stub that I can see under /__admin/ but when making any sort of rest calls nothing registers in either __admin/requests or __admin/requests/unmatched which I feel is strange. Is Wiremock failing to intercept the request?
Simplified code:
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:
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>]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于找到了这个问题,我试图拦截的端口没有在容器中打开
Finally found the issue, the port that I was trying to intercept wasn't open in the container thus why I got no entries in either __admin/requests or __admin/requests/unmatched