tomakehurst/wiremock — pull request #218 by radAdam (2014-12-30 16:06:48+00:00)
Title: Support for parametrization in reponse body files via Velocity templates.

Hi Tom , hope all is well.

Recently I had the need to support parametrization in stubbed service calls. Essentially I was stubbing part of a user registration flow and using JMeter to help load test.The flow requires a unique user guid to be passed in, and it in turn does a look up on this id, and generates a hash derived from the guid passed via the request. Because I am using an incrementer from within a JMeter plan and invoking tens of thousands of requests concurrently, I was having to generate tens of thousands of mocks. A wild card, catch all response mapping would not work in this scenario.

I added in support for Velocity templates. The request is processed in the handler , and stored in a context object. Before the response is rendered , I do a check to see if the body file is of type .vm , if so the context object is merged with template, and I can process or extrapolate information from the request into the response dynamically.

Thought perhaps this may benefit others.

Cheers !
-adam