}
public void testEncode(String name) throws Exception
{
byte[] raw = getRawMessage(name);
Buffer origBuffer = new ByteArrayBuffer(raw);
DnsMessage message = new DnsMessage();
message.decode(origBuffer);
origBuffer = new ByteArrayBuffer(raw);
Buffer buffer = new ByteArrayBuffer(512);
message.encode(buffer);
byte[] encoded = buffer.asArray();
//System.out.println(message);
DnsMessage message2 = new DnsMessage();
message2.decode(new ByteArrayBuffer(encoded));
assertArrayEquals(raw, encoded);
}