### Question:
ViewExportedVariablesServlet extends HttpServlet { @Deprecated protected void showVariables( final String uri, final HttpServletResponse response, final String namespace, final boolean includeDoc, final boolean html, final String... vars ) throws IOException { final DisplayType displayType = html ? DisplayType.HTML : DisplayType.PLAINTEXT; showVariables(uri, response, namespace, includeDoc, displayType, vars); }  @Override void init(final ServletConfig servletConfig);  }### Answer:
@Test public void notFoundIsServedOnMissingNamespace() throws IOException { final String nonExistentNamespace = "a-nonexistent-namespace"; assertFalse(VarExporter.getNamespaces().contains(nonExistentNamespace)); final HttpServletResponse response = createMock(HttpServletResponse.class); response.sendError(HttpServletResponse.SC_NOT_FOUND, "The specified namespace was not found"); replay(response); setupServlet().showVariables("/private/v", response, nonExistentNamespace, "", true, ViewExportedVariablesServlet.DisplayType.HTML); verify(response); assertFalse(VarExporter.getNamespaces().contains(nonExistentNamespace)); }
@Test public void escapesHtmlInVariableNamesAndValues() throws IOException { final StringWriter bodyWriter = new StringWriter(); final HttpServletResponse response = createMock(HttpServletResponse.class); response.setContentType("text/html"); expectLastCall().once(); expect(response.getWriter()).andReturn(new PrintWriter(bodyWriter)).once(); replay(response); final String unescaped = "<img src='https: VarExporter.global().export( ManagedVariable .builder() .setName(unescaped) .setValue(unescaped) .build() ); setupServlet() .showVariables( "/private/v", response, "", "", false, ViewExportedVariablesServlet.DisplayType.HTML ); verify(response); assertFalse(bodyWriter.toString().contains(unescaped)); }