If you are looking to write a true isolation unit test of your code then I agree that your test isn't appropriate. If you are looking to write more of an integration test then your approach is fine.
If you are looking to write a true isolation unit test of your code then I agree that your test isn't appropriate. If you are looking to write more of an integration test then your approach is fine. For my isolation junits I create them so that they only test the class under test.
I use EasyMock to mock out all collaborating classes. So in this case I would create a mock for httpClient. I would set up a test where the mock throws the exception, and then assert that the class under test handles the exception as expected.
The code snippets below may give you an idea of what I mean. Private DefaultHttpClient httpClient; private ClassUnderTest classUnderTest; @Before public void setUpTest() { httpClient = createMock(DefaultHttpClient. Class); @Test public void performARequestThatThrowsAnIOException() { expect(httpClient.
Execute(post)). AndThrow(iOException); replayAll(); try { classUnderTest. ExecuteMethodUnderTest(); fail("This test should throw an IOException."); } catch (IOException e){ verifyAll(); } The above assumes that the method in the class under test throws the exception.
If the exception is caught then you would write the above differently.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.