1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.james.jspf;
22
23 import org.apache.james.jspf.impl.DNSServiceXBillImpl;
24 import org.xbill.DNS.DClass;
25 import org.xbill.DNS.Lookup;
26 import org.xbill.DNS.Name;
27 import org.xbill.DNS.Record;
28 import org.xbill.DNS.SPFRecord;
29 import org.xbill.DNS.TXTRecord;
30 import org.xbill.DNS.TextParseException;
31 import org.xbill.DNS.Type;
32
33 import java.net.InetAddress;
34 import java.net.UnknownHostException;
35
36 import junit.framework.TestCase;
37
38 public class DNSServiceXBillImplTest extends TestCase {
39
40 protected void setUp() throws Exception {
41 super.setUp();
42 }
43
44 protected void tearDown() throws Exception {
45 super.tearDown();
46 }
47
48
49
50
51
52 public void testGetLocalDomainNames() throws UnknownHostException,
53 TextParseException {
54
55 System.out.println(InetAddress.getLocalHost());
56
57 System.out.println(InetAddress.getAllByName(null)[0]);
58
59 System.out.println(InetAddress.getLocalHost().getCanonicalHostName());
60
61 System.out.println(InetAddress.getAllByName(null)[0]
62 .getCanonicalHostName());
63 Record[] record = new Lookup(Name.root, Type.ANY).run();
64 if (record !=null) System.out.println(record[0]);
65 }
66
67 public void testMultipleStrings() throws Exception {
68 Record[] rr = new Record[] { TXTRecord.fromString(Name.fromString("test.local."), Type.TXT, DClass.IN, 0, "\"string \" \"concatenated\"", Name.fromString("local.")) };
69 assertEquals("string concatenated", DNSServiceXBillImpl.convertRecordsToList(rr).get(0));
70
71 rr = new Record[] { TXTRecord.fromString(Name.fromString("test.local."), Type.TXT, DClass.IN, 0, "string", Name.fromString("local.")) };
72 assertEquals("string", DNSServiceXBillImpl.convertRecordsToList(rr).get(0));
73
74 rr = new Record[] { TXTRecord.fromString(Name.fromString("test.local."), Type.TXT, DClass.IN, 0, "\"quoted string\"", Name.fromString("local.")) };
75 assertEquals("quoted string", DNSServiceXBillImpl.convertRecordsToList(rr).get(0));
76
77 rr = new Record[] { SPFRecord.fromString(Name.fromString("test.local."), Type.SPF, DClass.IN, 0, "\"quot\" \"ed st\" \"ring\"", Name.fromString("local.")) };
78 assertEquals("quoted string", DNSServiceXBillImpl.convertRecordsToList(rr).get(0));
79 }
80
81 }