Package org.apache.velocity.app

Examples of org.apache.velocity.app.VelocityEngine.evaluate()


        ve.evaluate(newEscapeContext(),writer,"test","$test1_js_test");
        assertEquals("Jimmy\\'s <b>pizza</b>",writer.toString());

        // JavaScript and HTML (method call)
        writer = new StringWriter();
        ve.evaluate(newEscapeContext(),writer,"test","$test1_js.substring(0,7)");
        assertEquals("Jimmy\\'s",writer.toString());
    }

    private Context newEscapeContext()
    {
View Full Code Here


        Writer writer = new StringWriter();

        try
        {
            ve.evaluate(context,writer,"test","   #set($abc)   ");
            fail("Should have thown a ParseErrorException");
        }
        catch (ParseErrorException e)
        {
            assertEquals("test",e.getTemplateName());
View Full Code Here

        Writer writer = new StringWriter();

        try
        {
            ve.evaluate(context,writer,"testMacro","#macro($blarg) foo #end");
            fail("Should have thown a ParseErrorException");
        }
        catch (ParseErrorException e)
        {
            assertEquals("testMacro",e.getTemplateName());
View Full Code Here

        Writer writer = new StringWriter();

        try
        {
            ve.evaluate(context,writer,"testMacroInvoke", "#macro(   foo $a) $a #end #foo(woogie)");
            fail("Should have thown a ParseErrorException");
        }
        catch (ParseErrorException e)
        {
            assertEquals("testMacroInvoke",e.getTemplateName());
View Full Code Here

       
        Writer writer = new StringWriter();
       
        try
        {
            ve.evaluate(context,writer,"testMacroInvoke", "#macro(foo $a) $a #end #foo('test1' 'test2')");    
            fail("Should have thown a ParseErrorException");
        }
        catch (ParseErrorException e)
        {
            assertEquals("testMacroInvoke",e.getTemplateName());
View Full Code Here

        Writer writer = new StringWriter();

        // will not throw an exception
        try
        {
            ve.evaluate(context,writer,"testMacroInvoke", "#macro(foo $a) $a #end #foo('test1' 'test2')");    
        }
        finally
        {
            if (writer != null)
            {
View Full Code Here

        assertTrue(writer.toString().indexOf("Index: 0, Size: 0") != -1);
        assertTrue(writer.toString().indexOf("ArrayList") == -1);

        // stack trace
        writer = new StringWriter();
        ve3.evaluate(context,writer,"test","$list.get(0)");
        assertTrue(writer.toString().indexOf("IndexOutOfBoundsException") != -1);
        assertTrue(writer.toString().indexOf("ArrayList") != -1);
    }

    public void testIncludeNotFound() throws Exception
View Full Code Here

        // let velocity parse and generate the result in buffer
        VelocityEngine engine = getVelocityEngine();
        if (log.isDebugEnabled()) {
            log.debug("Velocity is evaluating using velocity context: " + variableMap);
        }
        engine.evaluate(velocityContext, buffer, logTag, reader);

        // now lets output the results to the exchange
        Message out = exchange.getOut();
        out.setBody(buffer.toString());
        out.setHeader(VelocityConstants.VELOCITY_RESOURCE, resource);
View Full Code Here

        Context velocityContext = new VelocityContext(variableMap);

        // let velocity parse and generate the result in buffer
        VelocityEngine engine = getVelocityEngine();
        log.debug("Velocity is evaluating using velocity context: {}", variableMap);
        engine.evaluate(velocityContext, buffer, logTag, reader);

        // now lets output the results to the exchange
        Message out = exchange.getOut();
        out.setBody(buffer.toString());
        out.setHeaders(exchange.getIn().getHeaders());
View Full Code Here

        Context velocityContext = new VelocityContext(variableMap);

        // let velocity parse and generate the result in buffer
        VelocityEngine engine = getVelocityEngine();
        log.debug("Velocity is evaluating using velocity context: {}", variableMap);
        engine.evaluate(velocityContext, buffer, logTag, reader);

        // now lets output the results to the exchange
        Message out = exchange.getOut();
        out.setBody(buffer.toString());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.