tomakehurst/wiremock — pull request #4 by tootedom (2012-07-07 21:31:03+00:00)
Title: Add Ability to specify the Response body to be a byte array (to mock returning binary data)

Currently the response can be defined with either withBody or withBodyFile; both of these have the requirement for the body to be String. I was testing a client/mocking a web service returning gzip'd data, for the client to auto decompress, and noticed that there's no current way to specify binary data (byte[] - unless I've missed some configuration settings)

Therefore, I've added a withByteBody method, like the following

stubFor(get(urlEqualTo(GET_COMPRESSED))
.withHeader("Accept-Encoding", containing("gzip"))
.willReturn(aResponse()
.withStatus(200)
.withHeader("Content-Encoding", "gzip")
.withByteBody(COMPRESSED_GET_DATA)
).atPriority(1));

or

"response": {
"status": 200,
"byteBody": [65,66,67]
}

Maybe its an additional idea to extend withBodyFile (i.e. withBinaryBodyFile); so that the wiremock can also returned binary files like jpg, etc

Loving the wiremock, great tool.

Thanks
/dom