/** * 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)); }
/** * Check that a server is alive by probing the {@link HttpServer#isAlive()} method * and the text of its toString() description * @param server server */ private void assertAlive(HttpServer server) { assertTrue("Server is not alive", server.isAlive()); assertToStringContains(server, HttpServer.STATE_DESCRIPTION_ALIVE); }
private void assertNotLive(HttpServer server) { assertTrue("Server should not be live", !server.isAlive()); assertToStringContains(server, HttpServer.STATE_DESCRIPTION_NOT_LIVE); }