### Question:
IPUtils { public static boolean isValidIpv4String(String in) { IPv4 ip = new IPv4(in); try { ip.getBytes(); } catch (IPStringConversionException ex) { return false; } return true; }  static Integer rndInt(int lo, int hi); static Double rndDouble(double lo, double hi); static Integer rndPosInt(int lo, int hi); static String rndIp(); static Object rndChoice(List oList); static Object rndChoice(Object[] oArray); static String rndperc(); static final int ubyte2int(byte in); static final byte int2ubyte(int in); static boolean isValidIpv6String(String in); static final boolean isValidIpv4Subnet(String in); static boolean isValidIpv6Subnet(String in); static boolean isValidIpv4String(String in); static int nibble2int(byte nibble); static final byte int2nibble(int in); static String int16bit2hex(int i16); static int hex16bit2int(String in); static boolean IP4RegEx(String ip); static boolean IP6RegEx(String ip); static boolean IPRegEx(String ip);  }### 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")); }