我正在使用wireMock,我得到了500 Internal Server Error的一致响应。
我正在使用以下代码创建模拟服务器,wiremock 版本:2.24.0
final URI listenUri = URI.create(listenAddress);
final Duration responseTimeout = Duration.ofSeconds(timeout);
final BlockingQueue<HttpRequest> requestQueue = new LinkedBlockingDeque<>();
final BlockingQueue<HttpResponse> responseQueue = new LinkedBlockingDeque<>();
final WireMockServer server = new WireMockServer(
wireMockConfig()
.bindAddress(listenUri.getHost())
.port(listenUri.getPort())
.extensions(new PooledReqResTransformer(requestQueue, responseQueue, responseTimeout))
);
server.stubFor(any(anyUrl()).willReturn(aResponse()));
server.start();
当我尝试使用 curl 命令调用我的服务器时出现错误
curl http://dlpune.local:9320/
$ curl http://machine.local:9320/test/id/4117d6cc
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 500 Server Error</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /test/id/4117d6cc. Reason:
<pre> Server Error</pre></p><h3>Caused by:</h3><pre>java.lang.AssertionError: Response is not available
at com.oberthur.wes.tests.mock.wiremock.extensions.PooledReqResTransformer.transform(PooledReqResTransformer.java:61)
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.applyTransformations(StubResponseRenderer.java:78)
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:57)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:70)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:120)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:529)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:499)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258)
at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555)
at java.lang.Thread.run(Thread.java:748)
</pre>
<hr><i><small>Powered by Jetty://</small></i><hr/>
</body>
</html>
请帮助解决上述情况。