I\'m in process of using EasyMock to write Unit tests for a number of collaborating classes. One of these classes (lets call it Foo) opens a network connection
Foo
you can use the method andThrow(Throwable throwable) in easy mock. Check the documentation - heading Working with Exceptions.
andThrow(Throwable throwable)
For example
expect(mock.voteForRemoval("Document")) .andThrow(new RuntimeException(), 4);