Package com.alibaba.citrus.service.velocity.impl

Examples of com.alibaba.citrus.service.velocity.impl.ConditionalEscapeHandler


    public void handlers_local() throws TemplateException, IOException {
        getEngine("with_local_handlers", factory);

        Iterator<?> i = velocityEngine.getConfiguration().getEventCartridge().getReferenceInsertionEventHandlers();
        assertThat(i.next(), instanceOf(RenderableHandler.class));
        ConditionalEscapeHandler h2 = (ConditionalEscapeHandler) i.next();
        assertFalse(i.hasNext());

        Context ctx = new VelocityContext();

        // no escape
        ctx.put("object", new MyRenderable());

        String content = velocityEngine.mergeTemplate("test_renderable.vm", ctx, null);
        assertThat(content, containsAll("from render()"));
        assertThat(content, not(containsString("escaped")));

        // escape
        ctx.put("escape", "true");

        content = velocityEngine.mergeTemplate("test_renderable.vm", ctx, null);
        assertThat(content, containsAll("escaped from render()"));

        // check handler
        ConditionalEscapeHandler new_h2 = ConditionalEscapeHandler.handlerHolder.get();
        ConditionalEscapeHandler.handlerHolder.remove();

        assertNotNull(new_h2);
        assertNotSame(h2, new_h2);
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.service.velocity.impl.ConditionalEscapeHandler

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.