NATTraversalTechniqueAttribute implements Attribute { @Override public void writeTo(final OutputStream out) throws IOException { final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final DataOutputStream dout = new DataOutputStream(bout); dout.writeInt(this.encoded); out.write(bout.toByteArray()); out.flush(); } NATTraversalTechniqueAttribute(final int encoded); int getEncoded(); @Override AttributeType getType(); @Override int getLength(); @Override void writeTo(final OutputStream out); @Override int hashCode(); @Override boolean equals(Object obj); static NATTraversalTechniqueAttribute fromBytes(final byte[] encoded, final AttributeHeader header);  }
@Test public void testWriteTo() throws IOException { final ByteArrayOutputStream baos = new ByteArrayOutputStream(); this.attr.writeTo(baos); assertTrue(Arrays.equals(this.getEncodedAsBytes(), baos.toByteArray())); }