Search in sources :

Example 1 with EventsHandler

use of org.zeromq.ZPoller.EventsHandler in project jeromq by zeromq.

the class TestZPoller method testUseNull.

@Test
public void testUseNull() throws IOException {
    ZPoller poller = new ZPoller(new ZStar.VerySimpleSelectorCreator().create());
    SelectableChannel channel = null;
    // ctx.createSocket(ZMQ.SUB);
    Socket socket = null;
    boolean rc = false;
    rc = poller.register(socket, ZPoller.IN);
    Assert.assertFalse("Registering a null socket was successful", rc);
    rc = poller.register(channel, ZPoller.OUT);
    Assert.assertFalse("Registering a null channel was successful", rc);
    int events = poller.poll(10);
    Assert.assertEquals("reading event on without sockets", 0, events);
    rc = poller.isReadable(socket);
    Assert.assertFalse("checking read event on a null socket was successful", rc);
    rc = poller.writable(socket);
    Assert.assertFalse("checking write event on a null socket was successful", rc);
    rc = poller.readable(channel);
    Assert.assertFalse("checking read event on a null channel was successful", rc);
    rc = poller.isWritable(channel);
    Assert.assertFalse("checking write event on a null channel was successful", rc);
    EventsHandler global = null;
    poller.setGlobalHandler(global);
    EventsHandler handler = null;
    rc = poller.register(socket, handler, ZPoller.ERR);
    Assert.assertFalse("Register with handler on a null socket was successful", rc);
    rc = poller.register(channel, ZPoller.ERR);
    Assert.assertFalse("Register with handler on a null channel was successful", rc);
    events = poller.poll(10);
    Assert.assertEquals("reading event with events handlers without sockets", 0, events);
    poller.close();
}
Also used : SelectableChannel(java.nio.channels.SelectableChannel) EventsHandler(org.zeromq.ZPoller.EventsHandler) Socket(org.zeromq.ZMQ.Socket) Test(org.junit.Test)

Aggregations

SelectableChannel (java.nio.channels.SelectableChannel)1 Test (org.junit.Test)1 Socket (org.zeromq.ZMQ.Socket)1 EventsHandler (org.zeromq.ZPoller.EventsHandler)1