Code example for DatagramSocket

Methods: close, getBroadcast, setBroadcast

0
            //expected 
        } 
    } 
 
    public void test_getBroadcast() throws Exception { 
        DatagramSocket theSocket = new DatagramSocket();
        theSocket.setBroadcast(true);
        assertTrue("getBroadcast false when it should be true", theSocket
                .getBroadcast());
        theSocket.setBroadcast(false);
        assertFalse("getBroadcast true when it should be False", theSocket
                .getBroadcast());
        theSocket.close();
        try { 
            theSocket.getBroadcast();
            fail("SocketException was not thrown.");
        } catch(SocketException se) {
            //expected 
        } 
    }