title: How to mock REST Services?
body: <p>I have a maven/mule/spring development environment that I build REST services within.  I also have a series of TestNG tests to validate these services.  I also want the ability to alter the responses from the services, either returning specific information or throw an exception.  This was I can automatically test broader behaviours of the services.  I figured that mocking the services would be the best approach, but I cannot find any good information on how to mock a REST service.</p>
  
  <p>Is there any material I can review on how to mock a REST web service?</p>
  
  <p>--Update---</p>
  
  <p>I thought I would add an example to make the problem more concrete.  If I have the following setup:</p>
  
  <pre><code>testA calls serviceA, which then calls serviceB
  </code></pre>
  
  <p>If serviceA should return a web exception to testA if serviceB responds with an error, I would like to inject a mockedServiceB in to the system for the test where mockedServiceB always returns an error:</p>
  
  <pre><code>testA calls serviceA, which then calls mockedServiceB (which always returns an error to serviceA)
  </code></pre>