OrderedHandlerExecutor implements IoHandlerExecutor { @Override public void execute(Event event) { try { int workerIndex = (int) (event.getSession().getId() % workers.length); LOG.debug("executing event {} in worker {}", event, workerIndex); workers[workerIndex].enqueue(event); } catch (InterruptedException e) { return; } } OrderedHandlerExecutor(int workerThreadCount, int queueSize); @Override void execute(Event event);  }
@Test public void execute_open_events() throws InterruptedException { executor = new OrderedHandlerExecutor(1, 1); IoSession session = mock(IoSession.class); when(session.getId()).thenReturn(12345L); Event evt = mock(Event.class); when(evt.getSession()).thenReturn(session); executor.execute(evt); verify(session).getId(); verify(evt).getSession(); Thread.sleep(200); verify(evt).visit(any(EventVisitor.class)); verifyNoMoreInteractions(evt, session); }