### Question:
IPUtil { public static int ipToInt(final String addr) { final String[] addressBytes = addr.split("\\."); if (addressBytes.length != 4) { throw new IllegalArgumentException("IPs have the format x.x.x.x"); } int ip = 0; for (int i = 0; i < 4; i++) { ip <<= 8; ip |= Integer.parseInt(addressBytes[i]); } return ip; } private  IPUtil(); static int ipToInt(final String addr); static String intToIp(int i); static long ipToLong(final String addr);  }### Answer:
@Test public void testIpToInt() { assertEquals(0, IPUtil.ipToInt("0.0.0.0")); assertEquals(255, IPUtil.ipToInt("0.0.0.255")); assertEquals((1 * 256) + 255, IPUtil.ipToInt("0.0.1.255")); assertEquals((25 * 256 * 256) + (1 * 256) + 255, IPUtil.ipToInt("0.25.1.255")); assertEquals((32 * 256 * 256 * 256) + (25 * 256 * 256) + (1 * 256) + 255, IPUtil.ipToInt("32.25.1.255")); assertEquals((255 * 256 * 256 * 256) + (255 * 256 * 256) + (255 * 256) + 255, IPUtil.ipToInt("255.255.255.255")); try { IPUtil.ipToInt("asdf"); fail("Should have thrown exception."); } catch (IllegalArgumentException ex) { } try { IPUtil.ipToInt("a.b.c.d"); fail("Should have thrown exception."); } catch (NumberFormatException ex) { } }