Code example for DatagramChannel

Methods: close, isConnected, isOpen, receive

0
     * Test method for 'DatagramChannelImpl.receive(ByteBuffer)' 
     * 
     * @throws Exception 
     */ 
    public void testReceive_UnconnectedClose() throws Exception { 
        assertFalse(this.channel1.isConnected());
        ByteBuffer dst = ByteBuffer.allocateDirect(CAPACITY_NORMAL);
        this.channel1.close();
        assertFalse(this.channel1.isOpen());
        try { 
            assertNull(this.channel1.receive(dst));
            fail("Should throw a ClosedChannelException here."); //$NON-NLS-1$
        } catch (ClosedChannelException e) {
            // OK. 
        } 
    } 
 
    /** 
     * Test method for 'DatagramChannelImpl.receive(ByteBuffer)' 
     * 
     * @throws Exception