use of org.neo4j.io.pagecache.StubPagedFile in project neo4j by neo4j.
the class PagedByteChannelsTest method mustCloseCursorOnClose.
@Theory
public void mustCloseCursorOnClose(ThrowingFunction<PagedFile, ? extends Channel, IOException> channelConstructor) throws Exception {
AtomicInteger closeCounter = new AtomicInteger();
PagedFile pf = new StubPagedFile(8192) {
@Override
public PageCursor io(long pageId, int pf_flags) throws IOException {
return new DelegatingPageCursor(super.io(pageId, pf_flags)) {
@Override
public void close() {
super.close();
closeCounter.getAndIncrement();
}
};
}
};
channelConstructor.apply(pf).close();
assertThat(closeCounter.get(), is(1));
}
use of org.neo4j.io.pagecache.StubPagedFile in project neo4j by neo4j.
the class BaseHighLimitRecordFormatTest method mustCheckForOutOfBoundsWhenReadingDoubleRecord.
@Test
public void mustCheckForOutOfBoundsWhenReadingDoubleRecord() throws Exception {
MyRecordFormat format = new MyRecordFormat();
StubPageCursor cursor = new StubPageCursor(0, 4);
cursor.putByte(0, (byte) (HEADER_BIT_RECORD_UNIT + HEADER_BIT_FIRST_RECORD_UNIT));
StubPagedFile pagedFile = new StubPagedFile(3) {
@Override
protected void prepareCursor(StubPageCursor cursor) {
cursor.putByte(0, (byte) HEADER_BIT_RECORD_UNIT);
}
};
format.shortsPerRecord.add(2);
format.read(new MyRecord(0), cursor, RecordLoad.NORMAL, 4);
assertTrue(cursor.checkAndClearBoundsFlag());
}
Aggregations