IpHelper { public static long ipStringToLong(String ip) { InetAddress ipAddress = InetAddresses.forString(ip); if (!(ipAddress instanceof Inet4Address)) { throw new IllegalArgumentException(ip + " is not an IPv4 address"); } return IpHelper.ipToLong((Inet4Address) ipAddress); }  static long ipToLong(Inet4Address ip); static InetAddress longToIp(long ip); static String longToIpString(long ip); static long ipStringToLong(String ip); static byte[] longToNetworkByteOrderArray(long addr); static String calculateCidrFromIpV4Range(long ipLow, long ipHigh); static InetAddress calculateNetmaskFromCidr(String cidr); static String calculateNetmaskStringFromCidr(String cidr); static int safeLongToInt(long l);  }
@Test(dataProvider = "IpAddresses") public void testIpStringToLong(String ipAddress, long expectedLongValue) { long ip = IpHelper.ipStringToLong(ipAddress); assertThat(ip, is(expectedLongValue)); }