PostgreSQLCommandCompletePacket implements PostgreSQLPacket { @Override public void write(final PostgreSQLPacketPayload payload) { payload.writeStringNul(sqlCommand + " " + rowCount); } PostgreSQLCommandCompletePacket();  PostgreSQLCommandCompletePacket(final String sqlCommand, final long rowCount); @Override void write(final PostgreSQLPacketPayload payload);  }
@Test public void assertReadWrite() { String sqlCommand = "SELECT * FROM t_order LIMIT 1"; long rowCount = 1; String expectedString = sqlCommand + " " + rowCount; int expectedStringLength = expectedString.length(); PostgreSQLPacketPayload payload = new PostgreSQLPacketPayload(ByteBufTestUtils.createByteBuf(expectedStringLength + 1)); PostgreSQLCommandCompletePacket packet = new PostgreSQLCommandCompletePacket(sqlCommand, rowCount); assertThat(packet.getMessageType(), is(PostgreSQLCommandPacketType.COMMAND_COMPLETE.getValue())); packet.write(payload); assertThat(payload.readStringNul(), is(expectedString)); }