use of org.minidns.source.DNSDataSource in project minidns by MiniDNS.
the class DNSClientTest method testReturnNullSource.
@Test
public void testReturnNullSource() throws IOException {
class NullSource extends DNSDataSource {
boolean queried = false;
@Override
public DNSMessage query(DNSMessage message, InetAddress address, int port) {
queried = true;
return null;
}
}
DNSClient client = new DNSClient(new LRUCache(0));
NullSource source = new NullSource();
client.setDataSource(source);
DNSMessage message = client.query("www.example.com", TYPE.A);
assertNull(message);
assertTrue(source.queried);
}
use of org.minidns.source.DNSDataSource in project minidns by MiniDNS.
the class AsyncApiTest method tcpAsyncApiTest.
public static void tcpAsyncApiTest() throws IOException {
DNSDataSource dataSource = new AsyncNetworkDataSource();
dataSource.setTimeout(60 * 60 * 1000);
dataSource.setUdpPayloadSize(256);
dataSource.setQueryMode(QueryMode.tcp);
DNSClient client = new DNSClient();
client.setDataSource(dataSource);
client.setAskForDnssec(true);
MiniDnsFuture<DNSMessage, IOException> future = client.queryAsync("google.com", Record.TYPE.AAAA);
DNSMessage response = future.getOrThrow();
assertEquals(RESPONSE_CODE.NO_ERROR, response.responseCode);
}
Aggregations