Package org.apache.velocity.app

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


        context.put("a1","test");
        context.put("b1","test");
        Writer writer = new StringWriter();

        ve.evaluate(context,writer,"test","$a1 no problem");

        try {
            ve.evaluate(context,writer,"test","$a1 $c1 $a1.length() $a1.foobar()");
            fail ("Expected exception.");
        } catch (RuntimeException E) {}
View Full Code Here


        Writer writer = new StringWriter();

        ve.evaluate(context,writer,"test","$a1 no problem");

        try {
            ve.evaluate(context,writer,"test","$a1 $c1 $a1.length() $a1.foobar()");
            fail ("Expected exception.");
        } catch (RuntimeException E) {}


        log("Caught invalid references (global configuration).");
View Full Code Here

        // test normal reference
        context = new VelocityContext();
        writer = new StringWriter();
        context.put("bold","<b>");
        ve.evaluate(context,writer,"test","$bold test & test");
        assertEquals("&lt;b&gt; test & test",writer.toString());

        // test method reference
        context = new VelocityContext();
        writer = new StringWriter();
View Full Code Here

        // test method reference
        context = new VelocityContext();
        writer = new StringWriter();
        context.put("bold","<b>");
        ve.evaluate(context,writer,"test","$bold.substring(0,1)");
        assertEquals("&lt;",writer.toString());

        log("Escape matched all references (global configuration)");

    }
View Full Code Here

        Writer writer;

        // Html no JavaScript
        writer = new StringWriter();
        ve.evaluate(newEscapeContext(),writer,"test","$test1");
        assertEquals("Jimmy's &lt;b&gt;pizza&lt;/b&gt;",writer.toString());

        // comment out bad test -- requires latest commons-lang
        /**

 
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);

        log("PrintException handler successful.");
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

       
        Context context = new VelocityContext();
        context.put("lt","<");
        context.put("gt",">");
        StringWriter writer = new StringWriter();
        ve.evaluate(context, writer, "test","${lt}test${gt} #evaluate('${lt}test2${gt}')");
        assertEquals("&lt;test&gt; &lt;test2&gt;", writer.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.