Search in sources :

Example 6 with WTemplate

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

the class WTemplateRenderer_Test method testVelocityTemplate.

@Test
public void testVelocityTemplate() throws IOException, SAXException, XpathException {
    WTemplate template = new WTemplate("templates/Test_Velocity.vm", TemplateRendererFactory.TemplateEngine.VELOCITY);
    setupTemplate(template);
    String output = toXHtml(template);
    assertOutput(output);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 7 with WTemplate

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

the class WTemplateRenderer_Test method testVelocityInlineTemplate.

@Test
public void testVelocityInlineTemplate() 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.VELOCITY);
    template.setInlineTemplate(inline.toString());
    String output = toXHtml(template);
    assertOutput(output);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 8 with WTemplate

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

the class WTemplateRenderer_Test method testPlainTextTemplate.

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

Example 9 with WTemplate

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

the class WTemplateRenderer_Test method testHandlebarsTemplate.

@Test
public void testHandlebarsTemplate() throws IOException, SAXException, XpathException {
    WTemplate template = new WTemplate("templates/Test_Handlebars.hbs", TemplateRendererFactory.TemplateEngine.HANDLEBARS);
    setupTemplate(template);
    String output = toXHtml(template);
    assertOutput(output);
}
Also used : WTemplate(com.github.bordertech.wcomponents.WTemplate) Test(org.junit.Test)

Example 10 with WTemplate

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

the class WTemplateRenderer_Test method testRendererCorrectlyConfigured.

@Test
public void testRendererCorrectlyConfigured() {
    WTemplate template = new WTemplate();
    Assert.assertTrue("Incorrect renderer supplied", getWebXmlRenderer(template) instanceof WTemplateRenderer);
}
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