public void testUpdateWithRequiredRowsAffected() throws SQLException { TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.update("myStatement", "myParameter"); template.executorControl.setReturnValue(10, 1); template.executorControl.replay(); template.update("myStatement", "myParameter", 10); template.executorControl.verify(); }
public void testUpdateWithParameter() throws SQLException { TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.update("myStatement", "myParameter"); template.executorControl.setReturnValue(10, 1); template.executorControl.replay(); assertEquals(10, template.update("myStatement", "myParameter")); template.executorControl.verify(); }
public void testUpdateWithRequiredRowsAffectedAndInvalidRowCount() throws SQLException { TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.update("myStatement", "myParameter"); template.executorControl.setReturnValue(20, 1); template.executorControl.replay(); try { template.update("myStatement", "myParameter", 10); fail("Should have thrown JdbcUpdateAffectedIncorrectNumberOfRowsException"); } catch (JdbcUpdateAffectedIncorrectNumberOfRowsException ex) { // expected assertEquals(10, ex.getExpectedRowsAffected()); assertEquals(20, ex.getActualRowsAffected()); } template.executorControl.verify(); }