Hi,
I'm looking at a way to test the following code against a mock object,
or test database using DBUnit:
What is the recommended approach? MockObjects' MockDataSource and MockConnection2 seem easy enough to setup, but I'm getting an NPE because the statment wrapped by targetTemplate.query() is null.Code:public List getLinePairs() { JdbcTemplate targetTemplate = new JdbcTemplate(target); RowMapper hqLineMapper = new RowMapper() { public Object mapRow(ResultSet rs, int rowNum) throws SQLException { return new LinePair(rs.getString(hqAbbrColumnName), rs.getString(catAbbrColumnName)); } }; return targetTemplate.query(selectTargetHqLineSql, hqLineMapper); }
Is it easier or more appropriate to setup a dbunit database and test the DataSource code against a real database? Or is there a secret getting all the right mock statements initialized?


Reply With Quote
