我的方法是这样的:
public class Decompile extends JdbcDaoSupport
public void getRunner(){
String val = this.getJdbcTemplate().queryForObject(sql,String.class, new Object[]{1001});
}
}
请建议我将如何模拟它.
Please suggest how I would mock this.
EasyMock-3.0 示例
an EasyMock-3.0 example
String sql = "select * from t1";
Object[] params = new Object[] { 1001 };
JdbcTemplate t = EasyMock.createMock(JdbcTemplate.class);
EasyMock.expect(
t.queryForObject(sql, String.class, params)).andReturn("res");
EasyMock.replay(t);
这篇关于如何模拟 JdbcTemplate.queryForObject() 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!