Package com.alibaba.citrus.service.template

Examples of com.alibaba.citrus.service.template.TemplateContext


    public void render_error() throws Exception {
        getEngine("templateService", factory);
        assertProperty("default_encoding", "GBK");
        assertProperty("output_encoding", "UTF-8");

        TemplateContext ctx = new MappedTemplateContext();

        // 未找到模板
        try {
            templateService.getText("notExist.ftl", ctx);
            fail();
View Full Code Here


    @Test
    public void renderable() throws Exception {
        getEngine("templateService", factory);

        TemplateContext ctx = new MappedTemplateContext();
        ctx.put("object", new MyRenderable());

        String content = templateService.getText("test_renderable.ftl", ctx);
        assertThat(content, containsString("from render()"));
        assertThat(content, not(containsString("from toString()")));
    }
View Full Code Here

    @Test
    public void escape_url() throws Exception {
        getEngine("templateService", factory);

        TemplateContext ctx = new MappedTemplateContext();
        ctx.put("world", "中国");

        // configured value: UTF-8
        String content = templateService.getText("test_url_encode.ftl", ctx);
        assertThat(content, containsString("你好,%E4%B8%AD%E5%9B%BD"));
View Full Code Here

    @Test
    public void escape_html() throws Exception {
        getEngine("templateService", factory);

        TemplateContext ctx = new MappedTemplateContext();
        ctx.put("world", "<country name=\"中国\" />");

        // configured value: UTF-8
        String content = templateService.getText("test_html_escape.ftl", ctx);
        assertThat(content, containsString("你好,&lt;country name=&quot;中国&quot; /&gt;"));
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.template.TemplateContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.