### Question:
MultiAutoGrowingByteBufferBackedFiler implements IFiler { @Override public final void seek(long position) throws IOException { position(position); } MultiAutoGrowingByteBufferBackedFiler(long initialBufferSegmentSize,
        long maxBufferSegmentSize,
        ByteBufferFactory byteBufferFactory); private  MultiAutoGrowingByteBufferBackedFiler(long maxBufferSegmentSize,
        ByteBufferFactory byteBufferFactory,
        ByteBufferBackedFiler[] filers,
        long length,
        int fShift,
        long fseekMask); MultiAutoGrowingByteBufferBackedFiler duplicateAll(); @Override final void seek(long position); @Override long skip(long skip); @Override long length(); @Override void setLength(long len); @Override long getFilePointer(); @Override void eof(); @Override int read(); @Override int read(byte[] b); @Override int read(byte[] b, int offset, int len); @Override void write(byte b); @Override void write(byte[] b, int offset, int len); @Override void close(); @Override void flush(boolean fsync); @Override Object lock(); static final long MAX_BUFFER_SEGMENT_SIZE; static long MAX_POSITION; }### Answer:
@Test public void writeALongTest() throws Exception { byte[] intLongBuffer = new byte[8]; for (int i = 1; i < 10; i++) { @SuppressWarnings("unchecked") ByteBufferFactory[] bufferFactorys = new ByteBufferFactory[] { new HeapByteBufferFactory(), new DirectByteBufferFactory() }; for (ByteBufferFactory bf : bufferFactorys) { System.out.println("i:" + i); MultiAutoGrowingByteBufferBackedFiler filer = new MultiAutoGrowingByteBufferBackedFiler(i, i, bf); UIO.writeLong(filer, Long.MAX_VALUE, "a long", intLongBuffer); filer.seek(0); Assert.assertEquals(UIO.readLong(filer, "a long", intLongBuffer), Long.MAX_VALUE, "Booya"); } } }
@Test public void writeIntsTest() throws Exception { byte[] intLongBuffer = new byte[8]; for (int b = 1; b < 10; b++) { System.out.println("b:" + b); @SuppressWarnings("unchecked") ByteBufferFactory[] bufferFactorys = new ByteBufferFactory[] { new HeapByteBufferFactory(), new DirectByteBufferFactory() }; for (ByteBufferFactory bf : bufferFactorys) { MultiAutoGrowingByteBufferBackedFiler filer = new MultiAutoGrowingByteBufferBackedFiler(b, b, bf); for (int i = 0; i < b * 4; i++) { System.out.println(b + " " + i + " " + bf); UIO.writeInt(filer, i, "", new byte[4]); filer.seek(i * 4); Assert.assertEquals(UIO.readInt(filer, "", intLongBuffer), i, "Boo " + i + " at " + b + " " + bf); } } } }