Search in sources :

Example 11 with UnsafeCharArrayWriter

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

the class IssueTestCase method test100.

@Test
public void test100() throws Exception {
    String source = "#set(Map<String, String> map = {'name':'jetbrick'})\n";
    source += "${map.name.length()}";
    JetTemplate template = engine.createTemplate(source);
    UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
    template.render(new JetContext(), out);
    Assert.assertEquals("8", out.toString());
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) Test(org.junit.Test)

Example 12 with UnsafeCharArrayWriter

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

the class SecurityManagerTestCase method methodAccess.

@Test
public void methodAccess() throws Exception {
    try {
        JetTemplate template = engine.createTemplate("${new Date().time}");
        UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
        template.render(new JetContext(), out);
    } catch (AccessControlException e) {
        return;
    }
    Assert.fail();
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) AccessControlException(java.security.AccessControlException) Test(org.junit.Test)

Example 13 with UnsafeCharArrayWriter

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

the class SecurityManagerTestCase method pkgAccess.

@Test
public void pkgAccess() throws Exception {
    try {
        JetTemplate template = engine.createTemplate("${new HashMap()}");
        UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
        template.render(new JetContext(), out);
    } catch (AccessControlException e) {
        return;
    }
    Assert.fail();
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) AccessControlException(java.security.AccessControlException) Test(org.junit.Test)

Example 14 with UnsafeCharArrayWriter

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

the class SecurityManagerTestCase method fieldAccess.

@Test
public void fieldAccess() throws Exception {
    try {
        JetTemplate template = engine.createTemplate("${@Integer.MAX_VALUE}");
        UnsafeCharArrayWriter out = new UnsafeCharArrayWriter();
        template.render(new JetContext(), out);
    } catch (AccessControlException e) {
        return;
    }
    Assert.fail();
}
Also used : UnsafeCharArrayWriter(jetbrick.template.utils.UnsafeCharArrayWriter) AccessControlException(java.security.AccessControlException) 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