### Question:
ProxyServlet extends HttpServlet { protected static CharSequence encodeUriQuery(CharSequence in) { StringBuilder outBuf = null; for (int i = 0; i < in.length(); i++) { char c = in.charAt(i); boolean escape = true; if (c < 128) { if (asciiQueryChars.get(c)) { escape = false; } } else if (!Character.isISOControl(c) && !Character.isSpaceChar(c)) { escape = false; } if (!escape) { if (outBuf != null) { outBuf.append(c); } } else { if (outBuf == null) { outBuf = new StringBuilder(in.length() + 5 * 3); outBuf.append(in, 0, i); } try (Formatter formatter = new Formatter(outBuf)) { formatter.format("%%%02X", (int) c); } } } return outBuf != null ? outBuf : in; }  @Override String getServletInfo(); @Override void init(); @Override void destroy(); String getMDCUserIdValue(); static final String P_FORWARDEDFOR; static final String P_PRESERVEHOST; static final String P_PRESERVECOOKIES; static final String P_RESPONSE_URL_MATCHERS; static final String P_RESPONSE_CONTENT_REWRITE_PAIRS; static final String P_SKIP_RESPONSE_CONTENT_TYPES; static final String P_SKIP_RESPONSE_URL_MATCHERS; static final String P_APPEND_URL_PARAMS; static final String P_SET_ADDITIONAL_HEADERS; final Logger logger; }### Answer:
@Test public void encodeUriQuery() throws Exception { String in = "The Grateful Dead"; String expected = "The%20Grateful%20Dead"; StringBuilder actual = (StringBuilder) ProxyServlet.encodeUriQuery(in); assertEquals(expected, actual.toString()); }