use of com.couchbase.client.deps.io.netty.buffer.ByteBuf in project components by Talend.
the class CouchbaseEventGenericRecordConverterTest method testConvertToAvroFailedIllegalRecordIndex.
@Test(expected = IndexOutOfBoundsException.class)
public void testConvertToAvroFailedIllegalRecordIndex() {
ByteBuf buffer = Mockito.mock(ByteBuf.class);
// Mocking key object
Mockito.when(buffer.getByte(0)).thenReturn(MessageUtil.MAGIC_REQ);
Mockito.when(buffer.getByte(1)).thenReturn(MessageUtil.DCP_EXPIRATION_OPCODE);
Mockito.when(buffer.getByte(4)).thenReturn(OFFSET);
Mockito.when(buffer.getShort(2)).thenReturn(LENGTH);
ByteBuf key = Mockito.mock(ByteBuf.class);
Mockito.when(key.readableBytes()).thenReturn(4);
Mockito.when(buffer.slice(29, 10)).thenReturn(key);
IndexedRecord record = converter.convertToAvro(buffer);
record.get(10);
}
use of com.couchbase.client.deps.io.netty.buffer.ByteBuf in project components by Talend.
the class CouchbaseEventGenericRecordConverterTest method testConvertToAvroFailedToChangeRecord.
@Test(expected = UnmodifiableAdapterException.class)
public void testConvertToAvroFailedToChangeRecord() {
ByteBuf buffer = Mockito.mock(ByteBuf.class);
// Mocking key object
Mockito.when(buffer.getByte(0)).thenReturn(MessageUtil.MAGIC_REQ);
Mockito.when(buffer.getByte(1)).thenReturn(MessageUtil.DCP_EXPIRATION_OPCODE);
Mockito.when(buffer.getByte(4)).thenReturn(OFFSET);
Mockito.when(buffer.getShort(2)).thenReturn(LENGTH);
ByteBuf key = Mockito.mock(ByteBuf.class);
Mockito.when(key.readableBytes()).thenReturn(4);
Mockito.when(buffer.slice(29, 10)).thenReturn(key);
IndexedRecord record = converter.convertToAvro(buffer);
record.put(0, "Update is not supported");
}
Aggregations