### Question:
HttpServletRequestUtils { public static String extractHost(HttpServletRequest request) { Preconditions.checkNotNull(request); String host = request.getHeader("X-FORWARDED-HOST"); if (host == null) { host = request.getServerName(); } return host; } private  HttpServletRequestUtils(); static String extractClientIp(HttpServletRequest request); static String extractScheme(HttpServletRequest request); static String extractHost(HttpServletRequest request); static int extractServerPort(HttpServletRequest request); static String constructRequestBaseUrl(HttpServletRequest request); static String constructRequestUrl(HttpServletRequest request); static String constructRequestUrlWithParameters(HttpServletRequest request); static boolean isDefaultPort(String scheme, int port);  }### Answer:
@Test(expected=NullPointerException.class) public void extractHost_NULL() { HttpServletRequestUtils.extractHost(null); }
@Test public void extractHost_X_FORWARDED_HOST() { when(request.getHeader("X-FORWARDED-HOST")).thenReturn("saos.org.pl"); assertEquals("saos.org.pl", HttpServletRequestUtils.extractHost(request)); }
@Test public void extractHost_NO_X_FORWARDED_HOST() { when(request.getHeader("X-FORWARDED-HOST")).thenReturn(null); when(request.getServerName()).thenReturn("saos.org.pl"); assertEquals("saos.org.pl", HttpServletRequestUtils.extractHost(request)); }