Code example for SocketPermission

0
    public void test_checkMulticastLjava_net_InetAddress() 
            throws UnknownHostException { 
        // enable all but one check 
        mutableSM.addPermission(new AllPermission());
        mutableSM.denyPermission(new SocketPermission(InetAddress.getByName(
                "localhost").getHostAddress(), "accept,connect"));
        try { 
            mutableSM.checkMulticast(InetAddress.getByName("localhost"));
            fail("This should throw a SecurityException.");
        } catch (SecurityException e) {
            // expected 
        } 
    } 
 
    /** 
     * @throws UnknownHostException 
     * @tests {@link java.lang.SecurityManager#checkMulticast(java.net.InetAddress,byte)} 
     */ 
    @SuppressWarnings( { "nls", "deprecation" }) 
    public void test_checkMulticastLjava_net_InetAddress_int() 
            throws UnknownHostException {