final DummySession session = new DummySession();
session.setService(acceptor);
session.setLocalAddress(ADDRESS);
IoHandler handler = EasyMock.createStrictMock(IoHandler.class);
session.setHandler(handler);
final IoServiceListener listener = EasyMock.createStrictMock(IoServiceListener.class);
// Activate a service and create a session.
listener.serviceActivated(acceptor);
listener.sessionCreated(session);
handler.sessionCreated(session);
handler.sessionOpened(session);
EasyMock.replay(listener);
EasyMock.replay(handler);
support.add(listener);
support.fireServiceActivated();
support.fireSessionCreated(session);
EasyMock.verify(listener);
EasyMock.verify(handler);
// Deactivate a service and make sure the session is closed & destroyed.
EasyMock.reset(listener);
EasyMock.reset(handler);
listener.serviceDeactivated(acceptor);
EasyMock.expect(acceptor.isCloseOnDeactivation()).andReturn(true);
listener.sessionDestroyed(session);
handler.sessionClosed(session);
EasyMock.replay(listener);
EasyMock.replay(acceptor);
EasyMock.replay(handler);