Code example for DatagramSocket

Methods: close, getReuseAddress, setReuseAddress

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