// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.jdisc.http.server.jetty; import jakarta.servlet.http.HttpServletResponse; import org.junit.jupiter.api.Test; import java.nio.charset.StandardCharsets; import static org.junit.jupiter.api.Assertions.assertEquals; /** * @author bjorncs */ public class ErrorResponseContentCreatorTest { @Test void response_content_matches_expected_string() { String expectedHtml = "\n" + "\n" + "\n" + "Error 200\n" + "\n" + "\n" + "

HTTP ERROR: 200

\n" + "

Problem accessing http://foo.bar. Reason:\n" + "

    My custom error message

\n" + "
\n" + "\n" + "\n"; ErrorResponseContentCreator c = new ErrorResponseContentCreator(); byte[] rawContent = c.createErrorContent( "http://foo.bar", HttpServletResponse.SC_OK, "My custom error message"); String actualHtml = new String(rawContent, StandardCharsets.ISO_8859_1); assertEquals(expectedHtml, actualHtml); } }