@Test
public void testFileIOEngine() throws IOException {
int size = 2 * 1024 * 1024; // 2 MB
String filePath = "testFileIOEngine";
try {
FileIOEngine fileIOEngine = new FileIOEngine(filePath, size);
for (int i = 0; i < 50; i++) {
int len = (int) Math.floor(Math.random() * 100);
long offset = (long) Math.floor(Math.random() * size % (size - len));
byte[] data1 = new byte[len];
for (int j = 0; j < data1.length; ++j) {
data1[j] = (byte) (Math.random() * 255);
}
byte[] data2 = new byte[len];
fileIOEngine.write(ByteBuffer.wrap(data1), offset);
fileIOEngine.read(ByteBuffer.wrap(data2), offset);
for (int j = 0; j < data1.length; ++j) {
assertTrue(data1[j] == data2[j]);
}
}
} finally {