WebAppUtils { public static String getHtmlEscapedURIWithQueryString( HttpServletRequest request) { String urlEncodedQueryString = getURLEncodedQueryString(request, null); if (urlEncodedQueryString != null) { return HtmlQuoting.quoteHtmlChars( request.getRequestURI() + "?" + urlEncodedQueryString); } return HtmlQuoting.quoteHtmlChars(request.getRequestURI()); }  static void setRMWebAppPort(Configuration conf, int port); static void setRMWebAppHostnameAndPort(Configuration conf,
      String hostname, int port); static void setNMWebAppHostNameAndPort(Configuration conf,
      String hostName, int port); static R execOnActiveRM(Configuration conf,
      ThrowingBiFunction<String, T, R> func, T arg); static String getRMWebAppURLWithoutScheme(Configuration conf,
      boolean isHAEnabled, int haIdIndex); static String getRMWebAppURLWithScheme(Configuration conf,
      int haIdIndex); static String getRMWebAppURLWithScheme(Configuration conf); static String getRMWebAppURLWithoutScheme(Configuration conf); static String getRouterWebAppURLWithScheme(Configuration conf); static String getRouterWebAppURLWithoutScheme(Configuration conf); static List<String> getProxyHostsAndPortsForAmFilter(
      Configuration conf); static String getProxyHostAndPort(Configuration conf); static String getResolvedRemoteRMWebAppURLWithScheme(
      Configuration conf); static String getResolvedRMWebAppURLWithScheme(Configuration conf); static String getResolvedRemoteRMWebAppURLWithoutScheme(
      Configuration conf); static String getResolvedRMWebAppURLWithoutScheme(Configuration conf); static String getResolvedRMWebAppURLWithoutScheme(Configuration conf,
      Policy httpPolicy); static String getResolvedRemoteRMWebAppURLWithoutScheme(Configuration conf,
      Policy httpPolicy); static String getResolvedRemoteRMWebAppURLWithoutScheme(
      Configuration conf, Policy httpPolicy, String rmId); static String getResolvedAddress(InetSocketAddress address); static String getWebAppBindURL(
      Configuration conf,
      String hostProperty,
      String webAppURLWithoutScheme); static String getNMWebAppURLWithoutScheme(Configuration conf); static String getAHSWebAppURLWithoutScheme(Configuration conf); static String getTimelineReaderWebAppURLWithoutScheme(
      Configuration conf); static String getTimelineCollectorWebAppURLWithoutScheme(
      Configuration conf); static String getURLWithScheme(String schemePrefix, String url); static String getRunningLogURL(
      String nodeHttpAddress, String containerId, String user); static String getAggregatedLogURL(String serverHttpAddress,
      String allocatedNode, String containerId, String entity, String user); static String getHttpSchemePrefix(Configuration conf); static HttpServer2.Builder loadSslConfiguration(
      HttpServer2.Builder builder); static HttpServer2.Builder loadSslConfiguration(
      HttpServer2.Builder builder, Configuration conf); static ApplicationId parseApplicationId(RecordFactory recordFactory,
      String appId); static String getSupportedLogContentType(String format); static String getDefaultLogContentType(); static List<String> listSupportedLogContentType(); static List<NameValuePair> getURLEncodedQueryParam(
      HttpServletRequest request); static String removeQueryParams(HttpServletRequest httpRequest,
      String parameterName); static String getHtmlEscapedURIWithQueryString(
      HttpServletRequest request); static String appendQueryParams(HttpServletRequest request,
      String targetUri); static final String WEB_APP_TRUSTSTORE_PASSWORD_KEY; static final String WEB_APP_KEYSTORE_PASSWORD_KEY; static final String WEB_APP_KEY_PASSWORD_KEY; static final String HTTPS_PREFIX; static final String HTTP_PREFIX; }
@Test public void testGetHtmlEscapedURIWithQueryString() throws Exception { HttpServletRequest request = Mockito.mock(HttpServletRequest.class); String targetUri = "/test/path"; Mockito.when(request.getCharacterEncoding()).thenReturn(null); Mockito.when(request.getRequestURI()).thenReturn(targetUri); Map<String, String> paramResultMap = new HashMap<>(); paramResultMap.put("param1=x", targetUri + "?" + "param1=x"); paramResultMap .put("param1=x&param2=y", targetUri + "?" + "param1=x&amp;param2=y"); paramResultMap.put("param1=x&param2=y&param3=x+y", targetUri + "?" + "param1=x&amp;param2=y&amp;param3=x+y"); for (Map.Entry<String, String> entry : paramResultMap.entrySet()) { Mockito.when(request.getQueryString()).thenReturn(entry.getKey()); String uri = WebAppUtils.getHtmlEscapedURIWithQueryString(request); Assert.assertEquals(entry.getValue(), uri); } }