### Question:
IPUtils { public static boolean isValidIpv4String(String in) { IPv4 ip = new IPv4(in); try { ip.getBytes(); } catch (IPStringConversionException ex) { return false; } return true; }  static boolean isValidIpv6String(String in); static final boolean isValidIpv4Subnet(String in); static boolean isValidIpv6Subnet(String in); static boolean isValidIpv4String(String in); static byte[] invBytes(byte[] mask); static byte[] opBytes(byte[] a1, byte[] a2, ByteStreamOperation bop); static byte[] rollMask(int mask, int addrSize); static boolean bytesEqual(byte[] a1, byte[] a2);  }### Answer:
@Test public void testShouldRejectToManyOctetsIpv4() { assertFalse("expected rejection of 1.2.3.4.5 ", IPUtils.isValidIpv4String("1.2.3.4.5")); }
@Test public void testShouldRejectNotEnoughOctetsIpv4() { assertFalse("expected rejection of 1.2.3", IPUtils.isValidIpv4String("1.2.3")); }
@Test public void testShouldRejecteOctetOutofRangeIpv4() { assertFalse("expceted rejection of 1.2.3.256", IPUtils.isValidIpv4String("1.2.3.256")); }
@Test public void testShouldRejectNegativeOctetIpv4LOL() { assertFalse("Expected rejection of \"1.2.-1.4\"", IPUtils.isValidIpv4String("1.2.-1.4")); }