// Path: testing/src/main/java/io/airlift/testing/Closeables.java
// public static void closeAll(Closeable... closeables)
//         throws IOException
// {
//     try {
//         closeAll((AutoCloseable[]) closeables);
//     }
//     catch (Exception e) {
//         propagateIfPossible(e, IOException.class);
//         // Unreachable
//         throw new RuntimeException(e);
//     }
// }


import io.airlift.node.NodeConfig;
import io.airlift.node.NodeInfo;
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.URI;
import java.util.Optional;
import static io.airlift.testing.Closeables.closeAll;
import static org.testng.Assert.assertEquals;

        HttpServerConfig serverConfig = new HttpServerConfig();
        serverConfig.setHttpEnabled(true);
        serverConfig.setHttpPort(0);
        serverConfig.setHttpsEnabled(true);
        serverConfig.setAdminEnabled(true);

        HttpsConfig httpsConfig = new HttpsConfig()
                .setHttpsPort(0);

        HttpServerInfo httpServerInfo = new HttpServerInfo(serverConfig, Optional.ofNullable(httpsConfig), nodeInfo);

        int httpPort = httpServerInfo.getHttpUri().getPort();
        assertEquals(httpServerInfo.getHttpUri(), new URI("http://[::1]:" + httpPort));
        assertEquals(httpServerInfo.getHttpExternalUri(), new URI("http://[2001:db8::2:1]:" + httpPort));

        int httpsPort = httpServerInfo.getHttpsUri().getPort();
        assertEquals(httpServerInfo.getHttpsUri(), new URI("https://[::1]:" + httpsPort));
        assertEquals(httpServerInfo.getHttpsExternalUri(), new URI("https://[2001:db8::2:1]:" + httpsPort));

        int adminPort = httpServerInfo.getAdminUri().getPort();
        assertEquals(httpServerInfo.getAdminUri(), new URI("https://[::1]:" + adminPort));
        assertEquals(httpServerInfo.getAdminExternalUri(), new URI("https://[2001:db8::2:1]:" + adminPort));

        closeChannels(httpServerInfo);
    }

    static void closeChannels(HttpServerInfo info)
            throws IOException
    {
// Path: testing/src/main/java/io/airlift/testing/Closeables.java
// public static void closeAll(Closeable... closeables)
//         throws IOException
// {
//     try {
//         closeAll((AutoCloseable[]) closeables);
//     }
//     catch (Exception e) {
//         propagateIfPossible(e, IOException.class);
//         // Unreachable
//         throw new RuntimeException(e);
//     }
// }


// Path: http-server/src/test/java/io/airlift/http/server/TestHttpServerInfo.java
import io.airlift.node.NodeConfig;
import io.airlift.node.NodeInfo;
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.URI;
import java.util.Optional;
import static io.airlift.testing.Closeables.closeAll;
import static org.testng.Assert.assertEquals;


        HttpServerConfig serverConfig = new HttpServerConfig();
        serverConfig.setHttpEnabled(true);
        serverConfig.setHttpPort(0);
        serverConfig.setHttpsEnabled(true);
        serverConfig.setAdminEnabled(true);

        HttpsConfig httpsConfig = new HttpsConfig()
                .setHttpsPort(0);

        HttpServerInfo httpServerInfo = new HttpServerInfo(serverConfig, Optional.ofNullable(httpsConfig), nodeInfo);

        int httpPort = httpServerInfo.getHttpUri().getPort();
        assertEquals(httpServerInfo.getHttpUri(), new URI("http://[::1]:" + httpPort));
        assertEquals(httpServerInfo.getHttpExternalUri(), new URI("http://[2001:db8::2:1]:" + httpPort));

        int httpsPort = httpServerInfo.getHttpsUri().getPort();
        assertEquals(httpServerInfo.getHttpsUri(), new URI("https://[::1]:" + httpsPort));
        assertEquals(httpServerInfo.getHttpsExternalUri(), new URI("https://[2001:db8::2:1]:" + httpsPort));

        int adminPort = httpServerInfo.getAdminUri().getPort();
        assertEquals(httpServerInfo.getAdminUri(), new URI("https://[::1]:" + adminPort));
        assertEquals(httpServerInfo.getAdminExternalUri(), new URI("https://[2001:db8::2:1]:" + adminPort));

        closeChannels(httpServerInfo);
    }

    static void closeChannels(HttpServerInfo info)
            throws IOException
    {
        closeAll(info.getHttpChannel(), info.getHttpsChannel(), info.getAdminChannel());