RandomAccessFileInputStreamFactory implements MultiViewInputStreamFactory { @Override public RandomAccessFileInputStream newStream() throws IOException { return new RandomAccessFileInputStream(file, rangeOffset, rangeLength); } RandomAccessFileInputStreamFactory(File file, long rangeOffset, long rangeLength); @Override RandomAccessFileInputStream newStream();  }
@Test public void testNewStream_MakesIdenticalStreams() throws IOException { RandomAccessFileInputStream rafis1 = factory.newStream(); RandomAccessFileInputStream rafis2 = factory.newStream(); try { Assert.assertNotSame(rafis1, rafis2); for (int x = 0; x < testData.length; x++) { Assert.assertEquals(x, rafis1.read()); Assert.assertEquals(x, rafis2.read()); } Assert.assertEquals(-1, rafis1.read()); Assert.assertEquals(-1, rafis2.read()); } finally { try { rafis1.close(); } catch (Exception ignored) { } try { rafis2.close(); } catch (Exception ignored) { } } }