HttpUtils { public static String findCookie(final Cookie[] cookies, final String key) { if (cookies == null || key == null || key.isEmpty()) { return null; } for (Cookie cookie: cookies) { if (cookie != null && cookie.getName().equals(key)) { return cookie.getValue(); } } return null; }  static void addSecurityHeaders(final HttpServletResponse resp); static void writeHttpResponse(final HttpServletResponse resp, final String response,
                                         final Integer responseCode, final String responseType, final String jsonContentType); static String findCookie(final Cookie[] cookies, final String key); static boolean validateSessionKey(final HttpSession session, final Map<String, Object[]> params, final Cookie[] cookies, final String sessionKeyString); static final Logger s_logger; static final String UTF_8; static final String RESPONSE_TYPE_JSON; static final String RESPONSE_TYPE_XML; static final String JSON_CONTENT_TYPE; static final String XML_CONTENT_TYPE; }
@Test public void findCookieTest() { Cookie[] cookies = null; String cookieName = null; assertNull(HttpUtils.findCookie(cookies, cookieName)); cookieName = ""; assertNull(HttpUtils.findCookie(cookies, cookieName)); cookieName = "daakuBandar"; cookies = new Cookie[]{new Cookie(cookieName, "someValue")}; assertNull(HttpUtils.findCookie(cookies, "aalasiLangur")); assertNotNull(HttpUtils.findCookie(cookies, cookieName)); }