NetUtils { public static URI getCanonicalUri(URI uri, int defaultPort) { String host = uri.getHost(); if (host == null) { return uri; } String fqHost = canonicalizeHost(host); int port = uri.getPort(); if (host.equals(fqHost) && port != -1) { return uri; } try { uri = new URI(uri.getScheme(), uri.getUserInfo(), fqHost, (port == -1) ? defaultPort : port, uri.getPath(), uri.getQuery(), uri.getFragment()); } catch (URISyntaxException e) { throw new IllegalArgumentException(e); } return uri; }  static SocketFactory getSocketFactory(Configuration conf,
      Class<?> clazz); static SocketFactory getDefaultSocketFactory(Configuration conf); static SocketFactory getSocketFactoryFromProperty(
      Configuration conf, String propValue); static InetSocketAddress createSocketAddr(String target); static InetSocketAddress createSocketAddr(String target,
                                                   int defaultPort); static InetSocketAddress createSocketAddr(String target,
                                                   int defaultPort,
                                                   String configName); static InetSocketAddress createSocketAddr(String target,
                                                   int defaultPort,
                                                   String configName,
                                                   boolean useCacheIfPresent); static InetSocketAddress createSocketAddrForHost(String host, int port); static URI getCanonicalUri(URI uri, int defaultPort); static void addStaticResolution(String host, String resolvedName); static String getStaticResolution(String host); static List <String[]> getAllStaticResolutions(); static InetSocketAddress getConnectAddress(Server server); static InetSocketAddress getConnectAddress(InetSocketAddress addr); static SocketInputWrapper getInputStream(Socket socket); static SocketInputWrapper getInputStream(Socket socket, long timeout); static OutputStream getOutputStream(Socket socket); static OutputStream getOutputStream(Socket socket, long timeout); static void connect(Socket socket,
      SocketAddress address,
      int timeout); static void connect(Socket socket, 
                             SocketAddress endpoint,
                             SocketAddress localAddr,
                             int timeout); static String normalizeHostName(String name); static List<String> normalizeHostNames(Collection<String> names); static void verifyHostnames(String[] names); static String getHostNameOfIP(String ipPort); static String normalizeIP2HostName(String ipPort); static String getLocalHostname(); static String getHostname(); static String getHostPortString(InetSocketAddress addr); static InetAddress getLocalInetAddress(String host); static boolean isLocalAddress(InetAddress addr); static IOException wrapException(final String destHost,
                                          final int destPort,
                                          final String localHost,
                                          final int localPort,
                                          final IOException exception); static boolean isValidSubnet(String subnet); static List<InetAddress> getIPs(String subnet,
      boolean returnSubinterfaces); static int getFreeSocketPort(); static InetAddress bindToLocalAddress(InetAddress localAddr, boolean
      bindWildCardAddress); static final String UNKNOWN_HOST; static final String HADOOP_WIKI; }
@Test public void testCanonicalUriWithPort() { URI uri; uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: }
@Test public void testCanonicalUriWithDefaultPort() { URI uri; uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: }
@Test public void testCanonicalUriWithPath() { URI uri; uri = NetUtils.getCanonicalUri(URI.create("path"), 2); assertEquals("path", uri.toString()); uri = NetUtils.getCanonicalUri(URI.create("/path"), 2); assertEquals("/path", uri.toString()); }
@Test public void testCanonicalUriWithNoAuthority() { URI uri; uri = NetUtils.getCanonicalUri(URI.create("scheme:/"), 2); assertEquals("scheme:/", uri.toString()); uri = NetUtils.getCanonicalUri(URI.create("scheme:/path"), 2); assertEquals("scheme:/path", uri.toString()); uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: }
@Test public void testCanonicalUriWithNoHost() { URI uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: }
@Test public void testCanonicalUriWithNoPortNoDefaultPort() { URI uri = NetUtils.getCanonicalUri(URI.create("scheme: assertEquals("scheme: }