コード例 #1
0
 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();
 }
コード例 #2
0
 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();
 }
コード例 #3
0
 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();
 }