### Question:
IndexCursor { final void initialize( T progressor ) { if ( this.progressor != null ) { this.progressor.close(); } this.progressor = progressor; }    }### Answer:
@Test public void shouldClosePreviousBeforeReinitialize() { StubIndexCursor cursor = new StubIndexCursor(); StubProgressor progressor = new StubProgressor(); cursor.initialize( progressor ); assertFalse( "open before re-initialize", progressor.isClosed ); StubProgressor otherProgressor = new StubProgressor(); cursor.initialize( otherProgressor ); assertTrue( "closed after re-initialize", progressor.isClosed ); assertFalse( "new still open", otherProgressor.isClosed ); }