ByteBuffer buf = ByteBuffer.allocate(100);
channel.read(buf);
Message message = new Message(buf.array());
Record answer = message.getSectionArray(Section.ANSWER)[0];
Assert.assertEquals(Type.A, answer.getType());
String addr = ((ARecord)answer).getAddress().getHostAddress();
Assert.assertEquals("1.2.3.4", addr);
query = Message.newQuery(
Record.newRecord(new Name("foo.example.com."), Type.AAAA, DClass.IN));
channel.write(ByteBuffer.wrap(query.toWire()));
Thread.sleep(10);
buf.clear();
channel.read(buf);
message = new Message(buf.array());
answer = message.getSectionArray(Section.ANSWER)[0];
Assert.assertEquals(Type.AAAA, answer.getType());
addr = ((AAAARecord)answer).getAddress().getHostAddress();
Assert.assertEquals("2002:53fe:a000:0:0:0:0:1", addr);
}