### Question:
NetUtils { public static boolean isValidV4Address(InetAddress address) { if (address == null || address.isLoopbackAddress()) { return false; } String name = address.getHostAddress(); return (name != null && IP_PATTERN.matcher(name).matches() && !ANY_HOST_VALUE.equals(name) && !LOCAL_HOST_VALUE.equals(name)); } private  NetUtils(); static String getHost(); static boolean isValidV4Address(InetAddress address); static boolean ignoreNetworkInterface(NetworkInterface networkInterface);  }### Answer:
@Test public void testIsValidAddress() { assertFalse(NetUtils.isValidV4Address(null)); InetAddress address = mock(InetAddress.class); when(address.isLoopbackAddress()).thenReturn(true); assertFalse(NetUtils.isValidV4Address(address)); address = mock(InetAddress.class); when(address.getHostAddress()).thenReturn("localhost"); assertFalse(NetUtils.isValidV4Address(address)); address = mock(InetAddress.class); when(address.getHostAddress()).thenReturn("0.0.0.0"); assertFalse(NetUtils.isValidV4Address(address)); address = mock(InetAddress.class); when(address.getHostAddress()).thenReturn("127.0.0.1"); assertFalse(NetUtils.isValidV4Address(address)); address = mock(InetAddress.class); when(address.getHostAddress()).thenReturn("1.2.3.4"); assertTrue(NetUtils.isValidV4Address(address)); }