NetworkUtils { public boolean sameNetworkInterface(@Nullable final NetworkInterface netIf1, @Nullable final NetworkInterface netIf2) { if (netIf1 == null || netIf2 == null) { return false; } return netIf1.getName().equals(netIf2.getName()); }  boolean isUsable(@Nullable final NetworkInterface netif); boolean hasIPv4Address(@Nullable final NetworkInterface netif); String getNetworkInterfaceInfo(@Nullable final NetworkInterface netif); String getIPv4Addresses(@Nullable final NetworkInterface netif); String getIPv4Addresses(@Nullable final NetworkInterfaceInfo networkInterfaceInfo); String getMacAddress(@Nullable final NetworkInterface netif); @Nullable NetworkInterface getUpdatedNetworkInterface(@Nullable final NetworkInterface origNetIf); boolean sameNetworkInterface(@Nullable final NetworkInterface netIf1,
                                        @Nullable final NetworkInterface netIf2); @Nullable NetworkInterface findFirstUsableNetworkInterface(); @Nullable Enumeration<NetworkInterface> getNetworkInterfaces(); List<NetworkInterfaceInfo> getUsableNetworkInterfaces(); @Nullable String getLocalHostName(); @Nullable NetworkInterface getNetworkInterfaceByName(final String name); static final int IPTOS_RELIABILITY; }
@Test public void testSameNetworkInterface() { assertFalse(networkUtils.sameNetworkInterface(null, null)); final Enumeration<NetworkInterface> networkInterfaces = networkUtils.getNetworkInterfaces(); if (networkInterfaces != null) { try { final NetworkInterface interface1 = networkInterfaces.nextElement(); final NetworkInterface interface2 = networkInterfaces.nextElement(); assertTrue(networkUtils.sameNetworkInterface(interface1, interface1)); assertTrue(networkUtils.sameNetworkInterface(interface2, interface2)); assertFalse(networkUtils.sameNetworkInterface(interface1, interface2)); assertFalse(networkUtils.sameNetworkInterface(interface1, null)); assertFalse(networkUtils.sameNetworkInterface(null, interface2)); } catch (final NoSuchElementException e) { System.err.println("Not enough network interfaces - aborting test"); } } else { System.err.println("No network interfaces - aborting test"); } }