Search in sources :

Example 6 with UnsafeCharArrayWriter

use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.

the class SecurityManagerTestCase method classAccess.

@Test
public void classAccess() throws Exception {
    JetTemplate template = engine.createTemplate("${new Date()}");
    UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
    template.render(new JetContext(), out);
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) Test(org.junit.Test)

Example 7 with UnsafeCharArrayWriter

use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.

the class SourceCodeTest method foreachArray.

@Test
public void foreachArray() {
    JetContext context = new JetContext();
    context.put("applications", new String[][] { { "1", "2", "3" }, { "a", "b", "c" } });
    StringBuilder sb = new StringBuilder();
    sb.append("#for(String[] apps: applications)\n");
    sb.append("  #for(String app: apps)\n");
    sb.append("    ${app}\n");
    sb.append("  #end\n");
    sb.append("#end\n");
    JetTemplate template = engine.createTemplate(sb.toString());
    UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
    template.render(context, out);
    Assert.assertEquals("    1\n    2\n    3\n    a\n    b\n    c\n", out.toString());
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) Test(org.junit.Test)

Example 8 with UnsafeCharArrayWriter

use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.

the class SourceCodeTest method plain.

@Test
public void plain() {
    JetTemplate template = engine.createTemplate("你好");
    UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
    template.render(new JetContext(), out);
    Assert.assertEquals("你好", out.toString());
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) Test(org.junit.Test)

Example 9 with UnsafeCharArrayWriter

use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.

the class SourceCodeTest method expression.

@Test
public void expression() {
    JetTemplate template = engine.createTemplate("${1+2*3}");
    UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
    template.render(new JetContext(), out);
    Assert.assertEquals("7", out.toString());
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) Test(org.junit.Test)

Example 10 with UnsafeCharArrayWriter

use of jetbrick.template.utils.UnsafeCharArrayWriter in project jetbrick-template-1x by subchen.

the class TagInForeachTest method tagInFor.

@Test
public void tagInFor() {
    String source = "#for(int i: iterator(1,9))#tag testTag()${i}#end#end";
    JetTemplate template = engine.createTemplate(source);
    UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
    JetContext context = new JetContext();
    template.render(context, out);
    Assert.assertEquals(out.toString(), "123456789");
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) Test(org.junit.Test)

Aggregations

UnsafeCharArrayWriter (jetbrick.template.utils.UnsafeCharArrayWriter)14 Test (org.junit.Test)13 AccessControlException (java.security.AccessControlException)3 Properties (java.util.Properties)1