View Test by JUnit

The advantage of mixer2 is that you can test web application view by junit .


<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<div id="foo">
here comes message

java class

public class Sample {

    public Html createHtml(String message) throws IOException {
        Mixer2Engine m2e = new Mixer2Engine();
        Html html = m2e.loadHtmlTemplate(new File("Sample.html"));
        html.getById("foo", Div.class).replaceInner(message);
        return html;


test class

public class SampleTest {

    public void executeHtmlTest() throws IOException {
        Sample sample = new Sample();
        Html html = sample.createHtml("aaa");
        assertEquals("aaa",html.getById("foo", Div.class).getContent().get(0));