lundi 26 octobre 2015

MockRestServiceServer does not verify created RequestMatchers

I'm trying to write an integration test for my spring-integration flow. I wanted to use MockRestServiceServer to record and match the outgoing requests(using http:outbound-gateway) to the Rest server. However when I call verify method of the mockServer, it's not verifying as it is expected.

I'm writing my tests in the following way:

RestTemplate restTemplate = new RestTemplate();
MockRestServiceServer mockServer = MockRestServiceServer.createServer(restTemplate);

mockServer.expect(requestTo("adfasfadf.com")).andExpect(method(HttpMethod.GET));

// Call spring integration flow here

mockServer.verify();

When I check the verify method of MockRestServiceServer, it's not calling match methods of RequestMatchers, which I believe there is something wrong with this logic. Am I missing something here?

/**
 * Verify that all expected requests set up via
 * {@link #expect(RequestMatcher)} were indeed performed.
 * @throws AssertionError when some expectations were not met
 */
public void verify() {
    if (this.expectedRequests.isEmpty() || this.expectedRequests.equals(this.actualRequests)) {
        return;
    }
    throw new AssertionError(getVerifyMessage());
}

Aucun commentaire:

Enregistrer un commentaire