@Test
public void unmapMemoryMappedFile() throws IOException {

    // Make sure file is gone
    File tmpFile = new File("Unsafe9RTest.tmp");
    assertTrue("pre-create", !tmpFile.exists() || tmpFile.delete());
    // Create new file
    final FileChannel channel = new RandomAccessFile(tmpFile, "rw").getChannel();
    assertTrue("post-create", tmpFile.exists());
    // Map to memory
    final ByteBuffer buffer = channel
            .map(FileChannel.MapMode.READ_WRITE, 0, 1024)
            .load();
    if (PlatformInfo.isWindows()) {
        // Windows keeps open files from being deleted
        assertFalse("pre-close", tmpFile.delete());
        channel.close();
        assertFalse("post-close", tmpFile.delete());
    } else {
        // Linux doesn't
        channel.close();
    }
    // Unmap memory
    Unsafe9R.invokeCleaner(buffer);
    assertTrue("post-free", tmpFile.delete());
}