Search in sources :

Example 1 with AbstractSelectableChannel

use of java.nio.channels.spi.AbstractSelectableChannel in project robovm by robovm.

the class AbstractSelectableChannelTest method test_configureBlocking_Z_IllegalBlockingMode.

/**
     * @tests AbstractSelectableChannel#configureBlocking(boolean)
     */
public void test_configureBlocking_Z_IllegalBlockingMode() throws Exception {
    SocketChannel sc = SocketChannel.open();
    sc.configureBlocking(false);
    Selector acceptSelector = SelectorProvider.provider().openSelector();
    SelectionKey acceptKey = sc.register(acceptSelector, SelectionKey.OP_READ, null);
    assertEquals(sc.keyFor(acceptSelector), acceptKey);
    SelectableChannel getChannel = sc.configureBlocking(false);
    assertEquals(getChannel, sc);
    try {
        sc.configureBlocking(true);
        fail("Should throw IllegalBlockingModeException");
    } catch (IllegalBlockingModeException e) {
    // expected
    }
}
Also used : SocketChannel(java.nio.channels.SocketChannel) SelectionKey(java.nio.channels.SelectionKey) SelectableChannel(java.nio.channels.SelectableChannel) AbstractSelectableChannel(java.nio.channels.spi.AbstractSelectableChannel) IllegalBlockingModeException(java.nio.channels.IllegalBlockingModeException) Selector(java.nio.channels.Selector)

Aggregations

IllegalBlockingModeException (java.nio.channels.IllegalBlockingModeException)1 SelectableChannel (java.nio.channels.SelectableChannel)1 SelectionKey (java.nio.channels.SelectionKey)1 Selector (java.nio.channels.Selector)1 SocketChannel (java.nio.channels.SocketChannel)1 AbstractSelectableChannel (java.nio.channels.spi.AbstractSelectableChannel)1