Home / Function/ testUseComparator0() — netty Function Reference

testUseComparator0() — netty Function Reference

Architecture documentation for the testUseComparator0() function in DefaultAuthoritativeDnsServerCacheTest.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  99e36448_3865_c5bb_6120_589c93219afa["testUseComparator0()"]
  4a9246bd_af88_49ac_ddb5_b152cf30ca29["DefaultAuthoritativeDnsServerCacheTest"]
  99e36448_3865_c5bb_6120_589c93219afa -->|defined in| 4a9246bd_af88_49ac_ddb5_b152cf30ca29
  f435cf92_5536_b3ca_4a59_0e683c1cd836["testUseNoComparator()"]
  f435cf92_5536_b3ca_4a59_0e683c1cd836 -->|calls| 99e36448_3865_c5bb_6120_589c93219afa
  5945c937_b868_e053_e03d_b68b91559ba3["testUseComparator()"]
  5945c937_b868_e053_e03d_b68b91559ba3 -->|calls| 99e36448_3865_c5bb_6120_589c93219afa
  style 99e36448_3865_c5bb_6120_589c93219afa fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

resolver-dns/src/test/java/io/netty/resolver/dns/DefaultAuthoritativeDnsServerCacheTest.java lines 152–196

    private static void testUseComparator0(boolean noComparator) throws Exception {
        InetSocketAddress unresolved = InetSocketAddress.createUnresolved("ns1", 53);
        InetSocketAddress resolved = 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;

            if (noComparator) {
                cache = new DefaultAuthoritativeDnsServerCache(10000, 10000, null);
            }  else {
                cache = new DefaultAuthoritativeDnsServerCache(10000, 10000,
                                                               new Comparator<InetSocketAddress>() {
                    @Override
                    public int compare(InetSocketAddress o1, InetSocketAddress o2) {
                        if (o1.equals(o2)) {
                            return 0;
                        }
                        if (o1.isUnresolved()) {
                            return 1;
                        } else {
                            return -1;
                        }
                    }
                });
            }
            cache.cache("netty.io", unresolved, 100, loop);
            cache.cache("netty.io", resolved, 10000, loop);

            DnsServerAddressStream entries = cache.get("netty.io");
            assertEquals(2, entries.size());

            if (noComparator) {
                assertEquals(unresolved, entries.next());
                assertEquals(resolved, entries.next());
            } else {
                assertEquals(resolved, entries.next());
                assertEquals(unresolved, entries.next());
            }
        } finally {
            group.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does testUseComparator0() do?
testUseComparator0() is a function in the netty codebase, defined in resolver-dns/src/test/java/io/netty/resolver/dns/DefaultAuthoritativeDnsServerCacheTest.java.
Where is testUseComparator0() defined?
testUseComparator0() is defined in resolver-dns/src/test/java/io/netty/resolver/dns/DefaultAuthoritativeDnsServerCacheTest.java at line 152.
What calls testUseComparator0()?
testUseComparator0() is called by 2 function(s): testUseComparator, testUseNoComparator.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free