MySQLColumnDefinition41Packet implements MySQLPacket { @Override public void write(final MySQLPacketPayload payload) { payload.writeStringLenenc(CATALOG); payload.writeStringLenenc(schema); payload.writeStringLenenc(table); payload.writeStringLenenc(orgTable); payload.writeStringLenenc(name); payload.writeStringLenenc(orgName); payload.writeIntLenenc(NEXT_LENGTH); payload.writeInt2(characterSet); payload.writeInt4(columnLength); payload.writeInt1(columnType.getValue()); payload.writeInt2(flags); payload.writeInt1(decimals); payload.writeReserved(2); } MySQLColumnDefinition41Packet(final int sequenceId, final ResultSetMetaData resultSetMetaData, final int columnIndex);  MySQLColumnDefinition41Packet(final int sequenceId, final String schema, final String table, final String orgTable,
                                         final String name, final String orgName, final int columnLength, final MySQLColumnType columnType, final int decimals);  MySQLColumnDefinition41Packet(final int sequenceId, final int flags, final String schema, final String table, final String orgTable,
                                         final String name, final String orgName, final int columnLength, final MySQLColumnType columnType, final int decimals);  MySQLColumnDefinition41Packet(final MySQLPacketPayload payload); @Override void write(final MySQLPacketPayload payload);  }
@Test public void assertWriteWithResultSetMetaData() throws SQLException { when(resultSetMetaData.getSchemaName(1)).thenReturn("logic_db"); when(resultSetMetaData.getTableName(1)).thenReturn("tbl"); when(resultSetMetaData.getColumnLabel(1)).thenReturn("id"); when(resultSetMetaData.getColumnName(1)).thenReturn("id"); when(resultSetMetaData.getColumnDisplaySize(1)).thenReturn(10); when(resultSetMetaData.getColumnType(1)).thenReturn(Types.INTEGER); MySQLColumnDefinition41Packet actual = new MySQLColumnDefinition41Packet(1, resultSetMetaData, 1); assertThat(actual.getSequenceId(), is(1)); actual.write(payload); verifyWrite(); }
@Test public void assertWriteWithPayload() { when(payload.readInt1()).thenReturn(1, MySQLColumnType.MYSQL_TYPE_LONG.getValue(), 0); when(payload.readInt2()).thenReturn(MySQLServerInfo.CHARSET, 0); when(payload.readInt4()).thenReturn(10); when(payload.readIntLenenc()).thenReturn(0x0cL); when(payload.readStringLenenc()).thenReturn("def", "logic_db", "tbl", "tbl", "id", "id"); MySQLColumnDefinition41Packet actual = new MySQLColumnDefinition41Packet(payload); assertThat(actual.getSequenceId(), is(1)); actual.write(payload); verifyWrite(); }