MySQLHandshakeResponse41Packet implements MySQLPacket { @Override public void write(final MySQLPacketPayload payload) { payload.writeInt4(capabilityFlags); payload.writeInt4(maxPacketSize); payload.writeInt1(characterSet); payload.writeReserved(23); payload.writeStringNul(username); writeAuthResponse(payload); writeDatabase(payload); writeAuthPluginName(payload); } MySQLHandshakeResponse41Packet(final MySQLPacketPayload payload); void setDatabase(final String database); void setAuthPluginName(final MySQLAuthenticationMethod mysqlAuthenticationMethod); @Override void write(final MySQLPacketPayload payload);  }
@Test public void assertWriteWithClientPluginAuthLenencClientData() { MySQLHandshakeResponse41Packet actual = new MySQLHandshakeResponse41Packet(1, 100, MySQLServerInfo.CHARSET, "root"); actual.setCapabilityFlags(MySQLCapabilityFlag.CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA.getValue()); actual.setAuthResponse(new byte[] {1}); actual.write(payload); verify(payload).writeInt4(MySQLCapabilityFlag.CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA.getValue()); verify(payload).writeInt4(100); verify(payload).writeInt1(MySQLServerInfo.CHARSET); verify(payload).writeReserved(23); verify(payload).writeStringNul("root"); verify(payload).writeStringLenenc(new String(new byte[] {1})); }
@Test public void assertWriteWithClientSecureConnection() { MySQLHandshakeResponse41Packet actual = new MySQLHandshakeResponse41Packet(1, 100, MySQLServerInfo.CHARSET, "root"); actual.setCapabilityFlags(MySQLCapabilityFlag.CLIENT_SECURE_CONNECTION.getValue()); actual.setAuthResponse(new byte[] {1}); actual.write(payload); verify(payload).writeInt4(MySQLCapabilityFlag.CLIENT_SECURE_CONNECTION.getValue()); verify(payload).writeInt4(100); verify(payload).writeInt1(MySQLServerInfo.CHARSET); verify(payload).writeReserved(23); verify(payload).writeStringNul("root"); verify(payload).writeInt1(1); verify(payload).writeBytes(new byte[] {1}); }