title: How should I unit test Java that calls a MySQL stored procedure?
body: <p>I'm writing a simple application that will read some records and insert them in a database.  I've written a stored procedure that handles the insertion logic, and plan to test that separately.  Now I'd like to write a good unit test for the portion of the logic that takes a business object and passes it to the stored procedure call.</p>
  
  <p>I <em>think</em> what I want to do is pass a mock of the database connection, then assert that the call is made with expected parameter values:</p>
  
  <pre><code>Connection dbConnection = makeMockConnection();  // how?
  MyObjectWriter writer = new MyObjectWriter(dbConnection);
  writer.write(someSampleObject);
  // somehow assert that dbConnection called
  // `sp_saveMyObject` with param values x, y, and z
  </code></pre>
  
  <p>However, it seems like a lot of work dig around inside <code>java.sql.Connection</code>, understand how it works, then mock all the results.  Is there a test library that does all this for me?  Am I coming at this the wrong way?</p>