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