Code example for ServerSocketChannel

Methods: acceptisOpenisBlocking

0
    /* 
     * Test method for 'java.nio.channels.ServerSocketChannel.accept()' 
     */ 
 
    public void testAccept_Block_NotYetBound() throws IOException { 
        assertTrue(this.serverChannel.isOpen());
        assertTrue(this.serverChannel.isBlocking());
        try { 
            this.serverChannel.accept();
            fail("Should throw NotYetBoundException");
        } catch (NotYetBoundException e) {
            // correct 
        } 
    } 
 
    public void testAccept_NonBlock_NotYetBound() throws IOException { 
        assertTrue(this.serverChannel.isOpen());
        this.serverChannel.configureBlocking(false);
        try { 
            this.serverChannel.accept();
            fail("Should throw NotYetBoundException");