Package org.apache.velocity.app

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


        // 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(true);
        out.setBody(buffer.toString());
        Map<String, Object> headers = (Map<String, Object>) velocityContext.get("headers");
View Full Code Here


         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

        }

        context = new VelocityContext();
        w = new StringWriter();
        context.put("test","abc");
        ve2.evaluate( context, w, "test", "$test" );
        if ( !w.toString().equals( "ABCabc" ))
        {
            fail( "Reference insertion test 2");
        }
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.