Package org.apache.velocity.app

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


        // sequence2
        context = new VelocityContext();
        w = new StringWriter();
        context.put("test",new ArrayList());

        ve2.evaluate( context, w, "test", "$test.get(0)");

        // check log on null set with both sequences
        // sequence 1
        context = new VelocityContext();
        w = new StringWriter();
View Full Code Here


        // sequence 2
        context = new VelocityContext();
        w = new StringWriter();
        logString = null;
        ve2.evaluate( context, w, "test", "#set($test1 = $test2)" );
        if ( logString != null)
        {
            fail( "log null set test 2");
        }
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,"testMacro","#macro(aa $blarg) #set(!! = bb) #end #aa('aa')");
            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

        VelocityEngine ve = new VelocityEngine();
        ve.init();
       
        Context context = new VelocityContext();       
        StringWriter writer = new StringWriter();
        ve.evaluate(context, writer, "test","abc #* test\r\ntest2*#\r\ndef");
        assertEquals("abc \r\ndef", writer.toString());
    }

    /**
     * Test single line comments
View Full Code Here

        VelocityEngine ve = new VelocityEngine();
        ve.init();
       
        Context context = new VelocityContext();       
        StringWriter writer = new StringWriter();
        ve.evaluate(context, writer, "test","123 ## test test\r\nabc");
        assertEquals("123 abc", writer.toString());       
   
        context = new VelocityContext();       
        writer = new StringWriter();
        ve.evaluate(context, writer, "test","123 \r\n## test test\r\nabc");
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.