@Test
  public void testStatus() throws InterruptedException {
    client = new Client(HOST, PORT, new MinecraftProtocol(STATUS), new TcpSessionFactory());
    Session session = client.getSession();

    ServerInfoHandlerTest handler = new ServerInfoHandlerTest();
    session.setFlag(SERVER_INFO_HANDLER_KEY, handler);
    session.addListener(new DisconnectListener());
    session.connect();

    assertTrue("Could not connect status session.", session.isConnected());
    handler.status.await(2, SECONDS);

    ServerStatusInfo info = handler.info;
    assertNotNull("Failed to get server info.", info);

    assertEquals(
        "Received incorrect description.", "Hello world!", info.getDescription().getFullText());
    assertEquals(
        "Received incorrect game version.", GAME_VERSION, info.getVersionInfo().getVersionName());
    assertEquals(
        "Received incorrect protocol version.",
        PROTOCOL_VERSION,
        info.getVersionInfo().getProtocolVersion());
    assertEquals("Received incorrect online players.", 0, info.getPlayerInfo().getOnlinePlayers());
    assertEquals("Received incorrect max players.", 100, info.getPlayerInfo().getMaxPlayers());
  }
  @Test
  public void testLogin() throws InterruptedException {
    Client client = new Client(HOST, PORT, new MinecraftProtocol("test"), new TcpSessionFactory());
    Session session = client.getSession();

    LoginListenerTest listener = new LoginListenerTest();
    session.addListener(listener);
    session.addListener(new DisconnectListener());
    session.connect();

    assertTrue("Could not connect login session.", session.isConnected());
    listener.login.await(4, SECONDS);

    ServerJoinGamePacket packet = listener.packet;
    assertNotNull("Failed to log in.", packet);

    assertEquals("Received incorrect entity ID.", 0, packet.getEntityId());
    assertFalse("Received incorrect hardcore flag.", packet.getHardcore());
    assertEquals("Received incorrect gamemode.", SURVIVAL, packet.getGameMode());
    assertEquals("Received incorrect dimension.", 0, packet.getDimension());
    assertEquals("Received incorrect difficulty.", PEACEFUL, packet.getDifficulty());
    assertEquals("Received incorrect max players.", 100, packet.getMaxPlayers());
    assertEquals("Received incorrect world type.", DEFAULT, packet.getWorldType());
    assertFalse("Received incorrect reduced debug info flag.", packet.getReducedDebugInfo());
  }