@Test
public void testValidateSimpleRequestAndSendResponse() throws Exception {
//add the mock responses with request path, expected request and response
//expected request is compared with the actual one using xmlunit
httpTestServer.addResponseForRequest("/test",
new ClassPathResource("mock-request/validSearchByID12345.xml"),
new ClassPathResource("mock-response/validSearchByID12345.xml"),
null);
//load and send request to OSB
final ClassPathResource resource =
new ClassPathResource("/request/validSearchByIDRequest.xml");
final ContentExchange contentExchange =
httpTestClient.postToUrl(osbEndpoint, resource.getInputStream());
//assert that a 200 status is retrieved
assertThat("error: " + contentExchange.getResponseContent(),
contentExchange.getResponseStatus(), is(200));
//other assert to the payload
...
}
@Test
public void testValidateBadRequest() throws Exception {
//no responses are put in the mock server
//load and send request to OSB
final ClassPathResource resource =
new ClassPathResource("/request/invalidRequest.xml");
final ContentExchange contentExchange =
httpTestClient.postToUrl(osbEndpoint, resource.getInputStream());
//assert that a 500 status is retrieved
assertThat(contentExchange.getResponseStatus(), is(500));
//other assert to the format of the SOAP fault
...
}