Package org.apache.velocity.app

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


         this should parse fine -> uses ==
         */

        String template = "#if($a == $b) foo #end";

        ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);

        /*
         *  this should throw an exception
         */

 
View Full Code Here


        template = "#if($a = $b) foo #end";

        try
        {
            ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);
            fail("Could evaluate template with errors!");
        }
        catch(ParseErrorException pe)
        {
            // Do nothing
View Full Code Here

         * this should work
         */

        String template = "#macro(foo) foo #end";

        ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);

         /*
         *  this should throw an exception
         */

 
View Full Code Here

        template = "#macro($x) foo #end";

        try
        {
            ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);
            fail("Could evaluate macro with errors!");
        }
        catch(ParseErrorException pe)
        {
            // Do nothing
View Full Code Here

         * this should work
         */

        String template = "#macro(foo) foo #end";

        ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);

         /*
         *  this should work - spaces intentional
         */

 
View Full Code Here

         this should work - spaces intentional
         */

        template = "#foreach(  $i     in  $woogie   ) end #end";

        ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);

        /*
        *  this should bomb
        */

 
View Full Code Here

       template = "#macro(   foo $a) $a #end #foo(woogie)";

        try
        {
            ve.evaluate(new VelocityContext(), new StringWriter(), "foo", template);
            fail("Evaluation of macro with errors succeeded!");
        }
        catch(ParseErrorException pe)
        {
            // Do nothing
View Full Code Here

        ToStringCounter counter = new ToStringCounter();
        Map m = new HashMap();
        m.put("counter", counter);

        ve.evaluate(new VelocityContext(m), new StringWriter(), "foo", template);

        assertEquals(1, counter.timesCalled);
    }

    public static class ToStringCounter {
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

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.