/** * Assert that the result of {@link HttpServer#toString()} contains the specific text * @param server server to examine * @param text text to search for */ private void assertToStringContains(HttpServer server, String text) { String description = server.toString(); assertTrue("Did not find \"" + text + "\" in \"" + description + "\"", description.contains(text)); }
/** * Test that an invalid webapp triggers an exception * @throws Throwable if something went wrong */ @Test public void testMissingServerResource() throws Throwable { try { HttpServer server = createServer("NoSuchWebapp"); //should not have got here. //close the server String serverDescription = server.toString(); stop(server); fail("Expected an exception, got " + serverDescription); } catch (FileNotFoundException expected) { log.debug("Expected exception " + expected, expected); } }