### Question:
FileIOEngine implements IOEngine { public FileIOEngine(String filePath, long fileSize) throws IOException { try { raf = new RandomAccessFile(filePath, "rw"); } catch (java.io.FileNotFoundException fex) { LOG.error("Can't create bucket cache file " + filePath, fex); throw fex; } try { raf.setLength(fileSize); } catch (IOException ioex) { LOG.error("Can't extend bucket cache file; insufficient space for " + StringUtils.byteDesc(fileSize), ioex); raf.close(); throw ioex; } fileChannel = raf.getChannel(); LOG.info("Allocating " + StringUtils.byteDesc(fileSize) + ", on the path:" + filePath); } FileIOEngine(String filePath, long fileSize); @Override boolean isPersistent(); @Override int read(ByteBuffer dstBuffer, long offset); @Override void write(ByteBuffer srcBuffer, long offset); @Override void sync(); @Override void shutdown();  }### Answer:
@Test public void testFileIOEngine() throws IOException { int size = 2 * 1024 * 1024; 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 { File file = new File(filePath); if (file.exists()) { file.delete(); } } }