Search in sources :

Example 1 with PutChunkReplicaRequest

use of io.crate.blob.PutChunkReplicaRequest in project crate by crate.

the class SerializationTests method testPutChunkReplicaRequestSerialization.

@Test
public void testPutChunkReplicaRequestSerialization() throws Exception {
    BytesStreamOutput outputStream = new BytesStreamOutput();
    UUID transferId = UUID.randomUUID();
    PutChunkReplicaRequest requestOut = new PutChunkReplicaRequest();
    requestOut.index("foo");
    requestOut.transferId = transferId;
    requestOut.currentPos = 10;
    requestOut.isLast = false;
    requestOut.content = new BytesArray(new byte[] { 0x65, 0x66 });
    requestOut.sourceNodeId = "nodeId";
    requestOut.writeTo(outputStream);
    StreamInput inputStream = StreamInput.wrap(outputStream.bytes());
    PutChunkReplicaRequest requestIn = new PutChunkReplicaRequest();
    requestIn.readFrom(inputStream);
    assertEquals(requestOut.currentPos, requestIn.currentPos);
    assertEquals(requestOut.isLast, requestIn.isLast);
    assertEquals(requestOut.content, requestIn.content);
    assertEquals(requestOut.transferId, requestIn.transferId);
    assertEquals(requestOut.index(), requestIn.index());
}
Also used : BytesArray(org.elasticsearch.common.bytes.BytesArray) StreamInput(org.elasticsearch.common.io.stream.StreamInput) UUID(java.util.UUID) PutChunkReplicaRequest(io.crate.blob.PutChunkReplicaRequest) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

PutChunkReplicaRequest (io.crate.blob.PutChunkReplicaRequest)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 UUID (java.util.UUID)1 BytesArray (org.elasticsearch.common.bytes.BytesArray)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 Test (org.junit.Test)1