MySQLBinlogRowsEventPacket extends AbstractMySQLBinlogEventPacket { public void readRows(final MySQLBinlogTableMapEventPacket tableMapEventPacket, final MySQLPacketPayload payload) { List<MySQLBinlogColumnDef> columnDefs = tableMapEventPacket.getColumnDefs(); while (hasNextRow(payload)) { rows.add(readRow(columnDefs, payload)); if (isUpdateRowsEvent(getBinlogEventHeader().getEventType())) { rows2.add(readRow(columnDefs, payload)); } } } MySQLBinlogRowsEventPacket(final MySQLBinlogEventHeader binlogEventHeader, final MySQLPacketPayload payload); void readRows(final MySQLBinlogTableMapEventPacket tableMapEventPacket, final MySQLPacketPayload payload);  }
@Test public void assertReadWriteRowV1WithoutNullValue() { when(binlogEventHeader.getEventType()).thenReturn(MySQLBinlogEventType.WRITE_ROWS_EVENTv1.getValue()); when(payload.readInt8()).thenReturn(Long.MAX_VALUE); MySQLBinlogRowsEventPacket actual = new MySQLBinlogRowsEventPacket(binlogEventHeader, payload); actual.readRows(tableMapEventPacket, payload); assertBinlogRowsEventV1BeforeRows(actual); assertFalse(actual.getColumnsPresentBitmap().isNullParameter(0)); assertNull(actual.getColumnsPresentBitmap2()); assertThat(actual.getRows().size(), is(1)); assertThat(actual.getRows().get(0)[0], is(Long.MAX_VALUE)); assertTrue(actual.getRows2().isEmpty()); }
@Test public void assertReadWriteRowV1WithNullValue() { when(payload.readInt1()).thenReturn(0x01); when(binlogEventHeader.getEventType()).thenReturn(MySQLBinlogEventType.WRITE_ROWS_EVENTv1.getValue()); MySQLBinlogRowsEventPacket actual = new MySQLBinlogRowsEventPacket(binlogEventHeader, payload); actual.readRows(tableMapEventPacket, payload); assertBinlogRowsEventV1BeforeRows(actual); assertTrue(actual.getColumnsPresentBitmap().isNullParameter(0)); assertNull(actual.getColumnsPresentBitmap2()); assertThat(actual.getRows().size(), is(1)); assertNull(actual.getRows().get(0)[0]); assertTrue(actual.getRows2().isEmpty()); }
@Test public void assertReadUpdateRowV1WithoutNullValue() { when(binlogEventHeader.getEventType()).thenReturn(MySQLBinlogEventType.UPDATE_ROWS_EVENTv1.getValue()); when(payload.readInt8()).thenReturn(Long.MAX_VALUE, Long.MIN_VALUE); MySQLBinlogRowsEventPacket actual = new MySQLBinlogRowsEventPacket(binlogEventHeader, payload); actual.readRows(tableMapEventPacket, payload); assertBinlogRowsEventV1BeforeRows(actual); assertFalse(actual.getColumnsPresentBitmap().isNullParameter(0)); assertFalse(actual.getColumnsPresentBitmap2().isNullParameter(0)); assertThat(actual.getRows().size(), is(1)); assertThat(actual.getRows().get(0)[0], is(Long.MAX_VALUE)); assertThat(actual.getRows2().size(), is(1)); assertThat(actual.getRows2().get(0)[0], is(Long.MIN_VALUE)); }
@Test public void assertReadWriteRowV2WithoutNullValue() { when(binlogEventHeader.getEventType()).thenReturn(MySQLBinlogEventType.WRITE_ROWS_EVENTv2.getValue()); when(payload.readInt8()).thenReturn(Long.MAX_VALUE); MySQLBinlogRowsEventPacket actual = new MySQLBinlogRowsEventPacket(binlogEventHeader, payload); actual.readRows(tableMapEventPacket, payload); assertBinlogRowsEventV2BeforeRows(actual); assertFalse(actual.getColumnsPresentBitmap().isNullParameter(0)); assertNull(actual.getColumnsPresentBitmap2()); assertThat(actual.getRows().size(), is(1)); assertThat(actual.getRows().get(0)[0], is(Long.MAX_VALUE)); assertTrue(actual.getRows2().isEmpty()); }
@Test public void assertReadWriteRowV2WithNullValue() { when(payload.readInt1()).thenReturn(0x01); when(binlogEventHeader.getEventType()).thenReturn(MySQLBinlogEventType.WRITE_ROWS_EVENTv2.getValue()); MySQLBinlogRowsEventPacket actual = new MySQLBinlogRowsEventPacket(binlogEventHeader, payload); actual.readRows(tableMapEventPacket, payload); assertBinlogRowsEventV2BeforeRows(actual); assertTrue(actual.getColumnsPresentBitmap().isNullParameter(0)); assertNull(actual.getColumnsPresentBitmap2()); assertThat(actual.getRows().size(), is(1)); assertNull(actual.getRows().get(0)[0]); assertTrue(actual.getRows2().isEmpty()); }
@Test public void assertReadUpdateRowV2WithoutNullValue() { when(binlogEventHeader.getEventType()).thenReturn(MySQLBinlogEventType.UPDATE_ROWS_EVENTv2.getValue()); when(payload.readInt8()).thenReturn(Long.MAX_VALUE, Long.MIN_VALUE); MySQLBinlogRowsEventPacket actual = new MySQLBinlogRowsEventPacket(binlogEventHeader, payload); actual.readRows(tableMapEventPacket, payload); assertBinlogRowsEventV2BeforeRows(actual); assertFalse(actual.getColumnsPresentBitmap().isNullParameter(0)); assertFalse(actual.getColumnsPresentBitmap2().isNullParameter(0)); assertThat(actual.getRows().size(), is(1)); assertThat(actual.getRows().get(0)[0], is(Long.MAX_VALUE)); assertThat(actual.getRows2().size(), is(1)); assertThat(actual.getRows2().get(0)[0], is(Long.MIN_VALUE)); }