DefaultAuthoritativeDnsServerCacheTest Class — netty Architecture
Architecture documentation for the DefaultAuthoritativeDnsServerCacheTest class in DefaultAuthoritativeDnsServerCacheTest.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 4a9246bd_af88_49ac_ddb5_b152cf30ca29["DefaultAuthoritativeDnsServerCacheTest"] 3189b5f6_1567_6038_d229_d7a2ce723294["DefaultAuthoritativeDnsServerCacheTest.java"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|defined in| 3189b5f6_1567_6038_d229_d7a2ce723294 317bea78_5cbe_99cd_b512_036f12435822["testExpire()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 317bea78_5cbe_99cd_b512_036f12435822 2b038621_f351_0e35_7090_5bf186dc8458["testExpireWithDifferentTTLs()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 2b038621_f351_0e35_7090_5bf186dc8458 9454f74e_7cbf_f109_acae_d3717b8ff978["testExpireWithTTL0()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 9454f74e_7cbf_f109_acae_d3717b8ff978 955a5dce_bb16_2f67_057d_b9234caf7d5b["testAddMultipleDnsServerForSameHostname()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 955a5dce_bb16_2f67_057d_b9234caf7d5b 3faa78b8_e3ec_9987_96bc_0f0ab23a2d9f["testUnresolvedReplacedByResolved()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 3faa78b8_e3ec_9987_96bc_0f0ab23a2d9f f435cf92_5536_b3ca_4a59_0e683c1cd836["testUseNoComparator()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| f435cf92_5536_b3ca_4a59_0e683c1cd836 5945c937_b868_e053_e03d_b68b91559ba3["testUseComparator()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 5945c937_b868_e053_e03d_b68b91559ba3 99e36448_3865_c5bb_6120_589c93219afa["testUseComparator0()"] 4a9246bd_af88_49ac_ddb5_b152cf30ca29 -->|method| 99e36448_3865_c5bb_6120_589c93219afa
Relationship Graph
Source Code
resolver-dns/src/test/java/io/netty/resolver/dns/DefaultAuthoritativeDnsServerCacheTest.java lines 34–198
public class DefaultAuthoritativeDnsServerCacheTest {
@Test
public void testExpire() throws Throwable {
InetSocketAddress resolved1 = new InetSocketAddress(
InetAddress.getByAddress("ns1", new byte[] { 10, 0, 0, 1 }), 53);
InetSocketAddress resolved2 = new InetSocketAddress(
InetAddress.getByAddress("ns2", new byte[] { 10, 0, 0, 2 }), 53);
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
try {
EventLoop loop = group.next();
final DefaultAuthoritativeDnsServerCache cache = new DefaultAuthoritativeDnsServerCache();
cache.cache("netty.io", resolved1, 1, loop);
cache.cache("netty.io", resolved2, 10000, loop);
Throwable error = loop.schedule(new Callable<Throwable>() {
@Override
public Throwable call() {
try {
assertNull(cache.get("netty.io"));
return null;
} catch (Throwable cause) {
return cause;
}
}
}, 1, TimeUnit.SECONDS).get();
if (error != null) {
throw error;
}
} finally {
group.shutdownGracefully();
}
}
@Test
public void testExpireWithDifferentTTLs() {
testExpireWithTTL0(1);
testExpireWithTTL0(1000);
testExpireWithTTL0(1000000);
}
private static void testExpireWithTTL0(int days) {
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
try {
EventLoop loop = group.next();
final DefaultAuthoritativeDnsServerCache cache = new DefaultAuthoritativeDnsServerCache();
cache.cache("netty.io", new InetSocketAddress(NetUtil.LOCALHOST, 53), days, loop);
} finally {
group.shutdownGracefully();
}
}
@Test
public void testAddMultipleDnsServerForSameHostname() throws Exception {
InetSocketAddress resolved1 = new InetSocketAddress(
InetAddress.getByAddress("ns1", new byte[] { 10, 0, 0, 1 }), 53);
InetSocketAddress resolved2 = new InetSocketAddress(
InetAddress.getByAddress("ns2", new byte[] { 10, 0, 0, 2 }), 53);
EventLoopGroup group = new MultiThreadIoEventLoopGroup(1, LocalIoHandler.newFactory());
try {
EventLoop loop = group.next();
final DefaultAuthoritativeDnsServerCache cache = new DefaultAuthoritativeDnsServerCache();
cache.cache("netty.io", resolved1, 100, loop);
cache.cache("netty.io", resolved2, 10000, loop);
DnsServerAddressStream entries = cache.get("netty.io");
assertEquals(2, entries.size());
assertEquals(resolved1, entries.next());
assertEquals(resolved2, entries.next());
} finally {
group.shutdownGracefully();
}
}
@Test
public void testUnresolvedReplacedByResolved() throws Exception {
InetSocketAddress unresolved = InetSocketAddress.createUnresolved("ns1", 53);
InetSocketAddress resolved1 = new InetSocketAddress(
Defined In
Source
Frequently Asked Questions
What is the DefaultAuthoritativeDnsServerCacheTest class?
DefaultAuthoritativeDnsServerCacheTest is a class in the netty codebase, defined in resolver-dns/src/test/java/io/netty/resolver/dns/DefaultAuthoritativeDnsServerCacheTest.java.
Where is DefaultAuthoritativeDnsServerCacheTest defined?
DefaultAuthoritativeDnsServerCacheTest is defined in resolver-dns/src/test/java/io/netty/resolver/dns/DefaultAuthoritativeDnsServerCacheTest.java at line 34.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free