UpdatePacketDecoder { private LocalPrefPathAttribute decodeLocalPrefPathAttribute(ByteBuf buffer) { LocalPrefPathAttribute attr = new LocalPrefPathAttribute(); if(buffer.readableBytes() != 4) throw new AttributeLengthException(); attr.setLocalPreference((int)buffer.readUnsignedInt()); return attr; }  BGPv4Packet decodeUpdatePacket(ByteBuf buffer); NotificationPacket decodeUpdateNotification(ByteBuf buffer, int errorSubcode);  }
@Test public void testDecodeLocalPrefPathAttribute() throws Exception { UpdatePacket packet; LocalPrefPathAttribute localPref; packet = safeDowncast(decoder.decodeUpdatePacket(buildProtocolPacket(new byte[] { (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x07, (byte)0x40, (byte)0x05, (byte)0x04, 0x00, 0x00, 0x00, 0x64, })), UpdatePacket.class); Assert.assertEquals(2, packet.getType()); Assert.assertEquals(0, packet.getWithdrawnRoutes().size()); Assert.assertEquals(1, packet.getPathAttributes().size()); Assert.assertEquals(0, packet.getNlris().size()); localPref = (LocalPrefPathAttribute)packet.getPathAttributes().remove(0); Assert.assertEquals(100, localPref.getLocalPreference()); }