eventSource.removeListener(listener);
Assert.assertTrue(socketEvents.size() > 0);
ISocketEvent socketEvent = (ISocketEvent) socketEvents.remove(0);
Assert.assertTrue(socketEvent.toString(),
socketEvent instanceof ISocketCreatedEvent);
ISocketCreatedEvent createdEvent = (ISocketCreatedEvent) socketEvent;
ISocketEventSource source = createdEvent.getSource();
Assert.assertNotNull(source.toString(), source);
Object primary = canAdaptTo(source);
Socket createdSocket = createdEvent.getSocket();
Assert.assertNotNull(primary.toString(), createdSocket);
Assert.assertTrue(socketEvents.size() > 0);
socketEvent = (ISocketEvent) socketEvents.remove(0);
Assert.assertTrue(socketEvent.toString(),
socketEvent instanceof ISocketConnectedEvent);
ISocketConnectedEvent connectedEvent = (ISocketConnectedEvent) socketEvent;
Assert.assertSame(source, connectedEvent.getSource());
Assert.assertTrue(createdEvent.isSameFactorySocket(connectedEvent));
Assert.assertTrue(socketEvents.size() > 0);
socketEvent = (ISocketEvent) socketEvents.remove(0);
Assert.assertTrue(socketEvent.toString(),
socketEvent instanceof ISocketClosedEvent);
ISocketClosedEvent closedEvent = (ISocketClosedEvent) socketEvent;
Assert.assertSame(source, closedEvent.getSource());
Assert.assertTrue(createdEvent.isSameFactorySocket(closedEvent));
Assert.assertEquals(0, socketEvents.size());
}