CompositeReader extends Reader { @Override public void close() throws IOException { for (Reader reader : this.readers) { reader.close(); } } CompositeReader(Reader... readers); @Override void close(); @Override int read(char[] buffer, int offset, int length);  }
@Test void closeAll() throws Exception { Reader first = mock(Reader.class, "first"); Reader second = mock(Reader.class, "second"); new CompositeReader(first, second).close(); verify(first).close(); verify(second).close(); }