@Test public void testReadFrom() throws Exception { header = new TlvHeader(); header.setTlvType(1); header.setTlvLength(4); rtlv = new RouterTlv(header); channelBuffer = ChannelBuffers.copiedBuffer(packet); rtlv.readFrom(channelBuffer); assertThat(rtlv, is(notNullValue())); assertThat(rtlv, instanceOf(RouterTlv.class)); }
public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setRouterAddress(Ip4Address.valueOf(tempByteArray)); } catch (Exception e) { log.debug("Error::RouterTLV:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } }
RouterTlv extends TlvHeader implements TopLevelTlv { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setRouterAddress(Ip4Address.valueOf(tempByteArray)); } catch (Exception e) { log.debug("Error::RouterTLV:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } }
RouterTlv extends TlvHeader implements TopLevelTlv { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setRouterAddress(Ip4Address.valueOf(tempByteArray)); } catch (Exception e) { log.debug("Error::RouterTLV:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } RouterTlv(TlvHeader header); }
RouterTlv extends TlvHeader implements TopLevelTlv { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setRouterAddress(Ip4Address.valueOf(tempByteArray)); } catch (Exception e) { log.debug("Error::RouterTLV:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } RouterTlv(TlvHeader header); Ip4Address routerAddress(); void setRouterAddress(Ip4Address routerAddress); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getTlvBodyAsByteArray(); @Override String toString(); }
RouterTlv extends TlvHeader implements TopLevelTlv { public void readFrom(ChannelBuffer channelBuffer) throws Exception { try { byte[] tempByteArray = new byte[OspfUtil.FOUR_BYTES]; channelBuffer.readBytes(tempByteArray, 0, OspfUtil.FOUR_BYTES); this.setRouterAddress(Ip4Address.valueOf(tempByteArray)); } catch (Exception e) { log.debug("Error::RouterTLV:: {}", e.getMessage()); throw new OspfParseException(OspfErrorType.OSPF_MESSAGE_ERROR, OspfErrorType.BAD_MESSAGE); } } RouterTlv(TlvHeader header); Ip4Address routerAddress(); void setRouterAddress(Ip4Address routerAddress); void readFrom(ChannelBuffer channelBuffer); byte[] asBytes(); byte[] getTlvBodyAsByteArray(); @Override String toString();  }