0

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 ?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.