From: <res...@us...> - 2010-10-13 12:38:04
|
Revision: 3780 http://bigdata.svn.sourceforge.net/bigdata/?rev=3780&view=rev Author: resendes Date: 2010-10-13 12:37:58 +0000 (Wed, 13 Oct 2010) Log Message: ----------- Added ipv4LoopbackAddress() method to NicUtilTest. Three tests were failing under Ubuntu wrt loopback addresses. - NicUtil path was returning InetAddress.getLocalHost() (e.g. 127.0.1.1) - The test was traversing NetworkInterface.getNetworkInterfaces() and finding the associated IPv4 addresses (e.g. 127.0.0.1) The test was imply doing a string compare, which failed because 127.0.0.1 != 127.0.1.1. Notes: - All 127.* IPv4 addresses are effectively the loopback address - Ubuntu /etc/hosts (which apparetnly getLocalHost() interrogates) had the following entries: 127.0.0.1 localhost 127.0.1.1 <hostname-of-this-machine> Modified Paths: -------------- branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/config/NicUtilTest.java Modified: branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/config/NicUtilTest.java =================================================================== --- branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/config/NicUtilTest.java 2010-10-12 21:13:14 UTC (rev 3779) +++ branches/bbb_cleanup/bigdata-core/src/test/java/com/bigdata/util/config/NicUtilTest.java 2010-10-13 12:37:58 UTC (rev 3780) @@ -995,10 +995,15 @@ String ip = NicUtil.getIpAddress( propName, (String)arg[0], ((Boolean)arg[1]).booleanValue()); - assertTrue(ipv4Exists(ip, true)); + assertTrue(ipv4LoopbackAddress(ip)); } } + private boolean ipv4LoopbackAddress(String ip) { + //The whole 127.* range is considered loopback + return ip.startsWith("127."); + } + @Test public void testGetIpAddressStringStringBoolean_unset_prop_valid_default() throws SocketException, IOException @@ -1035,7 +1040,7 @@ String propName = UUID.randomUUID().toString(); String invalidDefault = propName; String actual = NicUtil.getIpAddress(propName, invalidDefault, true); - assertTrue(ipv4Exists(actual, true)); + assertTrue(ipv4LoopbackAddress(actual)); } @Test @@ -1117,7 +1122,7 @@ String propName = null; String invalidDefault = null; String actual = NicUtil.getIpAddress(propName, invalidDefault, true); - assertTrue(ipv4Exists(actual, true)); + assertTrue(ipv4LoopbackAddress(actual)); } @Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |