Search in sources :

Example 1 with MockBlockReader

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());
}
Also used : RPCBlockReadRequest(alluxio.network.protocol.RPCBlockReadRequest) RPCResponse(alluxio.network.protocol.RPCResponse) MockBlockReader(alluxio.worker.block.io.MockBlockReader) Test(org.junit.Test)

Aggregations

RPCBlockReadRequest (alluxio.network.protocol.RPCBlockReadRequest)1 RPCResponse (alluxio.network.protocol.RPCResponse)1 MockBlockReader (alluxio.worker.block.io.MockBlockReader)1 Test (org.junit.Test)1