title: Wiremock and Spring Integration
body: <p>I have a flow in Spring integration, which works as follows</p>
  
  <p>Read from MQ--> Do a Message Transformation-->Send the transformed message to an Api</p>
  
  <p>Now in my integration test, I am trying to mock the Api out and I tried 2 flavours but did not succeed.</p>
  
  <p>Here is the test with <strong>Wiremock flavour</strong> (also posted on <a href="https://github.com/tomakehurst/wiremock/issues/653" rel="nofollow noreferrer">Wiremock Github</a>) </p>
  
  <pre><code>String requestBody = TestUtil.createSampleInputMessage(rNumber);
  
  System.out.println("Expected Post msg by EvApiClient :" + requestBody);
  
  
  stubFor(post(urlEqualTo(TestUtil.EVENT_URL))
              //.withHeader("Content-Type", equalTo("application/json"))
              //.withRequestBody(equalToJson(requestBody))
  
          );
  
  
  ResponseEntity response = restTemplate.getForEntity("http://localhost:9966/__admin", String.class);
  
  System.out.println("Printing Expected response :" + response);
  
  sendToJmsOutChannel.send(MessageBuilder.withPayload(TestUtil.createSampleInputMessage(receiptNumber)).build());
  
  verify(postRequestedFor(urlEqualTo(TestUtil.EVENT_URL)));`
  </code></pre>
  
  <p>The failure I get is </p>
  
  <blockquote>
    <p>com.github.tomakehurst.wiremock.client.VerificationException: A request was unmatched by any stub mapping. Closest stub mapping was: expected:&lt;
    POST
    /pa/his/v1/ev> but was:&lt;
    POST
    /pa/his/v1/ev></p>
  </blockquote>
  
  <p>Here is the test with <strong>Spring's MockRestServiceServer</strong></p>
  
  <pre><code>@Before
  public void setup() throws PdsListenerException, URISyntaxException {       
  
      mockServer = MockRestServiceServer.createServer(restTemplate);
  
  }
  
  @Test
  public void test_001_success() throws InterruptedException, JSONException, URISyntaxException {
      rNumber = TestUtil.generateRNumber();
  
      String requestBody = TestUtil.createSampleInputMessage(rNumber);
  
  
  
      mockServer.expect(once(), requestTo("http://localhost:9966" + TestUtil.EVENT_URL))
          .andRespond(withCreatedEntity(new URI(TestUtil.EVENT_URL)));
  
  
  
      sendToJmsOutChannel.send(MessageBuilder.withPayload(TestUtil.createSampleInputMessage(rNumber)).build());
  
  
      mockServer.verify();
  
  
  }
  </code></pre>
  
  <p>The failure I get is </p>
  
  <blockquote>
    <p>java.lang.AssertionError: Further request(s) expected leaving 1 unsatisfied expectation(s).
    0 request(s) executed.</p>
  </blockquote>
  
  <p>I am not sure why the matching is failing. Is there anyone that can point out where I should be looking at.</p>