### Question:
NetUtils { public static void verifyHostnames(String[] names) throws UnknownHostException { for (String name: names) { if (name == null) { throw new UnknownHostException("null hostname found"); } URI uri = null; try { uri = new URI(name); if (uri.getHost() == null) { uri = new URI("http: } } catch (URISyntaxException e) { uri = null; } if (uri == null || uri.getHost() == null) { throw new UnknownHostException(name + " is not a valid Inet address"); } } }  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 void addStaticResolution(String host, String resolvedName); static String getStaticResolution(String host); static List <String[]> getAllStaticResolutions(); static InetSocketAddress getConnectAddress(Server server); static InputStream getInputStream(Socket socket); static InputStream getInputStream(Socket socket, long timeout); static OutputStream getOutputStream(Socket socket); static OutputStream getOutputStream(Socket socket, long timeout); static void connect(Socket socket, 
                             SocketAddress endpoint, 
                             int timeout); static String normalizeHostName(String name); static List<String> normalizeHostNames(Collection<String> names); static void verifyHostnames(String[] names); static String getHostNameOfIP(String ip); static String getHostname(); static InetAddress getLocalInetAddress(String host);  }### Answer:
@Test(expected=UnknownHostException.class) public void testVerifyHostnamesException() throws UnknownHostException { String[] names = {"valid.host.com", "1.com", "invalid host here"}; NetUtils.verifyHostnames(names); }
@Test public void testVerifyHostnamesNoException() { String[] names = {"valid.host.com", "1.com"}; try { NetUtils.verifyHostnames(names); } catch (UnknownHostException e) { fail("NetUtils.verifyHostnames threw unexpected UnknownHostException"); } }