### Question:
JDBCResultIterator implements ResultIterator<T> { @Override public void close() throws NoSuchElementException { if (!closed) { nextRow = false; StringBuilder errors = new StringBuilder(); try { resultSet.close(); } catch (SQLException e1) { errors.append("Error closing ResultSet."); } if (statement != null) { try { statement.close(); } catch (SQLException e2) { errors.append("Error closing PreparedStatement."); } } if (errors.length() > 0) { throw new CayenneRuntimeException("Error closing ResultIterator: %s", errors); } closed = true; } } JDBCResultIterator(Statement statement, ResultSet resultSet, RowReader<T> rowReader); @Override Iterator<T> iterator(); @Override List<T> allRows(); @Override boolean hasNextRow(); @Override T nextRow(); @Override void skipRow(); @Override void close();  }### Answer:
@Test public void testClose() throws Exception { Connection c = new MockConnection(); MockStatement s = new MockStatement(c); MockResultSet rs = new MockResultSet("rs"); rs.addColumn("a", new Object[] { "1", "2", "3" }); RowReader<?> rowReader = mock(RowReader.class); try (JDBCResultIterator it = new JDBCResultIterator(s, rs, rowReader);) { assertFalse(rs.isClosed()); assertFalse(s.isClosed()); assertFalse(c.isClosed()); } assertTrue(rs.isClosed()); assertTrue(s.isClosed()); }