commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/beanshell TestBeanShellEL.java
Date Wed, 13 Feb 2002 16:00:40 GMT
jstrachan    02/02/13 08:00:39

  Modified:    jelly    build.properties.sample build.xml
               jelly/src/java/org/apache/commons/jelly Context.java
                        Jelly.java
               jelly/src/java/org/apache/commons/jelly/expression/beanshell
                        BeanShellExpression.java
                        BeanShellExpressionFactory.java
               jelly/src/java/org/apache/commons/jelly/impl TagScript.java
               jelly/src/java/org/apache/commons/jelly/parser
                        XMLParser.java
               jelly/src/java/org/apache/commons/jelly/tags/core
                        ExprTag.java ForEachTag.java
               jelly/src/test/org/apache/commons/jelly TestAll.java
  Added:       jelly/src/java/org/apache/commons/jelly/expression/beanshell
                        JellyInterpreter.java package.html
               jelly/src/test/org/apache/commons/jelly TestCoreTags.java
                        testing123.jelly
               jelly/src/test/org/apache/commons/jelly/beanshell
                        TestBeanShellEL.java
  Log:
  Added support for BeanShell expressions in the core tags along with some unit tests. Unfortunately things are a bit of a kludge to support BeanShell - some changes are required to make it more optimal like (i) supporting a compile() of beanshell expressions and (ii) having to explicitly push in all variables in the context via Interpreter.set() rather than it being able to pull them from somewhere. Hopefully a neater EL could be Velocity.
  
  Revision  Changes    Path
  1.2       +10 -2     jakarta-commons-sandbox/jelly/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.properties.sample,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- build.properties.sample	11 Feb 2002 00:27:40 -0000	1.1
  +++ build.properties.sample	13 Feb 2002 16:00:39 -0000	1.2
  @@ -7,8 +7,16 @@
   # jakarta-commons-logging.jar
   logging.jar=../../jakarta-commons/logging/dist/commons-logging.jar
   
  +# you can change this property to point at a local copy of the java 2 platform api
  +jdk-doc-url=http://java.sun.com/products/jdk/1.3/docs/api
  +
  +# for the XML tags the following is required
  +#
   # dom4j.jar - go to http://dom4j.org to download
   dom4j.jar=/java/dom4j/dom4j.jar
   
  -# you can change this property to point at a local copy of the java 2 platform api
  -jdk-doc-url=http://java.sun.com/products/jdk/1.3/docs/api
  +# for the beanshell expression language the following is required
  +#
  +# beanshell.jar - go to http://www.beanshell.org
  +beanshell.jar=/java/beanshell/beanshell.jar
  +
  
  
  
  1.3       +24 -2     jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- build.xml	12 Feb 2002 21:34:33 -0000	1.2
  +++ build.xml	13 Feb 2002 16:00:39 -0000	1.3
  @@ -3,7 +3,7 @@
   
   <!--
           "Digester" component of the Jakarta Commons Subproject
  -        $Id: build.xml,v 1.2 2002/02/12 21:34:33 jstrachan Exp $
  +        $Id: build.xml,v 1.3 2002/02/13 16:00:39 jstrachan Exp $
   -->
   
   
  @@ -97,6 +97,7 @@
       <pathelement location="${jaxp.jaxp.jar}"/>
       <pathelement location="${jaxp.parser.jar}"/>
       <pathelement location="${dom4j.jar}"/>
  +    <pathelement location="${beanshell.jar}"/>
       <pathelement location="${commons-beanutils.jar}"/>
       <pathelement location="${commons-collections.jar}"/>
       <pathelement location="${commons-logging.jar}"/>
  @@ -116,6 +117,7 @@
       <pathelement location="${jaxp.jaxp.jar}"/>
       <pathelement location="${jaxp.parser.jar}"/>
       <pathelement location="${dom4j.jar}"/>
  +    <pathelement location="${beanshell.jar}"/>
       <pathelement location="${commons-beanutils.jar}"/>
       <pathelement location="${commons-collections.jar}"/>
       <pathelement location="${commons-logging.jar}"/>
  @@ -254,7 +256,7 @@
   
   
      <target name="test.xml" depends="compile.tests" 
  -      description="Runs sample XML tags">
  +      description="Runs the test of the XML tags">
       <java classname="org.apache.commons.jelly.TestXMLTags" fork="yes">
         <classpath refid="test.classpath"/>
         <sysproperty key="org.apache.commons.logging.log" value="org.apache.commons.logging.SimpleLog"/>
  @@ -262,6 +264,15 @@
       </java>
      </target>
   
  +   <target name="test.beanshell" depends="compile.tests" 
  +      description="Runs the BeanShell EL tests">
  +    <java classname="org.apache.commons.jelly.beanshell.TestBeanShellEL" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <sysproperty key="org.apache.commons.logging.log" value="org.apache.commons.logging.SimpleLog"/>
  +      <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
  +    </java>
  +   </target>
  +
   <!-- ========== Sample Program Targets ==================================== -->
   
      <target name="demo.hw" depends="compile" 
  @@ -277,6 +288,17 @@
       <java classname="org.apache.commons.jelly.Jelly" fork="yes">
         <classpath refid="test.classpath"/>
         <arg value="src/test/org/apache/commons/jelly/example2.jelly"/> 
  +    </java>
  +   </target>
  +
  +   <target name="demo.2" depends="compile" 
  +      description="Runs demo #2">
  +    <java classname="org.apache.commons.jelly.Jelly" fork="yes">
  +      <classpath refid="test.classpath"/>
  +      <arg value="src/test/org/apache/commons/jelly/testing123.jelly"/> 
  +      <arg value="one"/> 
  +      <arg value="two"/> 
  +      <arg value="three"/> 
       </java>
      </target>
   
  
  
  
  1.3       +14 -5     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Context.java	12 Feb 2002 21:34:33 -0000	1.2
  +++ Context.java	13 Feb 2002 16:00:39 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v 1.2 2002/02/12 21:34:33 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:33 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v 1.3 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,18 +57,19 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: Context.java,v 1.2 2002/02/12 21:34:33 jstrachan Exp $
  + * $Id: Context.java,v 1.3 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
   import java.io.Writer;
   import java.util.Hashtable;
  +import java.util.Iterator;
   import java.util.Map;
   
   /** <p><code>Context</code> represents the Jelly context.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class Context {
   
  @@ -96,4 +97,12 @@
               variables.put( name, value );
           }
       }    
  +    
  +    /** 
  +     * @return an Iterator over the current variable names in this
  +     * context 
  +     */
  +    public Iterator getVariableNames() {
  +        return variables.keySet().iterator();
  +    }
   }
  
  
  
  1.2       +18 -4     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java
  
  Index: Jelly.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Jelly.java	12 Feb 2002 21:34:33 -0000	1.1
  +++ Jelly.java	13 Feb 2002 16:00:39 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v 1.1 2002/02/12 21:34:33 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:33 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: Jelly.java,v 1.1 2002/02/12 21:34:33 jstrachan Exp $
  + * $Id: Jelly.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -74,7 +74,7 @@
   /** <p><code>Jelly</code> an application which runs a Jelly script.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class Jelly {
   
  @@ -88,10 +88,20 @@
               return;
           }
           String input = args[0];
  +        
  +/*
  +        // later we might wanna add some command line arguments 
  +        // checking stuff using commons-cli to specify the output file
  +        // and input file via command line arguments
  +  
           Writer writer = ( args.length > 1 ) 
               ? new FileWriter( args[1] ) 
               : new OutputStreamWriter( System.out );
           BufferedWriter output = new BufferedWriter( writer );
  +*/      
  +        Writer output = new BufferedWriter( 
  +            new OutputStreamWriter( System.out )
  +        );
           
           XMLParser parser = new XMLParser();
           Script script = parser.parse( input );
  @@ -102,7 +112,11 @@
               log.debug( "Compiled script: " + script );
           }
           
  -        Context context = new Context( System.getProperties() );        
  +        // add the system properties and the command line arguments
  +        //Context context = new Context( System.getProperties() );
  +        Context context = new Context();
  +        context.setVariable( "args", args );
  +        
           script.run( context, output );
           output.close();
       }    
  
  
  
  1.2       +27 -5     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpression.java
  
  Index: BeanShellExpression.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpression.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanShellExpression.java	12 Feb 2002 21:34:34 -0000	1.1
  +++ BeanShellExpression.java	13 Feb 2002 16:00:39 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpression.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpression.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,30 +57,52 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: BeanShellExpression.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: BeanShellExpression.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly.expression.beanshell;
   
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.expression.ExpressionSupport;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
  +
   /** Represents a <a href="http://www.beanshell.org">beanshell</a> expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class BeanShellExpression extends ExpressionSupport {
   
  +    /** The Log to which logging calls will be made. */
  +    private static final Log log = LogSource.getInstance( BeanShellExpression.class );
  +
       /** The expression */
       private String text;
       
  -    public BeanShellExpression(String text) {
  +    /** The interpreter */
  +    private JellyInterpreter interpreter = new JellyInterpreter();
  +    
  +    public BeanShellExpression(String text, JellyInterpreter interpreter) {
           this.text = text;
  +        this.interpreter = interpreter;
       }
   
       // Expression interface
       //------------------------------------------------------------------------- 
       public Object evaluate(Context context) {
  -        return null;
  +        try {
  +            interpreter.setContext(context);
  +            if ( log.isDebugEnabled() ) {            
  +                log.debug( "Evaluating EL: " + text );
  +            }
  +            
  +            return interpreter.eval( text );
  +        }
  +        catch (Exception e) {
  +            log.warn( "Caught exception evaluating: " + text + ". Reason: " + e, e );
  +            return null;
  +        }
       }
   }
  
  
  
  1.2       +7 -4      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpressionFactory.java
  
  Index: BeanShellExpressionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpressionFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BeanShellExpressionFactory.java	12 Feb 2002 21:34:34 -0000	1.1
  +++ BeanShellExpressionFactory.java	13 Feb 2002 16:00:39 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpressionFactory.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/BeanShellExpressionFactory.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: BeanShellExpressionFactory.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: BeanShellExpressionFactory.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly.expression.beanshell;
   
  @@ -67,17 +67,20 @@
   /** Represents a factory of <a href="http://www.beanshell.org">beanshell</a> expressions
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class BeanShellExpressionFactory implements ExpressionFactory {
   
  +    /** The interpreter */
  +    private JellyInterpreter interpreter = new JellyInterpreter();
  +    
       // ExpressionFactory interface
       //------------------------------------------------------------------------- 
       public Expression createExpression(String text) throws Exception {
           int length = text.length();
           if ( length > 2 && text.charAt(0) == '{'  && text.charAt( length - 1 ) == '}' ) {
               text = text.substring( 1, length - 1 );
  -            return new BeanShellExpression(text);
  +            return new BeanShellExpression(text, interpreter);
           }
           return null;
       }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/JellyInterpreter.java
  
  Index: JellyInterpreter.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/JellyInterpreter.java,v 1.1 2002/02/13 16:00:39 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/13 16:00:39 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: JellyInterpreter.java,v 1.1 2002/02/13 16:00:39 jstrachan Exp $
   */
  package org.apache.commons.jelly.expression.beanshell;
  
  import bsh.EvalError;
  import bsh.Interpreter;
  
  import java.util.Iterator;
  
  import org.apache.commons.jelly.Context;
  
  /** Integrates BeanShell's interpreter with Jelly's Context
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class JellyInterpreter extends Interpreter {
  
      private Context context;
      
      public JellyInterpreter() {
      }
  
      public Context getContext() {
          return context;
      }
      
      public void setContext(Context context) throws EvalError {
          this.context = context;
          
          // now pass in all the variables
          for ( Iterator iter = context.getVariableNames(); iter.hasNext(); ) {
              String name = (String) iter.next();
              Object value = context.getVariable(name);
              set( name, value );
          }
      }
  
  /*
    
      // the following code doesn't work - it seems that
      // all variables must be passed into the Interpreter
      // via set() method
   
      public Object get(String name) throws EvalError {
          if ( context != null ) {
              Object answer = context.getVariable( name );
              if ( answer != null ) { 
                  return answer;
              }
          }
          return super.get( name );
      }
  */
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/beanshell/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Implementation of Expression and ExpressionFactory that uses <a href="http://www.beanshell.org">BeanShell</a>.
    </p>
  
  </body>
  </html>
  
  
  1.3       +16 -7     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java
  
  Index: TagScript.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TagScript.java	12 Feb 2002 21:34:34 -0000	1.2
  +++ TagScript.java	13 Feb 2002 16:00:39 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v 1.3 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: TagScript.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: TagScript.java,v 1.3 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly.impl;
   
  @@ -85,7 +85,7 @@
   /** <p><code>TagScript</code> evaluates a custom tag.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class TagScript implements Script {
       
  @@ -185,12 +185,21 @@
           for ( int i = 0, size = expressions.length; i < size; i++ ) {
               Expression expression = expressions[i];
               Method method =  methods[i];
  +            Class type = types[i];
               
  -            Object value = expression.evaluate( context );
  +            // some types are Expression objects so let the tag
  +            // evaluate them
  +            Object value = null;
  +            if ( type.isAssignableFrom( Expression.class ) ) {
  +                value = expression;
  +            }
  +            else {
  +                value = expression.evaluate( context );
  +            }
               
               // convert value to correct type
               if ( value != null ) {
  -                value = convertType( value, types[i] );
  +                value = convertType( value, type );
               }
               
               Object[] arguments = { value };
  
  
  
  1.4       +25 -16    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XMLParser.java	12 Feb 2002 21:34:34 -0000	1.3
  +++ XMLParser.java	13 Feb 2002 16:00:39 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v 1.3 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v 1.4 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: XMLParser.java,v 1.3 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: XMLParser.java,v 1.4 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly.parser;
   
  @@ -115,7 +115,7 @@
    * The SAXParser and XMLReader portions of this code come from Digester.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class XMLParser extends DefaultHandler {
       
  @@ -588,27 +588,27 @@
        * @exception SAXException if a parsing error is to be reported
        */
       public void startElement(
  -    String namespaceURI, String localName, String qName, Attributes list
  +        String namespaceURI, String localName, String qName, Attributes list
       ) throws SAXException {
           
           // if this is a tag then create a script to run it
           // otherwise pass the text to the current body
           tagScript = createTag( namespaceURI, localName, list );
           tagScriptStack.add( tagScript );
  -        
  +
           if ( tagScript != null ) {            
               // set parent relationship...
               Tag tag = tagScript.getTag();
               tag.setParent( parentTag );
               parentTag = tag;
  -            
  +
               if ( textBuffer.length() > 0 ) {
                   script.addScript( new TextScript( textBuffer.toString() ) );
                   textBuffer.setLength(0);
               }
  -            
  +
               script.addScript( tagScript );
  -            
  +
               // start a new body
               scriptStack.push( script );
               script = new ScriptBlock();
  @@ -616,7 +616,7 @@
           }
           else {
               // XXXX: might wanna handle empty elements later...
  -            
  +
               textBuffer.append( "<" );
               textBuffer.append( qName );
               int size = list.getLength();
  @@ -717,8 +717,9 @@
        *
        * @exception SAXException if a parsing error is to be reported
        */
  -    public void ignorableWhitespace(char buffer[], int start, int len)
  -    throws SAXException {
  +    public void ignorableWhitespace(
  +        char buffer[], int start, int len
  +    ) throws SAXException {
           ;	// No processing required
           
       }
  @@ -911,7 +912,7 @@
               // use the URI to load a taglib
               TagLibrary taglib = (TagLibrary) taglibs.get( namespaceURI );
               if ( taglib == null ) {
  -                if ( namespaceURI.startsWith( "jelly:" ) ) {
  +                if ( namespaceURI != null && namespaceURI.startsWith( "jelly:" ) ) {
                       String uri = namespaceURI.substring(6);
                       // try to find the class on the claspath
                       try {
  @@ -946,6 +947,10 @@
               log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e );
               throw createSAXException(e);
           }
  +        catch (Throwable e) {
  +            log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e );
  +            return null;
  +        }
       }
       
       protected Expression createExpression( String tagName, String attributeName, String attributeValue ) throws Exception {
  @@ -968,19 +973,23 @@
        * @return the new exception
        */
       protected SAXException createSAXException(String message, Exception e) {
  +        log.warn( "Underlying exception: " + e );
  +        e.printStackTrace();
           if (locator != null) {
               String error = "Error at (" + locator.getLineNumber() + ", "
               + locator.getColumnNumber() + ": " + message;
               if (e != null) {
                   return new SAXParseException(error, locator, e);
  -            } else {
  +            } 
  +            else {
                   return new SAXParseException(error, locator);
               }
           }
           log.error("No Locator!");
           if (e != null) {
               return new SAXException(message, e);
  -        } else {
  +        } 
  +        else {
               return new SAXException(message);
           }
       }
  
  
  
  1.2       +10 -4     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java
  
  Index: ExprTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExprTag.java	12 Feb 2002 21:34:34 -0000	1.1
  +++ ExprTag.java	13 Feb 2002 16:00:39 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ExprTag.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: ExprTag.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -69,13 +69,19 @@
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.expression.Expression;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
   /** A tag which evaluates an expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class ExprTag extends TagSupport {
   
  +    /** The Log to which logging calls will be made. */
  +    private static final Log log = LogSource.getInstance( ExprTag.class );
  +
       /** The expression to evaluate. */
       private Expression value;        
   
  @@ -86,7 +92,7 @@
       //------------------------------------------------------------------------- 
       public void run(Context context, Writer writer) throws IOException {
           if ( value != null ) {
  -            String text = value.evaluateAsString( context );
  +            String text = value.evaluateAsString( context );            
               if ( text != null ) {
                   writer.write( text );
               }
  
  
  
  1.2       +18 -3     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java
  
  Index: ForEachTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ForEachTag.java	12 Feb 2002 21:34:34 -0000	1.1
  +++ ForEachTag.java	13 Feb 2002 16:00:39 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ForEachTag.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: ForEachTag.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -71,14 +71,20 @@
   import org.apache.commons.jelly.TagSupport;
   import org.apache.commons.jelly.expression.Expression;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogSource;
  +
   
   /** A tag which performs an iteration over the results of an XPath expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class ForEachTag extends TagSupport {
   
  +    /** The Log to which logging calls will be made. */
  +    private static final Log log = LogSource.getInstance( ForEachTag.class );
  +    
       /** Holds the variable name to export for the item being iterated over. */
       private Expression items;
       /** 
  @@ -106,8 +112,17 @@
       // Tag interface
       //------------------------------------------------------------------------- 
       public void run(Context context, Writer writer) throws Exception {
  +        if ( log.isDebugEnabled() ) {
  +            log.debug( "running with items: " + items );
  +        }
  +        
           if ( items != null ) { 
               Iterator iter = items.evaluateAsIterator( context );
  +            
  +            if ( log.isDebugEnabled() ) {
  +                log.debug( "Iterating through: " + iter );
  +            }
  +            
               for ( index = begin; iter.hasNext() && index < end; index += step ) {
                   Object value = iter.next();
                   if (var != null) {
  
  
  
  1.2       +9 -5      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestAll.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestAll.java	11 Feb 2002 00:27:41 -0000	1.1
  +++ TestAll.java	13 Feb 2002 16:00:39 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestAll.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/11 00:27:41 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestAll.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/02/13 16:00:39 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TestAll.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
  + * $Id: TestAll.java,v 1.2 2002/02/13 16:00:39 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -66,10 +66,12 @@
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
   
  +import org.apache.commons.jelly.beanshell.TestBeanShellEL;
  +
   /** Entry point for all JUnit tests.
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
    */
   public class TestAll extends TestCase {
       
  @@ -80,6 +82,8 @@
       public static Test suite() {
           TestSuite suite = new TestSuite();
           suite.addTest(TestXMLTags.suite());
  +        suite.addTest(TestCoreTags.suite());
  +        suite.addTest(TestBeanShellEL.suite());
           return suite;
       }
       
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java
  
  Index: TestCoreTags.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v 1.1 2002/02/13 16:00:39 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/13 16:00:39 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TestCoreTags.java,v 1.1 2002/02/13 16:00:39 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.StringWriter;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.impl.TagScript;
  import org.apache.commons.jelly.parser.XMLParser;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  
  
  /** Tests the core tags
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TestCoreTags extends TestCase {
      
      /** The Log to which logging calls will be made. */
      private static final Log log = LogSource.getInstance( TestXMLTags.class );
  
      public static void main( String[] args ) {
          TestRunner.run( suite() );
      }
      
      public static Test suite() {
          return new TestSuite(TestCoreTags.class);
      }
      
      public TestCoreTags(String testName) {
          super(testName);
      }
      
      public void testArgs() throws Exception {
          InputStream in = getClass().getResourceAsStream( "testing123.jelly" );
          XMLParser parser = new XMLParser();
          Script script = parser.parse( in );
          script = script.compile();
  
          log.debug( "Found: " + script );
          
          assertTrue( "Script is a TagScript", script instanceof TagScript );
          
          String[] args = { "one", "two", "three" };
          Context context = new Context();        
          context.setVariable( "args", args );
          StringWriter buffer = new StringWriter();
          
          script.run( context, buffer );
          
          String text = buffer.toString().trim();
          
          if ( log.isDebugEnabled() ) {
              log.debug( "Evaluated script as..." );
              log.debug( text );
          }
          
          assertEquals( "Produces the correct output", "one two three", text );        
      }    
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/testing123.jelly
  
  Index: testing123.jelly
  ===================================================================
  <?xml version="1.0"?>
  <j:jelly xmlns:j="jelly:core">
    <j:forEach var="arg" items="{args}">
      <j:expr value="{arg}"/> 
    </j:forEach>
  </j:jelly>
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/beanshell/TestBeanShellEL.java
  
  Index: TestBeanShellEL.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/beanshell/TestBeanShellEL.java,v 1.1 2002/02/13 16:00:39 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/13 16:00:39 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TestBeanShellEL.java,v 1.1 2002/02/13 16:00:39 jstrachan Exp $
   */
  package org.apache.commons.jelly.beanshell;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.expression.Expression;
  import org.apache.commons.jelly.expression.ExpressionFactory;
  import org.apache.commons.jelly.expression.beanshell.BeanShellExpressionFactory;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  
  
  /** Tests the BeanShell EL
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TestBeanShellEL extends TestCase {
      
      /** The Log to which logging calls will be made. */
      private static final Log log = LogSource.getInstance( TestBeanShellEL.class );
  
      /** Jelly context */
      protected Context context;
      
      /** The factory of Expression objects */
      protected ExpressionFactory factory;
      
      
      public static void main( String[] args ) {
          TestRunner.run( suite() );
      }
      
      public static Test suite() {
          return new TestSuite(TestBeanShellEL.class);
      }
      
      public TestBeanShellEL(String testName) {
          super(testName);
      }
      
      public void setUp() {
          context = new Context();
          context.setVariable( "foo", "abc" );
          context.setVariable( "bar", new Integer( 123 ) );
          factory = new BeanShellExpressionFactory();
      }
      
      public void testEL() throws Exception {
          assertExpression( "{foo}", "abc" );
          assertExpression( "{bar * 2}", new Integer( 246 ) );
      }    
      
      /** Evaluates the given expression text and tests it against the expected value */
      protected void assertExpression( String expressionText, Object expectedValue ) throws Exception {
          Expression expr = factory.createExpression( expressionText );
          Object value = expr.evaluate( context );
          assertEquals( "Value of expression: " + expressionText, expectedValue, value );
      }        
  }
  
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message