EnvVars implements HttpFunction { @Override public void service(HttpRequest request, HttpResponse response) throws IOException { BufferedWriter writer = response.getWriter(); String foo = System.getenv("FOO"); if (foo == null) { foo = "Specified environment variable is not set."; } writer.write(foo); }  @Override void service(HttpRequest request, HttpResponse response);  }
@Test public void envTest() throws IOException { environmentVariables.set("FOO", "BAR"); new EnvVars().service(request, response); writerOut.flush(); assertThat(responseOut.toString()).contains("BAR"); }