@Test
    void responseReceivedAfterCancellation() throws Exception {
        try (TestDnsServer dnsServer = new TestDnsServer(
                ImmutableMap.of(new DefaultDnsQuestion("foo.com.", DnsRecordType.A),
                                new DefaultDnsResponse(0).addRecord(DnsSection.ANSWER,
                                                                    newAddressRecord("foo.com.", "1.2.3.4")),
                                new DefaultDnsQuestion("bar.com.", DnsRecordType.A),
                                new DefaultDnsResponse(0).addRecord(DnsSection.ANSWER,
                                                                    newAddressRecord("bar.com.", "5.6.7.8"))),
                new ChannelOutboundHandlerAdapter() {
                    @Override
                    public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) {
                        ctx.executor().schedule(() -> ctx.writeAndFlush(msg, promise), 1, TimeUnit.SECONDS);
                    }
                })) {

            final EventLoop eventLoop = CommonPools.workerGroup().next();
            final DefaultDnsResolver resolver =
                    DefaultDnsResolver.of(
                            new DnsNameResolverBuilder(eventLoop)
                                    .channelType(TransportType.datagramChannelType(eventLoop))
                                    .queryTimeoutMillis(TimeUnit.HOURS.toMillis(1))
                                    .nameServerProvider(
                                            name -> DnsServerAddresses.sequential(dnsServer.addr()).stream())
                                    .build(),
                            DnsCache.ofDefault(), eventLoop, ImmutableList.of(), 1,
                            1, HostsFileEntriesResolver.DEFAULT);

            final DnsQuestionContext ctx = new DnsQuestionContext(eventLoop, 1);
            // resolver.resolveAll() should be executed by the event loop set to DnsNameResolver.
            eventLoop.submit(() -> {
                resolver.resolveAll(ctx,
                                    ImmutableList.of(new DefaultDnsQuestion("foo.com.", DnsRecordType.A),
                                                     new DefaultDnsQuestion("bar.com.", DnsRecordType.A)),
                                    "");
            }).get();

            // Cancel the queries immediately.
            ctx.whenCancelled().cancel(false);

            // Wait until the DNS server sends the response.
            Thread.sleep(2000);
            resolver.close();
        }
    }
This test does not check anything but makes the future returned by
{@link DefaultDnsResolver#resolve(List, String)}} is completed even before the DNS responses
are received. By doing so, we can make our leak detectors detect any leaks if we forgot to release
the DNS responses. See https://github.com/line/armeria/pull/2951 for more information.
core/src/test/java/com/linecorp/armeria/internal/client/dns/DefaultDnsResolverTest.java