### Question:
SelectIterator implements CloseableIterator<T> { @Override public T nextThrow() throws SQLException { if (closed) { return null; } if (!alreadyMoved) { boolean hasResult; if (first) { first = false; hasResult = results.first(); } else { hasResult = results.next(); } if (!hasResult) { first = false; return null; } } first = false; return getCurrent(); } SelectIterator(Class<?> dataClass, Dao<T, ID> classDao, GenericRowMapper<T> rowMapper,
			ConnectionSource connectionSource, DatabaseConnection connection, CompiledStatement compiledStmt,
			String statement, ObjectCache objectCache); boolean hasNextThrow(); @Override boolean hasNext(); @Override T first(); @Override T previous(); @Override T current(); @Override T nextThrow(); @Override T next(); @Override T moveRelative(int offset); void removeThrow(); @Override void remove(); @Override void close(); @Override void closeQuietly(); @Override DatabaseResults getRawResults(); @Override void moveToNext();  }### Answer:
@Test(expected = IllegalStateException.class) public void testNextThrow() throws Exception { ConnectionSource cs = createMock(ConnectionSource.class); cs.releaseConnection(null); CompiledStatement stmt = createMock(CompiledStatement.class); DatabaseResults results = createMock(DatabaseResults.class); expect(stmt.runQuery(null)).andReturn(results); expect(results.first()).andThrow(new SQLException("some result problem")); @SuppressWarnings("unchecked") GenericRowMapper<Foo> mapper = (GenericRowMapper<Foo>) createMock(GenericRowMapper.class); stmt.close(); replay(stmt, mapper, cs, results); SelectIterator<Foo, Integer> iterator = new SelectIterator<Foo, Integer>(Foo.class, null, mapper, cs, null, stmt, "statement", null); try { iterator.hasNext(); } finally { iterator.close(); } verify(stmt, mapper, cs, results); }