NetUtils { public static InetAddress getLocalAddress() { return getLocalAddress(null); }  static boolean isInvalidLocalHost(String host); static boolean isValidLocalHost(String host); static InetAddress getLocalAddress(); static InetAddress getLocalAddress(Map<String, Integer> destHostPorts); static boolean isValidAddress(String address); static boolean isValidAddress(InetAddress address); static String getHostName(SocketAddress socketAddress); static final String LOCALHOST; static final String ANYHOST; static final String MOTAN_IP_PREFIX; }
@Test public void testGetLocalAddress() { InetAddress address = NetUtils.getLocalAddress(); assertNotNull(address); assertTrue(NetUtils.isValidAddress(address)); try { if(NetUtils.isValidAddress(InetAddress.getLocalHost())){ assertEquals(InetAddress.getLocalHost(), address); } } catch (UnknownHostException e) { e.printStackTrace(); } }