@Test(expected = Exception.class) public void testReadFrom1() throws Exception { tlvHeader = new TlvHeader(); tlvHeader.setTlvType(2); tlvHeader.setTlvLength(4); linkId = new LinkId(tlvHeader); channelBuffer = ChannelBuffers.copiedBuffer(packet1); linkId.readFrom(channelBuffer); assertThat(linkId, is(notNullValue())); }
public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::LinkId:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } }
LinkId extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::LinkId:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } }
LinkId extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::LinkId:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } LinkId(TlvHeader header); }
LinkId extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::LinkId:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } LinkId(TlvHeader header); void setLinkId(String linkType); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLinkSubTypeTlvBodyAsByteArray(); @Override String toString(); }
LinkId extends TlvHeader implements LinkSubType { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setLinkId(InetAddress.getByAddress(tempByteArray).getHostName()); } catch (Exception e) { log.debug("Error::LinkId:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } LinkId(TlvHeader header); void setLinkId(String linkType); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getLinkSubTypeTlvBodyAsByteArray(); @Override String toString();  }