'How to test a soap endpoint that returns soapfaultclientexception

I have a soap endpoint that returns fault message when passing some parameters. I need to validate the fault string and pass the test when fault string is returned.

  runner.soap(action -> action
                .client(testClient)
                .receive()
                .status(HttpStatus.INTERNAL_SERVER_ERROR)
                .validate("/t:soap:Fault/t:faultcode", "test"));

This above code gives me a soapfaultclientexception. I couldn't pass this test. Any idea.



Solution 1:[1]

Please use fault strategy=propagate on the soap client configuration. By default it uses throwException strategy. This is why you get the exception.

With propagate you should be able to verify the fault in a receive action.

Please refer to the documentation for the details.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christoph Deppisch