### Question:
IPv4ToolSet { public static boolean isValid(String ip) { long ipLong; if(ip==null) { return false; } try { ipLong = ip2long(ip); } catch (IPStringException ex) { return false; } return true; }  static String long2ip(long ipLong); static long mask_bits(int bits); static List<String> ipv4BlockToIpStrings(String blockString); static List<String> ipv4BlocksToIpStrings(List<String> ipBlocks); static IPv4Range ipv4BlockToRange(String blockString); static boolean isValid(String ip); static long ip2long(String ip); static boolean rejectUnwantedIps(String ip);  }### Answer:
@Test public void shouldValidate() { assertTrue(IPv4ToolSet.isValid("192.168.3.51")); assertTrue(IPv4ToolSet.isValid("127.0.0.1")); assertTrue(IPv4ToolSet.isValid("10.0.0.1")); assertTrue(IPv4ToolSet.isValid("172.17.10.255")); }
@Test public void shouldReject() { assertFalse(IPv4ToolSet.isValid("www.google.com")); assertFalse(IPv4ToolSet.isValid(null)); assertFalse(IPv4ToolSet.isValid("888.888.888.888")); assertFalse(IPv4ToolSet.isValid("")); assertFalse(IPv4ToolSet.isValid("...222")); assertFalse(IPv4ToolSet.isValid("-1.-1.-1.-1")); }