Code example for SocketPermission

Methods: getName, implies

0
        assertEquals("Wrong name1", "localhost", sp1.getName());
        SocketPermission sp2 = new SocketPermission(":80", "connect");
        assertEquals("Wrong name2", ":80", sp2.getName());
 
        // Regression for HARMONY-1462 
        SocketPermission sp3 = new SocketPermission("localhost:*", "listen");
        assertEquals("Wrong name3", "localhost:*", sp3.getName());
        // For all ports 
        SocketPermission spAllPorts = new SocketPermission("localhost:0-65535",
                "listen"); 
        assertTrue("Port range error", sp3.implies(spAllPorts));
        assertTrue("Port range error", spAllPorts.implies(sp3));
 
        SocketPermission sp4 = new SocketPermission("localhost", "listen");
        assertEquals("Wrong name4", "localhost", sp4.getName());
        assertTrue("Port range error", sp4.implies(spAllPorts));
        assertTrue("Port range error", spAllPorts.implies(sp4));
    } 
 
    /** 
     * @tests java.net.SocketPermission#equals(java.lang.Object)