Http { static String getCookieValue(HttpServletRequest hreq, String name) { javax.servlet.http.Cookie[] cookies = hreq.getCookies(); if (cookies == null) { return null; } for (javax.servlet.http.Cookie cookie : cookies) { if (name.equals(cookie.getName())) { return cookie.getValue(); } } return null; }  static Principal authenticate(HttpServletRequest request,
            AuthorityList authorities); static Principal authenticate(HttpServletRequest request,
            AuthorityList authorities, boolean optionalAuth); static String authenticatedUser(HttpServletRequest request,
            AuthorityList authorities); static String authorizedUser(HttpServletRequest request,
            AuthorityList authorities, Authorizer authorizer, String action,
            String resource, String otherDomain); static Principal authorize(Authorizer authorizer, Principal principal,
            String action, String resource, String otherDomain); static final String WWW_AUTHENTICATE; static final String INVALID_CRED_ATTR; static final String AUTH_CHALLENGES; static final String JAVAX_CERT_ATTR; }
@Test public void testGetCookieValue() { HttpServletRequest httpServletRequest = Mockito.mock(HttpServletRequest.class); Mockito.when(httpServletRequest.getCookies()).thenReturn(null); assertNull(Http.getCookieValue(httpServletRequest, "cookie1")); assertNull(Http.getCookieValue(httpServletRequest, "cookie2")); javax.servlet.http.Cookie[] cookies = new javax.servlet.http.Cookie[2]; cookies[0] = new javax.servlet.http.Cookie("cookie1", "value1"); cookies[1] = new javax.servlet.http.Cookie("cookie2", "value2"); Mockito.when(httpServletRequest.getCookies()).thenReturn(cookies); assertEquals(Http.getCookieValue(httpServletRequest, "cookie1"), "value1"); assertEquals(Http.getCookieValue(httpServletRequest, "cookie2"), "value2"); assertNull(Http.getCookieValue(httpServletRequest, "cookie3")); }