The advantage of mixer2 is that you can test web application view by junit .
template
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <div id="foo"> here comes message </div> </body> </html>
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 {
@Test
public void executeHtmlTest() throws IOException {
Sample sample = new Sample();
Html html = sample.createHtml("aaa");
assertEquals("aaa",html.getById("foo", Div.class).getContent().get(0));
}
}