@Test(expected = IllegalStateException.class)
public void testRemoveThrow() throws Exception {
ConnectionSource cs = createMock(ConnectionSource.class);
cs.releaseConnection(null);
CompiledStatement stmt = createMock(CompiledStatement.class);
DatabaseResults results = createMock(DatabaseResults.class);
expect(results.first()).andReturn(true);
expect(stmt.runQuery(null)).andReturn(results);
@SuppressWarnings("unchecked")
GenericRowMapper<Foo> mapper = (GenericRowMapper<Foo>) createMock(GenericRowMapper.class);
Foo foo = new Foo();
expect(mapper.mapRow(results)).andReturn(foo);
@SuppressWarnings("unchecked")
Dao<Foo, Integer> dao = (Dao<Foo, Integer>) createMock(Dao.class);
expect(dao.delete(foo)).andThrow(new SQLException("some dao problem"));
stmt.close();
replay(stmt, dao, results, mapper, cs);
SelectIterator<Foo, Integer> iterator =
new SelectIterator<Foo, Integer>(Foo.class, dao, mapper, cs, null, stmt, "statement", null);
iterator.hasNext();
iterator.next();