I would like test my service return a 400 Bad request when it receive a payload with bad attribute.
I'm using an valid payload and add an invalid attribut. In SOAP-UI, it return a 400 bad request, but not with MockWebServiceClient, the bad attribute is skipped and process the request well.
@WebServiceServerTest({ MyEndpoint.class, WebServiceConfig.class})
class MyEndpointTests {
@Autowired
private MockWebServiceClient client;
@Value("classpath:endpoint/request/myEndoint.myRequest.xml")
private Resource requestFile;
@Test
void myEndpoint_InvalidRequest() throws Exception {
XMLTransformer transformer = new XMLTransformer(requestValidFile);
transformer.add("http://namespace.foo.bar/", "myRequest",
"http://namespace.foo.bar/", "thisIsNotAValidAttribute", "false");
this.client
.sendRequest(RequestCreators.withSoapEnvelope(transformer.getSource()))
.andExpect(ResponseMatchers.serverOrReceiverFault());
}
How can i test that ?