开发者

Strategies to block an external webservice to simulate "down" during for a testing scenario?

开发者 https://www.devze.com 2022-12-12 02:38 出处:网络
I am working to integrate data from an external web service in the client side of my appliction. Someone asked me to test the condition when the service is unavailable or down. Anyone have any tips on

I am working to integrate data from an external web service in the client side of my appliction. Someone asked me to test the condition when the service is unavailable or down. Anyone have any tips on how to block this site temporarily while we run the test to see how the service degrades?

For those curious we are testing against Virtual Earth, but Google Maps but this would appl开发者_如何学JAVAy to any equally complicated external service.

any thoughts and suggestions are welcome


Create some Mock-Webservice class or interface (and inject it). In there, you could test the response of your system to webservice failures and also what happens, if a web-service request take longer than expected or actually time-out.

DeveloperWorks article on mock testing: http://www.ibm.com/developerworks/library/j-mocktest.html


You need to be sure to test the most common failure modes for this:

  1. DNS lookup fails
  2. IP connection fails (once DNS lookup succeeds)
  3. HTTP response other than 200
  4. HTTP response incomplete or timeout
  5. HTTP response 200 but RPC or document returned is invalid

Those are just a few common failure modes I could think of that will all manifest themselves with different behaviors that you may wish to have your application handle explicitly.

If you set up a computer between the caller and service that routes between them, you can simulate each of these failure modes distinctly and modify your application to handle them.


How about blocking the domain name(s) in question by putting a nonsense entry into the hosts file?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号