We're trying to integrate wiremock-spring-boot-starter in our project using the default configuration (adding dependency + @WireMockTest). We have our response body files under src/test/resources/__files, which is the default location for Wiremock. When we run our tests we get this exception:
java.lang.RuntimeException: java.io.FileNotFoundException: /__files/product-catalog-response.json (No such file or directory)
at com.github.tomakehurst.wiremock.common.BinaryFile.readContents(BinaryFile.java:38) ~[wiremock-standalone-2.10.1.jar:na]
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.renderDirectly(StubResponseRenderer.java:95) ~[wiremock-standalone-2.10.1.jar:na]
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.buildResponse(StubResponseRenderer.java:65) ~[wiremock-standalone-2.10.1.jar:na]
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:54) ~[wiremock-standalone-2.10.1.jar:na]
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:47) ~[wiremock-standalone-2.10.1.jar:na]
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:102) ~[wiremock-standalone-2.10.1.jar:na]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) ~[tomcat-embed-core-8.5.23.jar:8.5.23]
at wiremock.org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) ~[wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) ~[wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83) ~[wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:301) ~[wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) ~[wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.Server.handle(Server.java:499) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) [wiremock-standalone-2.10.1.jar:na]
at wiremock.org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) [wiremock-standalone-2.10.1.jar:na]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_144]
It looks like Wiremock is trying to find the files using an absolute path, instead of going to the classpath. In fact, if we create a __files in the root directory of our computer with the same contents the tests work fine.
We haven't been able to figure out how to configure this properly to load the contents from the classpath, is there any way to do it?
We're trying to integrate wiremock-spring-boot-starter in our project using the default configuration (adding dependency +
@WireMockTest). We have our response body files undersrc/test/resources/__files, which is the default location for Wiremock. When we run our tests we get this exception:It looks like Wiremock is trying to find the files using an absolute path, instead of going to the classpath. In fact, if we create a
__filesin the root directory of our computer with the same contents the tests work fine.We haven't been able to figure out how to configure this properly to load the contents from the classpath, is there any way to do it?