Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
680 views
in Technique[技术] by (71.8m points)

java - Accept external REST calls from SpringBootTest context and verify the call

I am writing Spring Boot Integration test. For this, we boot up the empty application (context) and call multiple services as part of test.

One of the requirements is to call the external REST endpoint with payload that contains an URL to notify (call back) and that service, after some business logic, calls the URL received in the payload.

From the test, I can call the REST endpoint, which is external service. But I want to be able to test the call back from that service for the given URL. URL can be random.

Can I do with MockClientServer? OR MockRestServiceServer Or some other day to test this?

Essentially, I want the test to be able to get an external call and verify it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

After trying out a couple things, WireMock actually does what I wanted. It takes the rest call from outside application(s). Very useful for testing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...