Search in sources :

Example 1 with WTemplate

use of com.github.bordertech.wcomponents.WTemplate in project wcomponents by BorderTech.

the class WTemplateRenderer_Test method testVelocityInvalidTemplate.

@Test(expected = SystemException.class)
public void testVelocityInvalidTemplate() {
    WTemplate template = new WTemplate("notexist.vm", TemplateRendererFactory.TemplateEngine.VELOCITY);
    toXHtml(template);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 2 with WTemplate

use of com.github.bordertech.wcomponents.WTemplate in project wcomponents by BorderTech.

the class WTemplateRenderer_Test method testHandlebarsInlineTemplate.

@Test
public void testHandlebarsInlineTemplate() throws IOException, SAXException, XpathException {
    StringBuffer inline = new StringBuffer();
    inline.append("id={{wc.id}}");
    inline.append("param={{mytest}}");
    inline.append("firstName={{wc.bean.firstName}}");
    inline.append("lastName={{wc.bean.lastName}}");
    inline.append("child={{child1}}");
    inline.append("not1=[{{notexist}}]");
    inline.append("not2=[{{wc.notexist}}]");
    WTemplate template = new WTemplate();
    setupTemplate(template);
    template.setEngineName(TemplateRendererFactory.TemplateEngine.HANDLEBARS);
    template.setInlineTemplate(inline.toString());
    String output = toXHtml(template);
    assertOutput(output);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 3 with WTemplate

use of com.github.bordertech.wcomponents.WTemplate in project wcomponents by BorderTech.

the class WTemplateRenderer_Test method testHandlebarsInvalidTemplate.

@Test(expected = SystemException.class)
public void testHandlebarsInvalidTemplate() {
    WTemplate template = new WTemplate("notexist.hbs", TemplateRendererFactory.TemplateEngine.HANDLEBARS);
    toXHtml(template);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 4 with WTemplate

use of com.github.bordertech.wcomponents.WTemplate in project wcomponents by BorderTech.

the class WTemplateRenderer_Test method testPlainTextInvalidTemplate.

@Test(expected = SystemException.class)
public void testPlainTextInvalidTemplate() {
    WTemplate template = new WTemplate("notexist.txt", TemplateRendererFactory.TemplateEngine.PLAINTEXT);
    toXHtml(template);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 5 with WTemplate

use of com.github.bordertech.wcomponents.WTemplate in project wcomponents by BorderTech.

the class WTemplateRenderer_Test method testPlainTextInlineTemplate.

@Test
public void testPlainTextInlineTemplate() throws IOException, SAXException, XpathException {
    String inline = "Hello from plain text.";
    WTemplate template = new WTemplate();
    setupTemplate(template);
    template.setEngineName(TemplateRendererFactory.TemplateEngine.PLAINTEXT);
    template.setInlineTemplate(inline);
    String output = toXHtml(template);
    Assert.assertTrue("Text not in output", output.contains(inline));
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Aggregations

WTemplate (com.github.bordertech.wcomponents.WTemplate)11 Test (org.junit.Test)10 TemplateRenderer (com.github.bordertech.wcomponents.template.TemplateRenderer)1 HashMap (java.util.HashMap)1