Code example for NetworkInterface

Methods: getName

0
        if (loopbackAddress == null) {
            return; 
        } 
 
        InetAddressMatchInterfaceCriteria criteria = new InetAddressMatchInterfaceCriteria("::1");
        assertEquals(loopbackAddress, criteria.isAcceptable(loopbackInterface, loopbackAddress));
        criteria = new InetAddressMatchInterfaceCriteria("::1%" + loopbackInterface.getName());
        if (loopbackAddress.getScopeId() > 0) {
            assertEquals(loopbackAddress, criteria.isAcceptable(loopbackInterface, loopbackAddress));
        } else { 
            InetAddress match = criteria.isAcceptable(loopbackInterface, loopbackAddress);
            if (!loopbackAddress.equals(match)) {
                // This match fails because ::1%lo becomes ::1%<number_of_lo> which isn't 0 
                assertNull(match + " is invalid", criteria.isAcceptable(loopbackInterface, loopbackAddress));
            } 
        } 
        criteria = new InetAddressMatchInterfaceCriteria("::1%" + loopbackAddress.getScopeId());
        assertEquals(loopbackAddress, criteria.isAcceptable(loopbackInterface, loopbackAddress));
        criteria = new InetAddressMatchInterfaceCriteria("::1%" + (loopbackAddress.getScopeId() + 1));
        assertNull(criteria.isAcceptable(loopbackInterface, loopbackAddress));
    } 
 
    @Test 
    public void testNonLoopback() throws Exception {