My web application reads/writes xml document via a url connection. Is there anyway I can fake this connection and read the document from a file? I would like to be able to test all the cases of 5xx, 2xx http errors.
How is it possible that contacting a different server (even if on the same machine) and going through a complete HTTP request cycle could go wrong, as opposed to just reading a file off of a disk?! (Besides that it'll take longer.)
The whole point of coding to an interface is so you can plug in implementations. Being able to plug in implementations means you could just *mock* the XML service and implement almost nothing, rather than making sure the server is started.
You've turned a unit test into an integration test, integrating something that doesn't even exist in real life. And for the *integration* test you now have to make your Jetty simulate various failure modes, instead of just mocking the service and supplying the results you need.