@Test
@SuppressWarnings("unchecked")
public void testIteratorCaching() {

    ResultSet<Car> backingResultSet = mock(ResultSet.class);
    when(backingResultSet.iterator()).thenReturn(mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class), mock(Iterator.class));
    IteratorCachingResultSet<Car> iteratorCachingResultSet = new IteratorCachingResultSet<Car>(backingResultSet);
    Iterator<Car> i1 = iteratorCachingResultSet.iterator();
    Iterator<Car> i2 = iteratorCachingResultSet.iterator();
    assertSame(i1, i2);
    i2.hasNext();
    i2.hasNext();
    Iterator<Car> i3 = iteratorCachingResultSet.iterator();
    assertSame(i1, i3);
    i3.next();
    Iterator<Car> i4 = iteratorCachingResultSet.iterator();
    assertNotSame(i3, i4);
    i4.remove();
    Iterator<Car> i5 = iteratorCachingResultSet.iterator();
    assertNotSame(i4, i5);
    i5.hasNext();
    i5.hasNext();
    Iterator<Car> i6 = iteratorCachingResultSet.iterator();
    assertSame(i5, i6);
    iteratorCachingResultSet.isEmpty();
    iteratorCachingResultSet.isNotEmpty();
    Iterator<Car> i7 = iteratorCachingResultSet.iterator();
    assertSame(i6, i7);
}