### Question:
PacketFactory { public static Attribute nextAttribute(ByteBuffer bfr) { if (!bfr.hasRemaining()) { return null; } bfr.mark(); bfr.get(); final byte len = bfr.get(); final int length = (len) & 0xFF; final byte[] attrData = new byte[length]; bfr.reset(); bfr.get(attrData); return AttributeFactory.createAttribute(attrData); } private  PacketFactory(); static Packet toPacket(byte[] octets); static Packet toPacket(ByteBuffer data); static Attribute nextAttribute(ByteBuffer bfr);  }### Answer:
@Test private void testUserNameAtt() { final String hex = "01 06 6e 65 6d 6f"; final ByteBuffer bfr = Utils.toBuffer(hex); final Attribute att = PacketFactory.nextAttribute(bfr); Assert.assertEquals(att.getClass().getSimpleName(), UserNameAttribute.class.getSimpleName(), "wrong attribute class instantiated"); final UserNameAttribute una = (UserNameAttribute) att; Assert.assertEquals(una.getName(), "nemo"); }