Debian Codegraph @

minidns-integration-test/src/main/java/org/minidns/integrationtest/HlaTest.java

raw
1 /*
2 * Copyright 2015-2020 the original author or authors
3 *
4 * This software is licensed under the Apache License, Version 2.0,
5 * the GNU Lesser General Public License version 2 or later ("LGPL")
6 * and the WTFPL.
7 * You may choose either license to govern your use of this software only
8 * upon the condition that you accept all of the terms of either
9 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
10 */
11 package org.minidns.integrationtest;
12
13 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
14 import static org.junit.jupiter.api.Assertions.assertEquals;
15 import static org.junit.jupiter.api.Assertions.assertFalse;
16 import static org.junit.jupiter.api.Assertions.assertTrue;
17
18 import java.io.IOException;
19 import java.util.Set;
20
21 import org.minidns.hla.ResolverApi;
22 import org.minidns.hla.ResolverResult;
23 import org.minidns.hla.SrvResolverResult;
24 import org.minidns.record.A;
25 import org.minidns.record.SRV;
26
27 public class HlaTest {
28
29 @IntegrationTest
30 public static void resolverTest() throws IOException {
31 ResolverResult<A> res = ResolverApi.INSTANCE.resolve("geekplace.eu", A.class);
32 assertEquals(true, res.wasSuccessful());
33 Set<A> answers = res.getAnswers();
34 assertEquals(1, answers.size());
35 assertArrayEquals(new A(5, 45, 100, 158).toByteArray(), answers.iterator().next().toByteArray());
36 }
37
38 @IntegrationTest
39 public static void idnSrvTest() throws IOException {
40 ResolverResult<SRV> res = ResolverApi.INSTANCE.resolve("_xmpp-client._tcp.im.plä.net", SRV.class);
41 Set<SRV> answers = res.getAnswers();
42 assertEquals(1, answers.size());
43
44 SRV srv = answers.iterator().next();
45
46 ResolverResult<A> aRes = ResolverApi.INSTANCE.resolve(srv.target, A.class);
47
48 assertTrue(aRes.wasSuccessful());
49 }
50
51 @IntegrationTest
52 public static void resolveSrvTest() throws IOException {
53 SrvResolverResult resolverResult = ResolverApi.INSTANCE.resolveSrv("_xmpp-client._tcp.jabber.org");
54 Set<SRV> answers = resolverResult.getAnswers();
55 assertFalse(answers.isEmpty());
56 }
57 }