use of alluxio.worker.block.io.MockBlockReader in project alluxio by Alluxio.
the class NettyDataServerTest method readBlock.
@Test
public void readBlock() throws Exception {
long sessionId = 0;
long blockId = 1;
long offset = 2;
long length = 3;
long lockId = 4;
when(mBlockWorker.readBlockRemote(sessionId, blockId, lockId)).thenReturn(new MockBlockReader("abcdefg".getBytes(Charsets.UTF_8)));
RPCResponse response = request(new RPCBlockReadRequest(blockId, offset, length, lockId, sessionId));
// Verify that the 3 bytes were read at offset 2.
assertEquals("cde", Charsets.UTF_8.decode(response.getPayloadDataBuffer().getReadOnlyByteBuffer()).toString());
}
Aggregations