title: Mocking an object that uses jni using EasyMock
body: <p>So my class under test has code that looks braodly like this</p>
  
  <pre><code>public void doSomething(int param)
  {
      Report report = new Report()
      ...do some calculations
      report.someMethod(someData)
  }
  </code></pre>
  
  <p>my intention was to extract the construction of report into a protected method and override it to use a mock object that I could then test to ensure that someMethod had been called with the right data. </p>
  
  <p>So far so good. But Report isnt under my control, and to mkae things worse it uses JNI to load a library at runtime.</p>
  
  <p>If I do 
      Report report = EasyMock.createMock(Report.class)</p>
  
  <p>then EasyMock attempts to use reflection to find out the class members, but this causes an attempt to load the JNI library, which fails (the JNI libraries are only available on UNIX).</p>
  
  <p>Im considering two things: a) Introduce a ReportWrapper interface with two implementations, one of which will delegate calls to an real Report (so basically a Proxy), and a second which will basically use a mock object. or b) instead of calling someMethod, call a protected method which will in turn call someMethod that I can override in a testing subclass.</p>
  
  <p>Either way it seems nasty. Any better ways?</p>