AuthUtil { public static String getHeader(HttpRequest request, String name) { String headerValue = ""; if (request != null && name != null) { List<String> header = null; HttpHeaders headers = request.getHttpHeaders(); for (String key : headers.getRequestHeaders().keySet()) { if (key.equalsIgnoreCase(name)) { header = headers.getRequestHeader(key); break; } } if (null != header && header.size() > 0) { headerValue = header.get(0); } } return headerValue; } private  AuthUtil(); static String getHeader(HttpRequest request, String name);  }
@Test public void testGetHeaderExists() throws Exception { MockHttpRequest req = MockHttpRequest.create("GET", "http: req.header("test_header", "value"); String result = AuthUtil.getHeader(req, "test_header"); assertEquals("value", result); }
@Test public void testGetHeaderDoesNotExist() throws Exception { MockHttpRequest req = MockHttpRequest.create("GET", "http: req.header("test_header", "value"); String result = AuthUtil.getHeader(req, "not_found"); assertEquals("", result); }