### Question:
HttpUtil { public static String retrieveCookieValue( final HttpServletRequest request, final String cookieName ) { final Cookie[] cookies = request.getCookies(); if( cookies != null ) { for( final Cookie cookie : cookies ) { if( cookie.getName().equals( cookieName ) ) { String value = cookie.getValue(); if( value == null || value.length() == 0 ) { return null; } if( value.charAt( 0 ) == '"' && value.charAt( value.length() - 1 ) == '"' ) { value = value.substring( 1, value.length() - 1 ); } return value; } } } return null; } private  HttpUtil(); static String getRemoteAddress( final HttpServletRequest req ); static String retrieveCookieValue( final HttpServletRequest request, final String cookieName ); static String createETag( final String pageName, final Date lastModified ); static boolean checkFor304( final HttpServletRequest req, final String pageName, final Date lastModified ); static String guessValidURI( String uri ); static String safeGetQueryString( final HttpServletRequest request, final Charset contentEncoding ); static boolean isIPV4Address( final String name );  }### Answer:
@Test public void testRetrieveCookieValue() { final Cookie[] cookies = new Cookie[] { new Cookie( "cookie1", "value1" ), new Cookie( "cookie2", "\"value2\"" ), new Cookie( "cookie3", "" ), new Cookie( "cookie4", null ) }; final MockHttpServletRequest req = new MockHttpServletRequest( "/wiki", "/example" ); req.setCookies( cookies ); Assertions.assertEquals( "value1", HttpUtil.retrieveCookieValue( req, "cookie1" ) ); Assertions.assertEquals( "value2", HttpUtil.retrieveCookieValue( req, "cookie2" ) ); Assertions.assertNull( HttpUtil.retrieveCookieValue( req, "cookie3" ) ); Assertions.assertNull( HttpUtil.retrieveCookieValue( req, "cookie4" ) ); Assertions.assertNull( HttpUtil.retrieveCookieValue( req, "cookie5" ) ); }