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 testUpdate() throws SQLException { TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.update("myStatement", null); template.executorControl.setReturnValue(10, 1); template.executorControl.replay(); assertEquals(10, template.update("myStatement")); 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 testQueryForObjectWithParameterAndResultObject() throws SQLException { TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.queryForObject("myStatement", "myParameter", "myResult"); template.executorControl.setReturnValue("myResult", 1); template.executorControl.replay(); assertEquals("myResult", template.queryForObject("myStatement", "myParameter", "myResult")); template.executorControl.verify(); }
public void testQueryForMapWithValueProperty() throws SQLException { Map result = new HashMap(); TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.queryForMap("myStatement", "myParameter", "myKey", "myValue"); template.executorControl.setReturnValue(result, 1); template.executorControl.replay(); assertEquals(result, template.queryForMap("myStatement", "myParameter", "myKey", "myValue")); template.executorControl.verify(); }
public void testQueryForPaginatedListWithParameter() throws SQLException { PaginatedList result = new PaginatedArrayList(10); TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.queryForPaginatedList("myStatement", "myParameter", 10); template.executorControl.setReturnValue(result, 1); template.executorControl.replay(); assertEquals(result, template.queryForPaginatedList("myStatement", "myParameter", 10)); template.executorControl.verify(); }
public void testQueryWithRowHandlerWithParameter() throws SQLException { RowHandler rowHandler = new TestRowHandler(); TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.queryWithRowHandler("myStatement", "myParameter", rowHandler); template.executorControl.setVoidCallable(1); template.executorControl.replay(); template.queryWithRowHandler("myStatement", "myParameter", rowHandler); template.executorControl.verify(); }
public void testQueryForListParameterAndWithResultSize() throws SQLException { List result = new ArrayList(); TestSqlMapClientTemplate template = new TestSqlMapClientTemplate(); template.executor.queryForList("myStatement", "myParameter", 10, 20); template.executorControl.setReturnValue(result, 1); template.executorControl.replay(); assertEquals(result, template.queryForList("myStatement", "myParameter", 10, 20)); 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(); }