Search in sources :

Example 31 with ByteBufferPage

use of org.neo4j.io.pagecache.impl.ByteBufferPage in project neo4j by neo4j.

the class PageSwapperTest method vectoredReadMustNotReopenExplicitlyClosedChannel.

@Test
public void vectoredReadMustNotReopenExplicitlyClosedChannel() throws Exception {
    String filename = "a";
    File file = file(filename);
    ByteBufferPage page = createPage();
    PageSwapperFactory swapperFactory = createSwapperFactory();
    PageSwapper swapper = createSwapperAndFile(swapperFactory, file);
    swapper.write(0, page);
    swapper.close();
    try {
        swapper.read(0, new Page[] { page }, 0, 1);
        fail("Should have thrown because the channel should be closed");
    } catch (ClosedChannelException ignore) {
    // This is fine.
    }
}
Also used : ClosedChannelException(java.nio.channels.ClosedChannelException) ByteBufferPage(org.neo4j.io.pagecache.impl.ByteBufferPage) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)31 ByteBufferPage (org.neo4j.io.pagecache.impl.ByteBufferPage)31 File (java.io.File)30 ClosedChannelException (java.nio.channels.ClosedChannelException)4 ArrayList (java.util.ArrayList)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1