@org.junit.Test
public void basicOps() throws IOException {
File file = new File("target/foo.data");
file.delete();
MemoryMappedFile mmf = new MemoryMappedFile(file, 1024*1024*100, false);
int PAGE_SIZE = 1024*4;
int LAST_PAGE = 100;
byte expect[] = createData(PAGE_SIZE);
mmf.write(0, expect);
mmf.write(LAST_PAGE *PAGE_SIZE, expect);
// Validate data on the first page.
byte actual[] = new byte[PAGE_SIZE];
mmf.read(0, actual);
Assert.assertEquals('a', actual[0]);
Assert.assertEquals('a', actual[26]);
Assert.assertEquals('z', actual[26+25]);
// Validate data on the 3rd page.
actual = new byte[PAGE_SIZE];
mmf.read(PAGE_SIZE*LAST_PAGE, actual);
Assert.assertEquals('a', actual[0]);
Assert.assertEquals('a', actual[26]);
Assert.assertEquals('z', actual[26+25]);
mmf.sync();
mmf.close();
}