Search in sources :

Example 1 with TXT

use of org.minidns.record.TXT in project minidns by MiniDNS.

the class DNSMessageTest method testTXTLookup.

@Test
public void testTXTLookup() throws Exception {
    DNSMessage m = getMessageFromResource("codinghorror-txt");
    HashSet<String> txtToBeFound = new HashSet<>();
    txtToBeFound.add("google-site-verification=2oV3cW79A6icpGf-JbLGY4rP4_omL4FOKTqRxb-Dyl4");
    txtToBeFound.add("keybase-site-verification=dKxf6T30x5EbNIUpeJcbWxUABJEnVWzQ3Z3hCumnk10");
    txtToBeFound.add("v=spf1 include:spf.mandrillapp.com ~all");
    List<Record<? extends Data>> answers = m.answerSection;
    for (Record<? extends Data> r : answers) {
        assertCsEquals("codinghorror.com", r.name);
        Data d = r.getPayload();
        assertTrue(d instanceof TXT);
        assertEquals(TYPE.TXT, d.getType());
        TXT txt = (TXT) d;
        assertTrue(txtToBeFound.contains(txt.getText()));
        txtToBeFound.remove(txt.getText());
    }
    assertEquals(txtToBeFound.size(), 0);
}
Also used : TXT(org.minidns.record.TXT) Record(org.minidns.record.Record) Data(org.minidns.record.Data) DNSMessage(org.minidns.dnsmessage.DNSMessage) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

HashSet (java.util.HashSet)1 Test (org.junit.Test)1 DNSMessage (org.minidns.dnsmessage.DNSMessage)1 Data (org.minidns.record.Data)1 Record (org.minidns.record.Record)1 TXT (org.minidns.record.TXT)1