title: Getting EasyMock mock objects to throw Exceptions
body: <p>I'm in process of using EasyMock to write Unit tests for a number of collaborating classes. One of these classes (lets call it <code>Foo</code>) opens a network connection to a remote server and parses that servers' XML response into something the rest of the classes can use. </p>
  
  <p>Presently my tests only encompass scenarios in which everything is hunky-dory and the remote server is up and running and returning XML as expected. However, I <em>would</em> be happier if I could mock <code>Foo</code> so that I simulate what happens if the remote server is down, or there is some other problem that causes an <code>IOException</code> to be thrown by <code>Foo</code>.</p>
  
  <p>I have had a look at the EasyMock API, and I can't see anything that looks like a method asking a mock to throw an Exception. </p>
  
  <p>It's not absolutely essential for me to have <code>Exception</code> based tests, but I am curious if its possible with EasyMock, and I think it would be useful to test <code>Foo</code>'s public contract in this way. </p>
  
  <p>Anyone done anything like this with EasyMock before?</p>
  
  <p><strong>References</strong></p>
  
  <ul>
  <li><a href="http://easymock.org/api/easymock/3.0/index.html">EasyMock API</a></li>
  </ul>