@Test
public void sessionDisconnectValidation() throws InterruptedException {
// create necessary setup objects.
Game game = new SimpleGame(1, "Test");
Protocol dummyProtocol = new DummyProtocol();
GameRoomSessionBuilder sessionBuilder = new GameRoomSessionBuilder();
sessionBuilder.parentGame(game).gameRoomName("Zombie_ROOM_1")
.protocol(dummyProtocol);
CountDownLatch latch = new CountDownLatch(1);
AtomicLong counter = new AtomicLong(1l);
Session gameRoomSession = new TestGameRoom(sessionBuilder, counter,
latch);
GameRoom gameRoom = (GameRoom) gameRoomSession;
PlayerSession playerSession = gameRoom.createPlayerSession(null);
gameRoom.connectSession(playerSession);
playerSession.addHandler(new SessionHandlerLatchCounter(playerSession,
counter, latch));
// start test
gameRoom.disconnectSession(playerSession);
JetlangEventDispatcher gameDispatcher = (JetlangEventDispatcher) gameRoomSession
.getEventDispatcher();
assertNoListeners(gameDispatcher);
Event event = Events.event(null, Events.SESSION_MESSAGE);
playerSession.onEvent(event);
assertFalse(latch.await(500, TimeUnit.MILLISECONDS));
// Connect to another game room
sessionBuilder.gameRoomName("Zombie_ROOM_2");
Session gameRoomSession2 = new TestGameRoom(sessionBuilder, counter,
latch);
GameRoom gameRoom2 = (GameRoom) gameRoomSession2;
gameRoom2.connectSession(playerSession);