001/* 002 * Copyright 2015-2020 the original author or authors 003 * 004 * This software is licensed under the Apache License, Version 2.0, 005 * the GNU Lesser General Public License version 2 or later ("LGPL") 006 * and the WTFPL. 007 * You may choose either license to govern your use of this software only 008 * upon the condition that you accept all of the terms of either 009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL. 010 */ 011package org.minidns.integrationtest; 012 013import static org.junit.jupiter.api.Assertions.assertArrayEquals; 014import static org.junit.jupiter.api.Assertions.assertEquals; 015import static org.junit.jupiter.api.Assertions.assertFalse; 016import static org.junit.jupiter.api.Assertions.assertTrue; 017 018import java.io.IOException; 019import java.util.Set; 020 021import org.minidns.hla.ResolverApi; 022import org.minidns.hla.ResolverResult; 023import org.minidns.hla.SrvResolverResult; 024import org.minidns.record.A; 025import org.minidns.record.SRV; 026 027public class HlaTest { 028 029 @IntegrationTest 030 public static void resolverTest() throws IOException { 031 ResolverResult<A> res = ResolverApi.INSTANCE.resolve("geekplace.eu", A.class); 032 assertEquals(true, res.wasSuccessful()); 033 Set<A> answers = res.getAnswers(); 034 assertEquals(1, answers.size()); 035 assertArrayEquals(new A(5, 45, 100, 158).toByteArray(), answers.iterator().next().toByteArray()); 036 } 037 038 @IntegrationTest 039 public static void idnSrvTest() throws IOException { 040 ResolverResult<SRV> res = ResolverApi.INSTANCE.resolve("_xmpp-client._tcp.im.plä.net", SRV.class); 041 Set<SRV> answers = res.getAnswers(); 042 assertEquals(1, answers.size()); 043 044 SRV srv = answers.iterator().next(); 045 046 ResolverResult<A> aRes = ResolverApi.INSTANCE.resolve(srv.target, A.class); 047 048 assertTrue(aRes.wasSuccessful()); 049 } 050 051 @IntegrationTest 052 public static void resolveSrvTest() throws IOException { 053 SrvResolverResult resolverResult = ResolverApi.INSTANCE.resolveSrv("_xmpp-client._tcp.jabber.org"); 054 Set<SRV> answers = resolverResult.getAnswers(); 055 assertFalse(answers.isEmpty()); 056 } 057}