I would like to test our app using a HTTP client with a huge amount of data. Is it possible to create an infinite or several gigabytes length output with WireMock without allocating a byte array or String with that size?
As far as I see ResponseDefinitionBuilder
has three withBody*
methods:
public ResponseDefinitionBuilder withBodyFile(String fileName)
public ResponseDefinitionBuilder withBody(String body)
public ResponseDefinitionBuilder withBody(byte[] body)
I have tried withBodyFile("/dev/zero")
but I got the following exception:
WARN (ServletHandler.java:628) - /test.txt
com.github.tomakehurst.wiremock.security.NotAuthorisedException: Access to file /dev/zero is not permitted
at com.github.tomakehurst.wiremock.common.AbstractFileSource.assertFilePathIsUnderRoot(AbstractFileSource.java:160)
at com.github.tomakehurst.wiremock.common.AbstractFileSource.getBinaryFileNamed(AbstractFileSource.java:45)
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.renderDirectly(StubResponseRenderer.java:115)
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.buildResponse(StubResponseRenderer.java:64)
at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:56)
at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:50)
at com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
...
The other two require a huge in-memory array or string which I also would like to avoid.
I've also checked the Fault
enum but it does not seem extendable.