MySQLBlobBinlogProtocolValue implements MySQLBinlogProtocolValue { @Override public Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload) { return payload.readStringFixByBytes(readLengthFromMeta(columnDef.getColumnMeta(), payload)); }  @Override Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload);  }
@Test public void assertReadWithMeta1() { columnDef.setColumnMeta(1); when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedByte()).thenReturn((short) 0xff); when(payload.readStringFixByBytes(0xff)).thenReturn(new byte[255]); assertThat(new MySQLBlobBinlogProtocolValue().read(columnDef, payload), is(new byte[255])); }
@Test public void assertReadWithMeta2() { columnDef.setColumnMeta(2); when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedShortLE()).thenReturn(0xffff); when(payload.readStringFixByBytes(0xffff)).thenReturn(new byte[65535]); assertThat(new MySQLBlobBinlogProtocolValue().read(columnDef, payload), is(new byte[65535])); }
@Test public void assertReadWithMeta3() { columnDef.setColumnMeta(3); when(payload.getByteBuf()).thenReturn(byteBuf); when(byteBuf.readUnsignedMediumLE()).thenReturn(0xffffff); when(payload.readStringFixByBytes(0xffffff)).thenReturn(new byte[255]); assertThat(new MySQLBlobBinlogProtocolValue().read(columnDef, payload), is(new byte[255])); }
@Test public void assertReadWithMeta4() { columnDef.setColumnMeta(4); when(payload.readInt4()).thenReturn(Integer.MAX_VALUE); when(payload.readStringFixByBytes(Integer.MAX_VALUE)).thenReturn(new byte[255]); assertThat(new MySQLBlobBinlogProtocolValue().read(columnDef, payload), is(new byte[255])); }
@Test(expected = UnsupportedOperationException.class) public void assertReadWithUnknownMetaValue() { columnDef.setColumnMeta(5); new MySQLBlobBinlogProtocolValue().read(columnDef, payload); }