use of org.apache.hadoop.hbase.util.SimplePositionedByteRange in project hbase by apache.
the class TestPBCell method testRoundTrip.
/**
* Basic test to verify utility methods in {@link PBType} and delegation to protobuf works.
*/
@Test
public void testRoundTrip() {
final Cell cell = new KeyValue(Bytes.toBytes("row"), Bytes.toBytes("fam"), Bytes.toBytes("qual"), Bytes.toBytes("val"));
CellProtos.Cell c = ProtobufUtil.toCell(cell), decoded;
PositionedByteRange pbr = new SimplePositionedByteRange(c.getSerializedSize());
pbr.setPosition(0);
int encodedLength = CODEC.encode(pbr, c);
pbr.setPosition(0);
decoded = CODEC.decode(pbr);
assertEquals(encodedLength, pbr.getPosition());
assertTrue(CellUtil.equals(cell, ProtobufUtil.toCell(decoded)));
}
Aggregations