private void verifyIpAddressConversion(String ipString, int expectedJavaIpAddress, int expectedDatabaseIpAddress) throws UnknownHostException { // use Java to convert the string to an integer InetAddress address = InetAddress.getByName(ipString); // java inet4 address hashCode is the address object int javaIpAddress = address.hashCode(); // Verify the java integer value is as expected assertEquals(javaIpAddress, expectedJavaIpAddress); // Convert to database style and verify int databaseIpAddress = toDatabaseIpAddress(javaIpAddress); assertEquals(databaseIpAddress, expectedDatabaseIpAddress); // Finally, round trip back to java and verify assertEquals(fromDatabaseIpAddress(databaseIpAddress), javaIpAddress); } }
private void verifyIpAddressConversion(String ipString, int expectedJavaIpAddress, int expectedDatabaseIpAddress) throws UnknownHostException { // use Java to convert the string to an integer InetAddress address = InetAddress.getByName(ipString); // java inet4 address hashCode is the address object int javaIpAddress = address.hashCode(); // Verify the java integer value is as expected assertEquals(javaIpAddress, expectedJavaIpAddress); // Convert to database style and verify int databaseIpAddress = toDatabaseIpAddress(javaIpAddress); assertEquals(databaseIpAddress, expectedDatabaseIpAddress); // Finally, round trip back to java and verify assertEquals(fromDatabaseIpAddress(databaseIpAddress), javaIpAddress); } }