@Test public void testSerialize() { LLDPOrganizationalTLV tlv = new LLDPOrganizationalTLV(); tlv.setLength((short) 13); tlv.setOUI(new byte[] {0x0, 0x26, (byte) 0xe1}); tlv.setSubType((byte) 12); tlv.setInfoString("ExtraInfo".getBytes(Charset.forName("UTF-8"))); assertThat(tlv.getType(), is((byte)127)); assertThat(tlv.getLength(), is((short)13)); assertThat(tlv.getOUI(), is(new byte[] {0x0, 0x26, (byte) 0xe1})); assertThat(tlv.getSubType(), is((byte)12)); assertThat(tlv.serialize(), is(expected)); }
@Override public byte[] serialize() { int valueLength = OUI_LENGTH + SUBTYPE_LENGTH + infoString.length; value = new byte[valueLength]; ByteBuffer bb = ByteBuffer.wrap(value); bb.put(oui); bb.put(subType); bb.put(infoString); return super.serialize(); }
LLDPOrganizationalTLV extends LLDPTLV { @Override public byte[] serialize() { int valueLength = OUI_LENGTH + SUBTYPE_LENGTH + infoString.length; value = new byte[valueLength]; ByteBuffer bb = ByteBuffer.wrap(value); bb.put(oui); bb.put(subType); bb.put(infoString); return super.serialize(); } }
LLDPOrganizationalTLV extends LLDPTLV { @Override public byte[] serialize() { int valueLength = OUI_LENGTH + SUBTYPE_LENGTH + infoString.length; value = new byte[valueLength]; ByteBuffer bb = ByteBuffer.wrap(value); bb.put(oui); bb.put(subType); bb.put(infoString); return super.serialize(); } LLDPOrganizationalTLV(); }
LLDPOrganizationalTLV extends LLDPTLV { @Override public byte[] serialize() { int valueLength = OUI_LENGTH + SUBTYPE_LENGTH + infoString.length; value = new byte[valueLength]; ByteBuffer bb = ByteBuffer.wrap(value); bb.put(oui); bb.put(subType); bb.put(infoString); return super.serialize(); } LLDPOrganizationalTLV(); LLDPOrganizationalTLV setOUI(byte[] oui); byte[] getOUI(); LLDPOrganizationalTLV setSubType(byte subType); byte getSubType(); LLDPOrganizationalTLV setInfoString(byte[] infoString); LLDPOrganizationalTLV setInfoString(String infoString); byte[] getInfoString(); @Override byte[] serialize(); @Override LLDPTLV deserialize(ByteBuffer bb); @Override int hashCode(); @Override boolean equals(Object obj); }
LLDPOrganizationalTLV extends LLDPTLV { @Override public byte[] serialize() { int valueLength = OUI_LENGTH + SUBTYPE_LENGTH + infoString.length; value = new byte[valueLength]; ByteBuffer bb = ByteBuffer.wrap(value); bb.put(oui); bb.put(subType); bb.put(infoString); return super.serialize(); } LLDPOrganizationalTLV(); LLDPOrganizationalTLV setOUI(byte[] oui); byte[] getOUI(); LLDPOrganizationalTLV setSubType(byte subType); byte getSubType(); LLDPOrganizationalTLV setInfoString(byte[] infoString); LLDPOrganizationalTLV setInfoString(String infoString); byte[] getInfoString(); @Override byte[] serialize(); @Override LLDPTLV deserialize(ByteBuffer bb); @Override int hashCode(); @Override boolean equals(Object obj); static final int OUI_LENGTH; static final int SUBTYPE_LENGTH; static final byte ORGANIZATIONAL_TLV_TYPE; static final int MAX_INFOSTRING_LENGTH; }