I am currently working on Spring Boot. I am stuck with a problem: My REST service is calling SOAP service and I want to unit test my service whether the XML response from SOAP service matches the REST service response in JSON.
How can I achieve this?
Usually you do such things with mocking. During the test, you inject a class that behaves exactly like the target SOAP service, but is hardcoded to return some predetermined value. See Mockito tutorial for example. In a nutshell, you tell Spring to inject a mocked bean into your service instead of the real one.
You can also mock the actual service, for example with something like Wiremock . In this case, you change the URL in Spring configuration to point to Wiremock instead of the actual service.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.