use of org.neo4j.storageengine.api.ReadPastEndException in project neo4j by neo4j.
the class ReadAheadChannelTest method shouldReturnPositionWithinBufferedStream.
@Test
public void shouldReturnPositionWithinBufferedStream() throws Exception {
// given
EphemeralFileSystemAbstraction fsa = fileSystemRule.get();
File file = new File("foo.txt");
int readAheadSize = 512;
int fileSize = readAheadSize * 8;
createFile(fsa, file, fileSize);
ReadAheadChannel<StoreChannel> bufferedReader = new ReadAheadChannel<>(fsa.open(file, "r"), readAheadSize);
// when
for (int i = 0; i < fileSize / Long.BYTES; i++) {
assertEquals(Long.BYTES * i, bufferedReader.position());
bufferedReader.getLong();
}
assertEquals(fileSize, bufferedReader.position());
try {
bufferedReader.getLong();
fail();
} catch (ReadPastEndException e) {
// expected
}
assertEquals(fileSize, bufferedReader.position());
}
Aggregations