### Question:
NetUtil { public static long toLong(String address) { InetSocketAddress ad = toInetSocketAddress(address); String[] ip = ad.getAddress().getHostAddress().split("\\."); long r = 0; r = r | (Long.parseLong(ip[0]) << 40); r = r | (Long.parseLong(ip[1]) << 32); r = r | (Long.parseLong(ip[2]) << 24); r = r | (Long.parseLong(ip[3]) << 16); r = r | ad.getPort(); return r; }  static String toStringAddress(SocketAddress address); static String toIpAddress(SocketAddress address); static String toStringAddress(InetSocketAddress address); static InetSocketAddress toInetSocketAddress(String address); static long toLong(String address); static String getLocalIp(); static String getLocalHost(); static InetAddress getLocalAddress(); static void validAddress(InetSocketAddress address); static boolean isValidIp(String ip, boolean validLocalAndAny);  }### Answer:
@Test public void testToLong() { try { NetUtil.toLong("kdskdsfk"); } catch (Exception e) { assertThat(e).isInstanceOf(NullPointerException.class); } }
@Test public void testToLong1() { String[] split = "127.0.0.1".split("\\."); long r = 0; r = r | (Long.parseLong(split[0]) << 40); r = r | (Long.parseLong(split[1]) << 32); r = r | (Long.parseLong(split[2]) << 24); r = r | (Long.parseLong(split[3]) << 16); assertThat(NetUtil.toLong("127.0.0.1")).isEqualTo(r); }