use of org.minidns.record.MX in project minidns by MiniDNS.
the class DNSMessageTest method testMXLookup.
@Test
public void testMXLookup() throws Exception {
DNSMessage m = getMessageFromResource("gmail-mx");
assertFalse(m.authoritativeAnswer);
List<Record<? extends Data>> answers = m.answerSection;
assertEquals(5, answers.size());
Map<Integer, DNSName> mxes = new TreeMap<>();
for (Record<? extends Data> r : answers) {
assertCsEquals("gmail.com", r.name);
Data d = r.getPayload();
assertTrue(d instanceof MX);
assertEquals(TYPE.MX, d.getType());
mxes.put(((MX) d).priority, ((MX) d).target);
}
assertCsEquals("gmail-smtp-in.l.google.com", mxes.get(5));
assertCsEquals("alt1.gmail-smtp-in.l.google.com", mxes.get(10));
assertCsEquals("alt2.gmail-smtp-in.l.google.com", mxes.get(20));
assertCsEquals("alt3.gmail-smtp-in.l.google.com", mxes.get(30));
assertCsEquals("alt4.gmail-smtp-in.l.google.com", mxes.get(40));
}