nl.hsac.fitnesse.fixture.slim.HtmlFixture Maven / Gradle / Ivy
package nl.hsac.fitnesse.fixture.slim;
import nl.hsac.fitnesse.fixture.util.HtmlCleaner;
import org.apache.commons.text.StringEscapeUtils;
/**
* Fixture to facilitate working with HTML (fragments) obtained from an application being tested.
*/
public class HtmlFixture extends SlimFixture {
private final HtmlCleaner htmlCleaner = new HtmlCleaner();
/**
* Escapes the supplied html and places it inside a block, allowing it to be shown in a wiki page.
* @param html HTML content to show.
* @return HTML tags that can be shown in wiki page.
*/
public String htmlSource(String html) {
return getEnvironment().getHtml(html);
}
/**
* Unescapes supplied HTML content so it can be rendered inside a wiki page.
* @param htmlSource HTML code to display (possibly surrounded by tags).
* @return unescaped content, enclosed in so wiki will not escape it.
*/
public String html(String htmlSource) {
String cleanSource = htmlCleaner.cleanupPreFormatted(htmlSource);
return "" + StringEscapeUtils.unescapeHtml4(cleanSource) + "";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy