IpAddressUtil { public static void validateFormat(String ip) throws IpAddressException { if (!ip.trim().matches(Settings.IP_REGEX)) { throw new IpAddressException("Ip format is invalid " + ip); } }  static void main(String[] args); static List<String> ipRange(String ipStr); static void validateFormat(String ip); static List<String> ipRange(String srcIp, String destIp); static Pattern IP_PATTERN; }
@Test public void testValidateFormat() throws IpAddressException { IpAddressUtil.validateFormat("192.168.0.1"); IpAddressUtil.validateFormat("192.168.01.255"); IpAddressUtil.validateFormat("192.168.01.255 "); exception.expect(IpAddressException.class); IpAddressUtil.validateFormat("192.168"); IpAddressUtil.validateFormat("192.168.1"); IpAddressUtil.validateFormat("192.168.01.256."); IpAddressUtil.validateFormat("192.168.01.256"); }