String getJwtFromCookie(HttpServletRequest req) {
    String serializedJWT = null;
    Cookie[] cookies = req.getCookies();
    if (cookies != null) {
      for (Cookie cookie : cookies) {
        if (_cookieName != null && _cookieName.equals(cookie.getName())) {
          JWT_LOGGER.trace(_cookieName + " cookie has been found and is being processed");
          serializedJWT = cookie.getValue();
          break;
        }
      }
    }
    return serializedJWT;
  }
@Test
  public void testParseTokenFromCookie() {
    JwtAuthenticator authenticator = new JwtAuthenticator(TOKEN_PROVIDER, JWT_TOKEN);
    HttpServletRequest request = mock(HttpServletRequest.class);
    expect(request.getCookies()).andReturn(new Cookie[] {new Cookie(JWT_TOKEN, EXPECTED_TOKEN)});
    replay(request);
    String actualToken = authenticator.getJwtFromCookie(request);
    verify(request);
    assertEquals(EXPECTED_TOKEN, actualToken);
  }