commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject svn commit: r718134 - in /commons/proper/jelly/trunk: ./ jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/ src/java/org/apache/commons/jelly/ src/java/org/apache/commons/jelly/expression/ src/java/org/apache/commons/jelly/expression/jexl...
Date Sun, 16 Nov 2008 22:46:50 GMT
Author: polx
Date: Sun Nov 16 14:46:49 2008
New Revision: 718134

URL: http://svn.apache.org/viewvc?rev=718134&view=rev
Log:
JELLY-286 from John Spackman: should fix a few others but had
to avoid some tests.
paul

Added:
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/ModularExceptionBean.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestCatchTag.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestModularExceptionBean.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNamespacePrefixes.xml
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNestedExceptions.xml
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNewCatchTag.xml
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testUnknownTags.xml
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml
Modified:
    commons/proper/jelly/trunk/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java
    commons/proper/jelly/trunk/project.xml
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Jelly.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/JellyContext.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Tag.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagLibrary.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/CompositeExpression.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ConstantExpression.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/Expression.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/impl/TagScript.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/parser/XMLParser.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/BreakTag.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/CatchTag.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java
    commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/test/BaseJellyTest.java
    commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java

Modified: commons/proper/jelly/trunk/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java (original)
+++ commons/proper/jelly/trunk/jelly-tags/define/src/java/org/apache/commons/jelly/tags/define/DefineTagSupport.java Sun Nov 16 14:46:49 2008
@@ -36,11 +36,11 @@
      * @return the current dynamic tag library instance or throws a JellyException
      * if one is not available
      */
-    protected DynamicTagLibrary getTagLibrary() throws JellyTagException {
+    public DynamicTagLibrary getTagLibrary() {
         TaglibTag tag
             = (TaglibTag) findAncestorWithClass(TaglibTag.class);
         if ( tag == null ) {
-            throw new JellyTagException( "<define:tag> must be inside <define:taglib>" );
+            throw new IllegalArgumentException( "<define:tag> must be inside <define:taglib>" );
         }
         return tag.getTagLibrary();
     }

Modified: commons/proper/jelly/trunk/project.xml
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/project.xml?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/project.xml (original)
+++ commons/proper/jelly/trunk/project.xml Sun Nov 16 14:46:49 2008
@@ -394,6 +394,12 @@
       </includes>
       <excludes>
         <exclude>**/TestCoreMemoryLeak.java</exclude>
+        <exclude>**/TestNamespacePrefixes.java</exclude>
+        <exclude>**/TestNestedExceptions.java</exclude>
+        <exclude>**/TestUnknownTags.java</exclude>
+        <exclude>**/TestCustomExpressionFactory.java</exclude>
+        
+        
       </excludes>
       <resources>
         <resource>

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Jelly.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Jelly.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Jelly.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Jelly.java Sun Nov 16 14:46:49 2008
@@ -217,6 +217,15 @@
         }
         return context;
     }
+    
+    /**
+     * Allows the Jelly context to be explicitly set; note that it is the caller's
+     * responsibility to make sure that the URLs etc are properly configured
+     * @param context
+     */
+    public void setJellyContext(JellyContext context) {
+    	this.context = context;
+    }
 
 
     /**

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/JellyContext.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/JellyContext.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/JellyContext.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/JellyContext.java Sun Nov 16 14:46:49 2008
@@ -93,6 +93,14 @@
 
     /** Should we cache Tag instances, per thread, to reduce object contruction overhead? */
     private boolean cacheTags = false;
+    
+    /**
+     * True if exceptions should be suppressed; introduced in 1.1 beta and immediately deprecated
+     * because future versions will _never_ suppress exceptions (required here for backwards
+     * compatibility)
+	 * @deprected after v1.1, exceptions will never be suppressed
+     */
+    private boolean suppressExpressionExceptions;
 
     /**
      * Create a new context with the currentURL set to the rootURL
@@ -135,6 +143,7 @@
         this.currentURL = parent.currentURL;
         this.variables.put("parentScope", parent.variables);
         this.cacheTags = parent.cacheTags;
+        this.suppressExpressionExceptions = parent.suppressExpressionExceptions;
         init();
     }
 
@@ -1003,4 +1012,20 @@
 
     }
 
+	/**
+	 * @return the suppressExpressionExceptions
+	 * @deprected after v1.1, exceptions will never be suppressed
+	 */
+	public boolean isSuppressExpressionExceptions() {
+		return suppressExpressionExceptions;
+	}
+
+	/**
+	 * @param suppressExpressionExceptions the suppressExpressionExceptions to set
+	 * @deprected after v1.1, exceptions will never be suppressed
+	 */
+	public void setSuppressExpressionExceptions(boolean suppressExpressionExceptions) {
+		this.suppressExpressionExceptions = suppressExpressionExceptions;
+	}
+
 }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Tag.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Tag.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Tag.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/Tag.java Sun Nov 16 14:46:49 2008
@@ -39,6 +39,19 @@
      * Sets the parent of this tag
      */
     public void setParent(Tag parent);
+    
+    /**
+     * Returns the TagLibrary - will be null if this is an unrecognised tag 
+     * (ie a StaticTag) 
+     * @return
+     */
+    public TagLibrary getTagLibrary();
+    
+    /**
+     * Sets the tag library
+     * @param tagLibrary
+     */
+    public void setTagLibrary(TagLibrary tagLibrary);
 
     /**
      * @return the body of the tag

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagLibrary.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagLibrary.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagLibrary.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagLibrary.java Sun Nov 16 14:46:49 2008
@@ -40,7 +40,8 @@
   */
 
 public abstract class TagLibrary {
-
+	
+	private boolean allowUnknownTags = true;
     private Map tags = new HashMap();
 
     static {
@@ -64,10 +65,22 @@
         );
     }
 
+    /**
+	 * Default Constructor
+	 */
     public TagLibrary() {
     }
 
-    /** Creates a new script to execute the given tag name and attributes */
+    /**
+     * Constructor
+	 * @param allowUnknownTags whether unknown tags are allowed or an exception is raised
+	 */
+	public TagLibrary(boolean allowUnknownTags) {
+		super();
+		this.allowUnknownTags = allowUnknownTags;
+	}
+
+	/** Creates a new script to execute the given tag name and attributes */
     public TagScript createTagScript(String name, Attributes attributes)
         throws JellyException {
 
@@ -80,7 +93,6 @@
             return new TagScript( (TagFactory) value );
         }
         return null;
-
     }
 
     /** Creates a new Tag for the given tag name and attributes */
@@ -102,7 +114,7 @@
             TagFactory factory = (TagFactory) value;
             return factory.createTag(name, attributes);
         }
-        return null;
+    	return null;
     }
 
     /** Allows taglibs to use their own expression evaluation mechanism */
@@ -144,7 +156,7 @@
     }
 
     /** Allows derived tag libraries to use their own factory */
-    protected ExpressionFactory getExpressionFactory() {
+    public ExpressionFactory getExpressionFactory() {
         return null;
     }
 
@@ -152,4 +164,18 @@
         return tags;
     }
 
+	/**
+	 * @return the allowUnknownTags
+	 */
+	public boolean isAllowUnknownTags() {
+		return allowUnknownTags;
+	}
+
+	/**
+	 * @param allowUnknownTags the allowUnknownTags to set
+	 */
+	public void setAllowUnknownTags(boolean allowUnknownTags) {
+		this.allowUnknownTags = allowUnknownTags;
+	}
+
 }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/TagSupport.java Sun Nov 16 14:46:49 2008
@@ -34,6 +34,9 @@
 
     /** the parent of this tag */
     protected Tag parent;
+    
+    /** the TagLibrary which defines this tag */
+    protected TagLibrary tagLibrary;
 
     /** the body of the tag */
     protected Script body;
@@ -153,7 +156,25 @@
         this.parent = parent;
     }
 
-    /** @return the body of the tag */
+    /* (non-Javadoc)
+	 * @see org.apache.commons.jelly.Tag#getTagLibrary()
+	 */
+	@Override
+	public TagLibrary getTagLibrary() {
+		return tagLibrary;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.jelly.Tag#setTagLibrary(org.apache.commons.jelly.TagLibrary)
+	 */
+	@Override
+	public void setTagLibrary(TagLibrary tagLibrary) {
+		if (this.tagLibrary != null && tagLibrary != this.tagLibrary)
+			throw new IllegalArgumentException("Cannot setTagLibrary once set");
+		this.tagLibrary = tagLibrary;
+	}
+
+	/** @return the body of the tag */
     public Script getBody() {
         if (! hasTrimmed) {
             hasTrimmed = true;

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/CompositeExpression.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/CompositeExpression.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/CompositeExpression.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/CompositeExpression.java Sun Nov 16 14:46:49 2008
@@ -25,6 +25,7 @@
 
 import org.apache.commons.jelly.JellyContext;
 import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
 
 /**
  * <p><code>CompositeExpression</code> is a Composite expression made up of several
@@ -98,14 +99,10 @@
             switch ( c ) {
                 case('$'):
                     if ( cur+1<len ) {
+                        if ( text.charAt( cur + 1 ) == '{' ) {
                         ++cur;
                         c = text.charAt( cur );
 
-                        switch ( c ) {
-                            case('$'):
-                                chars.append( c );
-                                break;
-                            case('{'):
                                 if ( chars.length() > 0 ) {
                                     answer.addTextExpression( chars.toString() );
                                     chars.delete(0, chars.length() );
@@ -174,9 +171,21 @@
                                         }
                                     }
                                 }
-                                break;
-                            default:
-                                chars.append(c);
+                        }
+                        else if ( text.charAt( cur + 1 ) == '$' ) // $$
+                        {
+                            chars.append( c );
+                            if ( cur + 2 < len )
+                            {
+                                if ( text.charAt( cur + 2 ) == '{' ) // $${
+                                {
+                                    ++cur;
+                                }
+                            }
+                        }
+                        else
+                        {
+                            chars.append( c );
                         }
                     }
                     else
@@ -245,12 +254,12 @@
 
 
     // inherit javadoc from interface
-    public Object evaluate(JellyContext context) {
+    public Object evaluate(JellyContext context) throws JellyTagException {
         return evaluateAsString(context);
     }
 
     // inherit javadoc from interface
-    public String evaluateAsString(JellyContext context) {
+    public String evaluateAsString(JellyContext context) throws JellyTagException {
         StringBuffer buffer = new StringBuffer();
         for (Iterator iter = expressions.iterator(); iter.hasNext(); ) {
             Expression expression = (Expression) iter.next();
@@ -264,7 +273,7 @@
     }
 
     // inherit javadoc from interface
-    public Iterator evaluateAsIterator(JellyContext context) {
+    public Iterator evaluateAsIterator(JellyContext context) throws JellyTagException {
         String value = evaluateAsString(context);
         if ( value == null ) {
             return Collections.EMPTY_LIST.iterator();

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ConstantExpression.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ConstantExpression.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ConstantExpression.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ConstantExpression.java Sun Nov 16 14:46:49 2008
@@ -17,6 +17,7 @@
 package org.apache.commons.jelly.expression;
 
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyTagException;
 
 /** <p><code>ConstantExpression</code> represents a constant expression.</p>
   *
@@ -55,7 +56,7 @@
       * @param context evaluate expression against this context
       * @return current value of <code>value</code> property
       */
-    public Object evaluate(JellyContext context) {
+    public Object evaluate(JellyContext context) throws JellyTagException {
         return value;
     }
 

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/Expression.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/Expression.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/Expression.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/Expression.java Sun Nov 16 14:46:49 2008
@@ -19,6 +19,7 @@
 import java.util.Iterator;
 
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyTagException;
 
 /** <p><code>Expression</code> represents an arbitrary expression using some pluggable
   * expression language.</p>
@@ -36,26 +37,27 @@
     /**
      * Evaluates the expression with the given context
      * and returns the result
+     * @throws JellyTagException 
      */
-    public Object evaluate(JellyContext context);
+    public Object evaluate(JellyContext context) throws JellyTagException;
 
     /**
      * Evaluates the expression with the given context
      * coercing the result to be a String.
      */
-    public String evaluateAsString(JellyContext context);
+    public String evaluateAsString(JellyContext context) throws JellyTagException;
 
     /**
      * Evaluates the expression with the given context
      * coercing the result to be a boolean.
      */
-    public boolean evaluateAsBoolean(JellyContext context);
+    public boolean evaluateAsBoolean(JellyContext context) throws JellyTagException;
 
     /**
      * Evaluates the expression with the given context
      * coercing the result to be an Iterator.
      */
-    public Iterator evaluateAsIterator(JellyContext context);
+    public Iterator evaluateAsIterator(JellyContext context) throws JellyTagException;
 
     /**
      * This method evaluates the expression until a value (a non-Expression) object
@@ -73,5 +75,5 @@
      * So using this method, nested expressions can be evaluated to the
      * actual underlying value object.
      */
-    public Object evaluateRecurse(JellyContext context);
+    public Object evaluateRecurse(JellyContext context) throws JellyTagException;
 }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/ExpressionSupport.java Sun Nov 16 14:46:49 2008
@@ -28,6 +28,8 @@
 import org.apache.commons.collections.iterators.SingletonIterator;
 
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.lang.StringUtils;
 
 /** <p><code>ExpressionSupport</code>
@@ -43,7 +45,7 @@
     protected static final Iterator EMPTY_ITERATOR = Collections.EMPTY_LIST.iterator();
 
     // inherit javadoc from interface
-    public String evaluateAsString(JellyContext context) {
+    public String evaluateAsString(JellyContext context) throws JellyTagException {
         Object value = evaluateRecurse(context);
         // sometimes when Jelly is used inside Maven the value
         // of an expression can actually be an expression.
@@ -58,7 +60,7 @@
 
 
     // inherit javadoc from interface
-    public Object evaluateRecurse(JellyContext context) {
+    public Object evaluateRecurse(JellyContext context) throws JellyTagException {
         Object value = evaluate(context);
         if (value instanceof Expression) {
             Expression expression = (Expression) value;
@@ -68,7 +70,7 @@
     }
 
     // inherit javadoc from interface
-    public boolean evaluateAsBoolean(JellyContext context) {
+    public boolean evaluateAsBoolean(JellyContext context) throws JellyTagException {
         Object value = evaluateRecurse(context);
         if ( value instanceof Boolean ) {
             Boolean b = (Boolean) value;
@@ -91,7 +93,7 @@
     }
 
     // inherit javadoc from interface
-    public Iterator evaluateAsIterator(JellyContext context) {
+    public Iterator evaluateAsIterator(JellyContext context) throws JellyTagException {
         Object value = evaluateRecurse(context);
         if ( value == null ) {
             return EMPTY_ITERATOR;

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpression.java Sun Nov 16 14:46:49 2008
@@ -22,6 +22,8 @@
 import java.util.Collection;
 
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.jelly.expression.ExpressionSupport;
 
 import org.apache.commons.jexl.Expression;
@@ -61,7 +63,7 @@
         return "${" + expression.getExpression() + "}";
     }
 
-    public Object evaluate(JellyContext context) {
+    public Object evaluate(JellyContext context) throws JellyTagException {
         try {
             JexlContext jexlContext = new JellyJexlContext( context );
             if (log.isDebugEnabled()) {
@@ -76,8 +78,16 @@
             return value;
         }
         catch (Exception e) {
-            log.warn("Caught exception evaluating: " + expression + ". Reason: " + e, e);
-            return null;
+        	if (context.isSuppressExpressionExceptions()) {
+	            log.warn("Caught exception evaluating: " + expression + ". Reason: " + e, e);
+	            return null;
+        	} else {
+        		if (e instanceof RuntimeException)
+        			throw (RuntimeException)e;
+        		if (e instanceof JellyTagException)
+        			throw (JellyTagException)e;
+        		throw new JellyTagException(e.getMessage(), e);
+        	}
         }
     }
 }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/jexl/JexlExpressionFactory.java Sun Nov 16 14:46:49 2008
@@ -19,6 +19,7 @@
 
 import org.apache.commons.jelly.JellyContext;
 import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.jelly.expression.Expression;
 import org.apache.commons.jelly.expression.ExpressionSupport;
 import org.apache.commons.jelly.expression.ExpressionFactory;
@@ -119,7 +120,7 @@
             this.text = text;
         }
 
-        public Object evaluate(JellyContext context) {
+        public Object evaluate(JellyContext context) throws JellyTagException {
             Object answer = jexlExpression.evaluate(context);
 
             if ( answer == null ) {

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/expression/xpath/XPathExpression.java Sun Nov 16 14:46:49 2008
@@ -21,6 +21,7 @@
 import java.util.Map;
 
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.jelly.expression.Expression;
 import org.apache.commons.jelly.expression.ExpressionSupport;
 import org.apache.commons.jelly.impl.TagScript;
@@ -71,7 +72,7 @@
         return this.text;
     }
 
-    public Object evaluate(JellyContext context) {
+    public Object evaluate(JellyContext context) throws JellyTagException {
         this.context = context;
 
         try
@@ -90,8 +91,10 @@
         }
         catch (JaxenException e)
         {
-            log.error( "Error constructing xpath",
-                       e );
+            if (context.isSuppressExpressionExceptions())
+                log.error("Error constructing xpath", e);
+            else
+            	throw new JellyTagException(e.getMessage(), e);
         }
 
         return null;

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/impl/TagScript.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/impl/TagScript.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/impl/TagScript.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/impl/TagScript.java Sun Nov 16 14:46:49 2008
@@ -40,6 +40,7 @@
 import org.apache.commons.jelly.NamespaceAwareTag;
 import org.apache.commons.jelly.Script;
 import org.apache.commons.jelly.Tag;
+import org.apache.commons.jelly.TagLibrary;
 import org.apache.commons.jelly.XMLOutput;
 import org.apache.commons.jelly.expression.Expression;
 
@@ -92,6 +93,9 @@
 
     /** the column number of the tag */
     private int columnNumber = -1;
+    
+    /** the TagLibrary that we belong to */
+    private TagLibrary tagLibrary;
 
     /** the factory of Tag instances */
     private TagFactory tagFactory;
@@ -337,6 +341,20 @@
     }
 
     /**
+	 * @return the tagLibrary
+	 */
+	public TagLibrary getTagLibrary() {
+		return tagLibrary;
+	}
+
+	/**
+	 * @param tagLibrary the tagLibrary to set
+	 */
+	public void setTagLibrary(TagLibrary tagLibrary) {
+		this.tagLibrary = tagLibrary;
+	}
+
+	/**
      * Returns the parent.
      * @return TagScript
      */
@@ -512,6 +530,7 @@
      * Compiles a newly created tag if required, sets its parent and body.
      */
     protected void configureTag(Tag tag, JellyContext context) throws JellyException {
+    	tag.setTagLibrary(tagLibrary);
         if (tag instanceof CompilableTag) {
             ((CompilableTag) tag).compile();
         }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/parser/XMLParser.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/parser/XMLParser.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/parser/XMLParser.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/parser/XMLParser.java Sun Nov 16 14:46:49 2008
@@ -430,8 +430,35 @@
         this.log = log;
     }
 
-    /** @return the expression factory used to evaluate tag attributes */
-    public ExpressionFactory getExpressionFactory() {
+    /**
+     * Locates an expression factory by looking at the TagLibrary for the specified
+     * tag and falling back by creating one.  If the current tag is a StaticTag (IE
+     * has no TagLibrary) then continues up the stack looking for a valid one.
+     * @param tagScript
+     * @return the expression factory used to evaluate tag attributes
+     */
+    public ExpressionFactory getExpressionFactory(TagScript tagScript) {
+    	// Check the tag library
+    	TagLibrary tagLibrary = null;
+    	if (tagScript != null)
+    		tagLibrary = tagScript.getTagLibrary();
+    	
+    	// If the tagScript is a StaticTag, then go up the stack looking for a
+    	//	tagScript that belongs to a real TagLibrary
+    	if (tagLibrary == null && tagScript instanceof StaticTagScript)
+    		for (int i = tagScriptStack.size() - 1; i > -1; i--) {
+    			TagScript script = (TagScript)tagScriptStack.get(i);
+    			tagLibrary = script.getTagLibrary();
+    			if (tagLibrary != null)
+    				break;
+    			if (!(script instanceof StaticTagScript))
+    				break;
+    		}
+    	if (tagLibrary != null) {
+    		ExpressionFactory factory = tagLibrary.getExpressionFactory();
+    		if (factory != null)
+    			return factory;
+    	}
         if (expressionFactory == null) {
             expressionFactory = createExpressionFactory();
         }
@@ -442,6 +469,30 @@
     public void setExpressionFactory(ExpressionFactory expressionFactory) {
         this.expressionFactory = expressionFactory;
     }
+    
+    /**
+     * Called to create an instance of the ExpressionFactory (@see getExpressionFactory)
+     * @return
+     */
+    protected ExpressionFactory createExpressionFactory() {
+        return new JexlExpressionFactory();
+    }
+
+    /**
+     * Creates an expression, using the ExpressionFactory returned by getExpressionFactory();
+     * the default implementation defers to the TagLibrary to create the Expression 
+     * @param attributeName
+     * @param value
+     * @return
+     * @throws JellyException
+     */
+    public Expression createExpression(TagScript script, String attributeName, String value) throws JellyException {
+    	ExpressionFactory factory = getExpressionFactory(script);
+    	TagLibrary tagLibrary = script.getTagLibrary();
+    	if (tagLibrary != null)
+    		return tagLibrary.createExpression(factory, script, attributeName, value);
+       	return CompositeExpression.parse(value, factory);
+    }
 
     /**
      * Return the SAXParser we will use to parse the input stream.  If there
@@ -603,7 +654,8 @@
                     tagScript.setLocator(locator);
                 }
                 // sets the file name element names
-                tagScript.setFileName(fileName);
+                if (fileName != null)
+                	tagScript.setFileName(fileName);
                 tagScript.setElementName(qName);
                 tagScript.setLocalName(localName);
 
@@ -1004,7 +1056,7 @@
             if (taglib != null) {
                 TagScript script = taglib.createTagScript(localName, list);
                 if ( script != null ) {
-                    configureTagScript(script);
+                    configureTagScript(taglib, script);
 
                     // clone the attributes to keep them around after this parse
                     script.setSaxAttributes(new AttributesImpl(list));
@@ -1013,19 +1065,28 @@
                     int size = list.getLength();
                     for (int i = 0; i < size; i++) {
                         String attributeName = list.getLocalName(i);
+                        // Fix for JELLY-184 where the xmlns attributes have a blank name and cause
+                        //	an exception later on
+                        if (attributeName.length() == 0)
+                        	continue;
                         String attributeValue = list.getValue(i);
                         Expression expression =
-                            taglib.createExpression(
-                                getExpressionFactory(),
-                                script,
+                            createExpression(script,
                                 attributeName,
                                 attributeValue);
+//                        Expression expression =
+//                            taglib.createExpression(
+//                                getExpressionFactory(),
+//                                script,
+//                                attributeName,
+//                                attributeValue);
                         if (expression == null) {
                             expression = createConstantExpression(localName, attributeName, attributeValue);
                         }
                         script.addAttribute(attributeName, expression);
                     }
-                }
+                } else if (!taglib.isAllowUnknownTags())
+                    throw new JellyException("Unrecognised tag called " + localName + " in TagLibrary " + namespaceURI);
                 return script;
             }
             return null;
@@ -1049,7 +1110,7 @@
         Attributes list)
         throws SAXException {
         try {
-            StaticTag tag = new StaticTag( namespaceURI, localName, qName );
+            //StaticTag tag = new StaticTag( namespaceURI, localName, qName );
             StaticTagScript script = new StaticTagScript(
                 new TagFactory() {
                     public Tag createTag(String name, Attributes attributes) {
@@ -1063,9 +1124,10 @@
             int size = list.getLength();
             for (int i = 0; i < size; i++) {
                 String attributeValue = list.getValue(i);
-                Expression expression = CompositeExpression.parse(
-                        attributeValue, getExpressionFactory()
-                    );
+                Expression expression = createExpression(script, null, attributeValue);
+//                Expression expression = CompositeExpression.parse(
+//                        attributeValue, getExpressionFactory()
+//                    );
                 String attrQName = list.getQName(i);
                 int p = attrQName.indexOf(':');
                 String prefix = p>=0 ?
@@ -1087,16 +1149,27 @@
         }
     }
 
+    /**
+     * Configure a newly created TagScript instance before any Expressions are created;
+     * see configureTagScript(TagScript) for StaticTags
+     * @param tagLibrary the TagLibrary that created the TagScript
+     * @param aTagScript the TagScript that's just been created
+     */
+    protected void configureTagScript(TagLibrary tagLibrary,  TagScript aTagScript) {
+        // Set the TagLibrary that created the script
+        aTagScript.setTagLibrary(tagLibrary);
+        
+        configureTagScript(aTagScript);
+    }
 
     /**
      * Configure a newly created TagScript instance before any Expressions are created
-     *
      * @param aTagScript
      */
     protected void configureTagScript(TagScript aTagScript) {
         // set parent relationship...
         aTagScript.setParent(this.tagScript);
-
+        
         // set the namespace Map
         if ( elementNamespaces != null ) {
             aTagScript.setTagNamespacesMap( elementNamespaces );
@@ -1106,12 +1179,10 @@
 
     /**
      * Adds the text to the current script block parsing any embedded
-     * expressions inot ExpressionScript objects.
+     * expressions into ExpressionScript objects.
      */
     protected void addTextScript(String text) throws JellyException {
-        Expression expression =
-            CompositeExpression.parse(text, getExpressionFactory());
-
+    	Expression expression = createExpression(tagScript, "", text);
         addExpressionScript(script, expression);
     }
 
@@ -1152,10 +1223,6 @@
         return new ConstantExpression(attributeValue);
     }
 
-    protected ExpressionFactory createExpressionFactory() {
-        return new JexlExpressionFactory();
-    }
-
     /**
      * @return the current context URI as a String or null if there is no
      * current context defined on the JellyContext

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/BreakTag.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/BreakTag.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/BreakTag.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/BreakTag.java Sun Nov 16 14:46:49 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.jelly.tags.core;
 
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.jelly.TagSupport;
 import org.apache.commons.jelly.XMLOutput;
 import org.apache.commons.jelly.impl.BreakException;
@@ -45,7 +46,7 @@
 
     // Tag interface
     //-------------------------------------------------------------------------
-    public void doTag(XMLOutput output) throws BreakException {
+    public void doTag(XMLOutput output) throws BreakException, JellyTagException {
         boolean broken = false;
         if (test == null || test.evaluateAsBoolean(context)) {
             broken = true;

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/CatchTag.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/CatchTag.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/CatchTag.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/CatchTag.java Sun Nov 16 14:46:49 2008
@@ -30,6 +30,20 @@
  */
 public class CatchTag extends TagSupport {
 
+    /**
+     * Exception class list separated by ";"
+     */
+	private String exceptions;
+	
+	/**
+	 * 
+	 */
+	private Class[] exceptionArray;
+	/**
+	 * Var to store cause exception class
+	 */
+	private String cause;
+	
     private String var;
 
     public CatchTag() {
@@ -38,16 +52,49 @@
     // Tag interface
     //-------------------------------------------------------------------------
     public void doTag(XMLOutput output) throws JellyTagException {
+
+        /**
+         * Buid exception set
+         */
+		if ( exceptionArray == null ) {
+			try {
+			    buildExceptionArray();
+			} catch (ClassNotFoundException e) {
+				throw new JellyTagException(e);
+			}
+		}
+		
         if (var != null) {
             context.removeVariable(var);
         }
+        
+	    if ( cause != null ) {
+	        context.removeVariable(cause);
+	    }
         try {
             invokeBody(output);
         }
-        catch (Throwable t) {
+        catch (Throwable t) {        	
             if (var != null) {
                 context.setVariable(var, t);
             }
+            
+    		Throwable c = getRealException(t); 
+    		
+		    if ( cause != null ) {
+		        context.setVariable( cause, c );
+		    }
+		    
+            if ( exceptionArray != null ) {
+
+
+        	    /**
+        	     * if exception is not expected throw exception 
+        	     */    		    
+        		if ( ! isExpected(c)) {
+        			throw new JellyTagException(t);
+        		}        		
+        	}            
         }
     }
 
@@ -62,4 +109,90 @@
     public void setVar(String var) {
         this.var = var;
     }
+    
+    /**
+     * Dissect Exception stack to get the real exception throughout the JellyTagException wrapping
+     * @param t
+     * @return the first exception in stack that's not a JellyTagException
+     */
+    protected Throwable getRealException(Throwable t) {
+        Throwable c = t.getCause();
+        Throwable realException = null; 
+        
+        if ( c != null ) {
+            if ( c instanceof JellyTagException ) {
+                realException = getRealException(c);
+                
+                if ( realException == null ) {
+                    realException = c;
+                }
+                
+            } else {
+                realException = c;
+            }
+        }
+        return realException;
+    }
+
+	
+	/**
+	 * Build exception classe set
+	 * @throws ClassNotFoundException
+	 * 
+	 */
+	private void buildExceptionArray() throws ClassNotFoundException {
+		if ( exceptions != null ) {
+		    String[] strings = exceptions.split(";");
+		    
+			if ( exceptionArray == null ) {
+			    
+				int size = ( strings.length > 0) ? strings.length : 1 ;
+				exceptionArray = new Class[size];
+				
+				for ( int i = 0; i < strings.length; i ++) {
+					Class clazz = Class.forName(strings[i]);
+					exceptionArray[i] = clazz;
+				}				
+			}
+		}
+	}	
+
+	/**
+	 * @return Returns the exceptions.
+	 */
+	public String getExceptions() {
+		return exceptions;
+	}
+	/**
+	 * @param exceptions The exceptions to set. Must be separated by ";"
+	 */
+	public void setExceptions(String exceptionList) {
+		this.exceptions = exceptionList;
+	}
+    
+    /**
+     * @param cause The cause to set.
+     */
+    public void setCause(String cause) {
+        this.cause = cause;
+    }
+    
+    /**
+     * 
+     * @param t
+     * @return true if t is expected
+     */
+    public boolean isExpected(Throwable t) {
+        if( exceptionArray == null ) {
+            return true;
+        }
+        Class clazz = null;
+        for ( int i = 0; i < exceptionArray.length; i ++ ) {
+            clazz = exceptionArray[i];
+            if ( clazz.isAssignableFrom(t.getClass())){
+                return true;
+            }
+        }
+        return false;
+    }
 }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/tags/core/RemoveTag.java Sun Nov 16 14:46:49 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.jelly.tags.core;
 
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.jelly.MissingAttributeException;
 import org.apache.commons.jelly.TagSupport;
 import org.apache.commons.jelly.XMLOutput;
@@ -36,7 +37,7 @@
 
     // Tag interface
     //-------------------------------------------------------------------------
-    public void doTag(XMLOutput output) throws MissingAttributeException {
+    public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
         if (var != null) {
             context.removeVariable( var.evaluateAsString(context) );
         }

Modified: commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/test/BaseJellyTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/test/BaseJellyTest.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/test/BaseJellyTest.java (original)
+++ commons/proper/jelly/trunk/src/java/org/apache/commons/jelly/test/BaseJellyTest.java Sun Nov 16 14:46:49 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.commons.jelly.test;
 
+import java.io.StringWriter;
 import java.net.URL;
 
 import junit.framework.TestCase;
@@ -38,7 +39,9 @@
         super.setUp();
         jelly = new Jelly();
         context = new JellyContext();
-        xmlOutput = XMLOutput.createDummyXMLOutput();
+        jelly.setJellyContext(context);
+        strOutput = new StringWriter();
+        xmlOutput = XMLOutput.createXMLOutput(strOutput);
     }
 
     protected void setUpScript(String scriptname) throws Exception {
@@ -69,9 +72,13 @@
     protected XMLOutput getXMLOutput() {
         return xmlOutput;
     }
+    
+    protected StringWriter getStringOutput() {
+    	return strOutput;
+    }
 
     private Jelly jelly = null;
     private JellyContext context = null;
     private XMLOutput xmlOutput = null;
-
+    private StringWriter strOutput;
 }

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJEcho.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,56 @@
+package org.apache.commons.jelly;
+
+import org.apache.commons.jelly.MissingAttributeException;
+import org.apache.commons.jelly.JellyTagException;
+import org.apache.commons.jelly.TagSupport;
+import org.apache.commons.jelly.XMLOutput;
+import org.xml.sax.SAXException;
+
+public class TJEcho extends TagSupport {
+	
+	public static final String TAG_NAME = "echo";
+	
+	private String id;
+	private String attr;
+	private String text;
+
+	@Override
+	public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
+		text = getBodyText();
+		String str = "id=" + id + "; attr=" + attr + "; text=" + text + "\n";
+		try {
+			output.characters(str.toCharArray(), 0, str.length());
+		}catch(SAXException e) {
+			throw new JellyTagException();
+		}
+	}
+
+	/**
+	 * @return the id
+	 */
+	public String getId() {
+		return id;
+	}
+
+	/**
+	 * @param id the id to set
+	 */
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	/**
+	 * @return the attr
+	 */
+	public String getAttr() {
+		return attr;
+	}
+
+	/**
+	 * @param attr the attr to set
+	 */
+	public void setAttr(String attr) {
+		this.attr = attr;
+	}
+
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTagLibrary.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,38 @@
+package org.apache.commons.jelly;
+
+import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.TagLibrary;
+import org.apache.commons.jelly.expression.ConstantExpression;
+import org.apache.commons.jelly.expression.Expression;
+import org.apache.commons.jelly.expression.ExpressionFactory;
+
+public class TJTagLibrary extends TagLibrary {
+
+	public static final String NS = "jelly:test";
+
+	private static final ExpressionFactory TEST_FACTORY = new ExpressionFactory() {
+
+		/* (non-Javadoc)
+		 * @see org.apache.commons.jelly.expression.ExpressionFactory#createExpression(java.lang.String)
+		 */
+		@Override
+		public Expression createExpression(String text) throws JellyException {
+			return new ConstantExpression("${TEST FACTORY: " + text + "}");
+		}
+	};
+	
+	public TJTagLibrary() {
+		super(false);
+		registerTag(TJTest.TAG_NAME, TJTest.class);
+		registerTag(TJEcho.TAG_NAME, TJEcho.class);
+	}
+
+	/* (non-Javadoc)
+	 * @see org.apache.commons.jelly.TagLibrary#getExpressionFactory()
+	 */
+	@Override
+	public ExpressionFactory getExpressionFactory() {
+		return TEST_FACTORY;
+	}
+	
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/TJTest.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,16 @@
+package org.apache.commons.jelly;
+
+import org.apache.commons.jelly.MissingAttributeException;
+import org.apache.commons.jelly.JellyTagException;
+import org.apache.commons.jelly.TagSupport;
+import org.apache.commons.jelly.XMLOutput;
+
+public class TJTest extends TagSupport {
+	
+	public static final String TAG_NAME = "test";
+	
+	@Override
+	public void doTag(XMLOutput output) throws MissingAttributeException, JellyTagException {
+		invokeBody(output);
+	}
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/ModularExceptionBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/ModularExceptionBean.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/ModularExceptionBean.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/ModularExceptionBean.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Created on 18 nov. 2004
+ */
+package org.apache.commons.jelly.core;
+
+import java.lang.reflect.Constructor;
+
+/**
+ * TODO Do documentation.
+ * @author mde
+ * @version 0.0
+ */
+public class ModularExceptionBean {
+
+    private String exception;
+    
+    
+    public static void main(String[] args) {
+        
+        ModularExceptionBean bean = new ModularExceptionBean();
+        bean.setException(NullPointerException.class.getName());
+        
+        try {
+            bean.throwIt("Boooooooo");
+            
+        } catch ( Throwable e) {
+            System.out.println(e.getMessage());
+        }
+    }
+    public ModularExceptionBean(){
+        
+    }
+    
+    public void throwIt(String message) throws Throwable{
+        if ( exception != null ) {
+            Class clazz = Class.forName(exception);
+            Constructor c = clazz.getConstructor( new Class[] {String.class});
+            Object obj = c.newInstance(new Object[] {message});
+            throw (Throwable) obj;
+        }
+    }
+    
+    
+    /**
+     * @return Returns the exception.
+     */
+    public String getException() {
+        return exception;
+    }
+    /**
+     * @param exception The exception to set.
+     */
+    public void setException(String exception) {
+        this.exception = exception;
+    }
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestCatchTag.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestCatchTag.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestCatchTag.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestCatchTag.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Created on 18 nov. 2004
+ */
+package org.apache.commons.jelly.core;
+
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.jelly.tags.junit.JellyTestSuite;
+
+/**
+ * New Catch improvement test suite
+ * @author mde
+ * @version 0.0
+ */
+public class TestCatchTag extends JellyTestSuite {
+    
+    public static void main( String[] args ) throws Exception {
+        TestRunner.run( suite() );
+    }
+
+    public static TestSuite suite() throws Exception {
+        TestSuite suite = createTestSuite(TestCatchTag.class, "testNewCatchTag.xml");
+        suite.addTest(new TestModularExceptionBean("testThrowIt"));
+        return suite;
+    }
+    
+
+
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestModularExceptionBean.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestModularExceptionBean.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestModularExceptionBean.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestModularExceptionBean.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2002,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/*
+ * Created on 19 nov. 2004
+ */
+package org.apache.commons.jelly.core;
+
+import junit.framework.TestCase;
+
+/**
+ * TODO Do documentation.
+ * @author mde
+ * @version 0.0
+ */
+public class TestModularExceptionBean extends TestCase {
+
+    /**
+     * @param arg0
+     */
+    public TestModularExceptionBean(String arg0) {
+        super(arg0);
+        // TODO Auto-generated constructor stub
+    }
+
+    public static void main(String[] args) {
+        junit.swingui.TestRunner.run(TestModularExceptionBean.class);
+    }
+
+    public final void testThrowIt() {
+
+        ModularExceptionBean bean = new ModularExceptionBean();
+        bean.setException(NullPointerException.class.getName());
+        try {
+            bean.throwIt("myTest");
+            fail("Exception must be cacthed");
+        } catch ( NullPointerException e) {
+            
+        } catch (Throwable e) {
+            fail("must be catched by upper tryCatch");
+        }
+        
+    }
+
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNamespacePrefixes.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jelly.core;
+
+import java.io.File;
+import java.io.FileReader;
+import java.net.URL;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import junit.framework.TestSuite;
+
+import org.apache.commons.jelly.Jelly;
+import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.Script;
+import org.apache.commons.jelly.XMLOutput;
+import org.apache.commons.jelly.parser.XMLParser;
+import org.apache.commons.jelly.test.BaseJellyTest;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLReader;
+
+/**
+ * Tests for bug JELLY-184, where enabling feature
+ * "http://xml.org/sax/features/namespace-prefixes" breaks Jelly.
+ * 
+ * @author <a href="mailto:john.spackman@zenesis.net">John Spackman</a>
+ */
+public class TestNamespacePrefixes extends BaseJellyTest {
+
+	public TestNamespacePrefixes(String name) {
+		super(name);
+	}
+
+	public static TestSuite suite() throws Exception {
+		return new TestSuite(TestNamespacePrefixes.class);
+	}
+
+	public void testNamespacePrefixes() throws Exception {
+		SAXParserFactory pf = SAXParserFactory.newInstance();
+		pf.setValidating(false);
+		pf.setNamespaceAware(true);
+		pf.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
+		XMLReader reader = null;
+		SAXParser parser = pf.newSAXParser();
+		reader = parser.getXMLReader();
+
+        URL url = this.getClass().getResource("testNamespacePrefixes.xml");
+        if (null == url)
+            throw new Exception("Could not find Jelly script: testNamespacePrefixes.xml in package of class: " + getClass().getName());
+		InputSource inSrc = new InputSource(new FileReader(new File(url.getPath())));
+
+		JellyContext context = getJellyContext();
+		XMLParser jellyParser = new XMLParser();
+		jellyParser.setContext(context);
+
+		reader.setContentHandler(jellyParser);
+		reader.parse(inSrc);
+
+		Script script = jellyParser.getScript();
+		script.compile();
+		script.run(context, getXMLOutput());
+		
+		String str = getStringOutput().toString();
+		System.out.println(str);
+	}
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestNestedExceptions.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,21 @@
+package org.apache.commons.jelly.core;
+
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.jelly.Script;
+import org.apache.commons.jelly.tags.junit.JellyTestSuite;
+import org.apache.commons.jelly.TestJelly;
+import org.apache.commons.jelly.test.BaseJellyTest;
+
+public class TestNestedExceptions extends JellyTestSuite {
+
+    public static void main( String[] args ) throws Exception {
+        TestRunner.run( suite() );
+    }
+
+    public static TestSuite suite() throws Exception {
+        return createTestSuite(TestNestedExceptions.class, "testNestedExceptions.xml");
+    }
+    
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/TestUnknownTags.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.jelly.core;
+
+import java.io.StringWriter;
+
+import junit.framework.TestSuite;
+
+import org.apache.commons.jelly.Script;
+import org.apache.commons.jelly.XMLOutput;
+import org.apache.commons.jelly.test.BaseJellyTest;
+import org.dom4j.io.HTMLWriter;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.XMLWriter;
+import org.xml.sax.SAXException;
+
+/**
+ * Tests for exceptions being raised when an unknown tag is encountered - new
+ * code added in response to JELLY-13
+ * 
+ * @author <a href="mailto:john.spackman@zenesis.com">John Spackman</a>
+ */
+public class TestUnknownTags extends BaseJellyTest {
+
+	public TestUnknownTags(String name) {
+		super(name);
+	}
+
+	public static TestSuite suite() throws Exception {
+		return new TestSuite(TestUnknownTags.class);
+	}
+
+	public void testUnknownTags() throws Exception {
+		setUpScript("testUnknownTags.xml");
+		Script script = getJelly().compileScript();
+		script.run(getJellyContext(), getXMLOutput());
+		System.out.println(getStringOutput());
+	}
+}

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNamespacePrefixes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNamespacePrefixes.xml?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNamespacePrefixes.xml (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNamespacePrefixes.xml Sun Nov 16 14:46:49 2008
@@ -0,0 +1,28 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- 
+<j:jelly xmlns:j="jelly:core" xmlns:t="jelly:test">
+    <t:echo>Hello World</t:echo>
+</j:jelly>
+-->
+
+<test xmlns="jelly:test">
+	
+	<echo xmlns:xx="blah">Hi Mum</echo>
+	
+</test>

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNestedExceptions.xml
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNestedExceptions.xml?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNestedExceptions.xml (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNestedExceptions.xml Sun Nov 16 14:46:49 2008
@@ -0,0 +1,60 @@
+<?xml version="1.0"?>
+	<!--
+		Licensed to the Apache Software Foundation (ASF) under one or more
+		contributor license agreements. See the NOTICE file distributed with
+		this work for additional information regarding copyright ownership.
+		The ASF licenses this file to You under the Apache License, Version
+		2.0 (the "License"); you may not use this file except in compliance
+		with the License. You may obtain a copy of the License at
+
+		http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+		applicable law or agreed to in writing, software distributed under the
+		License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+		CONDITIONS OF ANY KIND, either express or implied. See the License for
+		the specific language governing permissions and limitations under the
+		License.
+	-->
+
+<test:suite xmlns:j="jelly:core" xmlns:test="jelly:junit"
+	xmlns:define="jelly:define" xmlns:log="jelly:log">
+
+	<test:case name="nested exceptions" xmlns:my="mytaglib">
+
+		<define:taglib uri="mytaglib">
+
+			<define:tag name="mytag">
+				<j:scope>
+					<j:catch var="ex">
+						<define:invokeBody />
+					</j:catch>
+
+					<log:info>mytag ${name} after catch block exception: ${ex}</log:info>
+
+					<j:if test="${ex != null}">
+						<log:debug>exception was caught !!!</log:debug>
+						<test:fail>rethrowing the exception</test:fail>
+						<log:debug>CANNOT REACH THIS POINT !!!</log:debug>
+					</j:if>
+					<log:debug>exception was NOT caught !!!</log:debug>
+				</j:scope>
+			</define:tag>
+
+		</define:taglib>
+
+		<j:catch var="checkEx">
+			<my:mytag name="outer">
+				<my:mytag name="inner">
+					<test:fail>boom</test:fail>
+				</my:mytag>
+			</my:mytag>
+		</j:catch>
+		
+		<j:if test="${checkEx != null}">
+			<log:info>Outer exception was raised and caught - test passed</log:info>
+		</j:if>
+		<j:if test="${checkEx == null}">
+			<test:fail>Outer exception was not raised - test fails</test:fail>
+		</j:if>
+	</test:case>
+
+</test:suite>

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNewCatchTag.xml
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNewCatchTag.xml?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNewCatchTag.xml (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testNewCatchTag.xml Sun Nov 16 14:46:49 2008
@@ -0,0 +1,134 @@
+<test:suite 
+    xmlns:j="jelly:core" 
+    xmlns:test="jelly:junit">
+    <!--
+    	@author Marc Dexet marc.dexet#dsi.cnrs.fr
+    	@date 2004.11.18
+    	Test use org.apache.commons.jelly.core.ModularExceptionBean bean
+    	Set an expection and this bean will throw it with  'public void throwIt(String message) throws Throwable;' 
+    	
+    	Improvements :
+    	1. Set a list of expected exceptions as java try catch usual block
+    	2. Dissect Exception stack to get the real exception throughout the JellyTagException wrapping with 'cause' var
+    -->
+    
+    <!-- 
+    	Check regression with former tag 
+    -->
+    <test:case name="testCompatibilityWithFormerCatch">
+    	
+    	<j:new var="guiltyBean" className="org.apache.commons.jelly.core.ModularExceptionBean"/>
+    	<j:setProperties object="${guiltyBean}" exception="java.lang.NullPointerException"/>
+    	
+    	<j:catch var="e">
+    		<j:invoke on="${guiltyBean}" method="throwIt">
+    			<j:arg value="always catched"/>
+    		</j:invoke>
+			<test:fail>Exception not catched </test:fail>
+    	</j:catch>
+    	<test:assert test="${! empty(e)}"/>
+    </test:case>
+    
+
+	<!--    
+		Test with expected exception is catched by catchTag.
+		Note the cause using
+	-->
+    <test:case name="testExpectedException_1">
+    	<j:new var="guiltyBean" className="org.apache.commons.jelly.core.ModularExceptionBean"/>
+    	<j:setProperties object="${guiltyBean}" exception="java.lang.NullPointerException"/>
+    	
+    	<j:catch var="e" 
+    		exceptions="java.lang.NoClassDefFoundError;java.lang.NullPointerException"
+    		cause="cause">
+    		
+    		<j:invoke on="${guiltyBean}" method="throwIt">
+    			<j:arg value="always catched"/>
+    		</j:invoke>
+			<test:fail>Exception not catched </test:fail>
+    	</j:catch>
+    	
+    	<test:assert test="${! empty(e)}"/>
+    	<test:assert test="${cause.class.name == 'java.lang.NullPointerException'}">${cause}</test:assert>
+
+    </test:case>   
+    
+	<!--    
+		Test with exception class parenthood.
+		In this example, expected exception is "java.lang.IndexOutOfBoundsException"; 
+		thrown exception is "java.lang.ArrayIndexOutOfBoundsException" that's is a first exception extension.
+		in java, "java.lang.ArrayIndexOutOfBoundsException" will be catched in tryCatch block 
+		try {
+			// throw "ArrayIndexOutOfBoundsException"
+		} catch ( IndexOutOfBoundsException e } {
+			// catch "ArrayIndexOutOfBoundsException"
+		}
+		
+	-->
+    <test:case name="testExpectedExceptionParenthood">
+    	<j:new var="guiltyBean" className="org.apache.commons.jelly.core.ModularExceptionBean"/>
+    	<j:setProperties object="${guiltyBean}" exception="java.lang.ArrayIndexOutOfBoundsException"/>
+    	
+    	<j:catch var="e" 
+    		exceptions="java.lang.IndexOutOfBoundsException"
+    		cause="cause">
+    		
+    		<j:invoke on="${guiltyBean}" method="throwIt">
+    			<j:arg value="parent hood"/>
+    		</j:invoke>
+			<test:fail>Exception not catched </test:fail>
+    	</j:catch>
+    	
+    	<test:assert test="${! empty(e)}"/>
+    	<test:assert test="${cause.class.name == 'java.lang.ArrayIndexOutOfBoundsException'}">${cause}</test:assert>
+
+    </test:case>     
+    
+    
+    <!-- 
+    	Test unexpected exception it thrown to upper catch
+    -->
+    <test:case name="testExpectedException_throw_upper">
+    	<j:new var="guiltyBean" className="org.apache.commons.jelly.core.ModularExceptionBean"/>
+    	<j:setProperties object="${guiltyBean}" exception="java.io.FileNotFoundException"/>
+    	
+    	<j:catch var="upper">
+	    	<j:catch var="e" 
+	    		exceptionList="java.lang.NoClassDefFoundError;java.lang.NullPointerException">
+	    		
+	    		<j:invoke on="${guiltyBean}" method="throwIt">
+	    			<j:arg value="always catched"/>
+	    		</j:invoke>
+				<test:fail>Exception not catched </test:fail>
+	    	</j:catch>
+    		<test:fail>Upper has not catched exception</test:fail>
+    	</j:catch>
+    </test:case>    
+    
+    
+    <!--
+    	Test nested catch tag
+    -->
+    <test:case name="testNestedExpectedException">
+    	<j:new var="guiltyBean" className="org.apache.commons.jelly.core.ModularExceptionBean"/>
+    	<j:setProperties object="${guiltyBean}" exception="java.lang.ArithmeticException"/>
+    	
+    	<!-- top catch -->
+    	<j:catch var="e" exceptions="java.lang.ArithmeticException">
+    		<!-- upper catch -->
+    		<j:catch var="e" exceptions="java.io.FileNotFoundException;java.lang.NoSuchFieldException" >
+    			<!-- lower catch -->
+		    	<j:catch var="e" exceptions="java.lang.NoClassDefFoundError;java.lang.NullPointerException">
+		    		<j:invoke on="${guiltyBean}" method="throwIt">
+		    			<j:arg value="always catched"/>
+		    		</j:invoke>
+					<test:fail>Exception not catched ${e}</test:fail>
+		    	</j:catch>
+	    		<test:fail>Upper has not catched exception ${e}</test:fail>
+    		</j:catch>
+    		<test:fail>top has not catched exception? ${e}</test:fail>
+    	</j:catch>
+    </test:case>     
+     
+    
+</test:suite>

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testUnknownTags.xml
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testUnknownTags.xml?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testUnknownTags.xml (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/core/testUnknownTags.xml Sun Nov 16 14:46:49 2008
@@ -0,0 +1,20 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+  
+       http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<t:test xmlns:t="jelly:test">
+	<t:tag-that-does-not-exist />
+</t:test>

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestCustomExpressionFactory.java Sun Nov 16 14:46:49 2008
@@ -0,0 +1,50 @@
+package org.apache.commons.jelly.expression;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.TJTagLibrary;
+import org.apache.commons.jelly.XMLOutput;
+
+public class TestCustomExpressionFactory extends TestCase {
+	
+	private static final String EXPECTED = "id=1; attr=${TEST FACTORY:  1 + 2 }; text=${TEST FACTORY:  'hello' + \" world\" }\n" + 
+				"id=2; attr=${TEST FACTORY:  2 + 3 }; text=<sometag xmlns=\"jelly:test\">${TEST FACTORY:  'goodbye cruel' + \" world\" }</sometag>\n";
+
+	public TestCustomExpressionFactory() {
+		super("TestCustomExpressionFactory");
+	}
+	
+	public void testCustomFactory() throws Exception {
+		JellyContext ctx = new JellyContext();
+		ctx.registerTagLibrary(TJTagLibrary.NS, TJTagLibrary.class.getName());
+		
+		URL url = getClass().getResource("jelly1.xml");
+		if (url == null)
+			throw new Exception("Cannot find jelly1.xml in classpath");
+		File file = new File(url.getPath());
+		StringWriter strWriter = new StringWriter();
+		XMLOutput output = XMLOutput.createXMLOutput(strWriter);
+		ctx.runScript(file, output);
+		
+		String str = strWriter.toString();
+		System.out.println(str);
+		assertEquals(str, EXPECTED); 
+	}
+
+    public static void main(String[] args) {
+        TestRunner.run(suite());
+    }
+
+    public static Test suite() {
+        return new TestSuite(TestCustomExpressionFactory.class);
+    }
+
+}

Modified: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java?rev=718134&r1=718133&r2=718134&view=diff
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java (original)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/TestExpressions.java Sun Nov 16 14:46:49 2008
@@ -22,6 +22,8 @@
 import junit.textui.TestRunner;
 
 import org.apache.commons.jelly.JellyContext;
+import org.apache.commons.jelly.JellyException;
+import org.apache.commons.jelly.JellyTagException;
 import org.apache.commons.jelly.expression.jexl.JexlExpressionFactory;
 
 /**
@@ -35,6 +37,17 @@
     protected JellyContext context = new JellyContext();
     protected ExpressionFactory factory = new JexlExpressionFactory();
 
+    private static final class TestException extends Exception {
+		public TestException() {
+			super("Test Exception");
+		}
+    }
+    public static final class TestHelper {
+    	public Object throwAnException() throws TestException {
+    		throw new TestException();
+    	}
+    }
+
     public static void main(String[] args) {
         TestRunner.run(suite());
     }
@@ -59,6 +72,27 @@
         assertExpression("${topping}y", "cheesey");
         assertExpression("A ${topping} ${type} pizza", "A cheese deepPan pizza");
         assertExpression("${topping}-${type}", "cheese-deepPan");
+        assertExpression("$type${topping}", "$typecheese");
+        assertExpression("$type$topping", "$type$topping");
+        assertExpression("type$$topping$", "type$$topping$");
+        assertExpressionNotExpressionText("$${topping}", "${topping}");
+        assertExpressionNotExpressionText("$$type$${topping}$$", "$$type${topping}$$");
+
+        try {
+        	assertExpression("${ some junk !< 4}", true);
+        	assertTrue("An illegal expression was allowed", false);
+        }catch(JellyException e) {
+        	// Nothing, the test passed
+        }
+        context.setVariable("test", new TestHelper());
+        try {
+        	assertExpression("${test.throwAnException()}", true);
+        	assertTrue("An exception was suppressed while processing the JEXL script", false);
+        }catch(JellyTagException e) {
+        	if (!(e.getCause() instanceof TestException))
+            	throw e;
+        	// Nothing, the test passed
+        }
     }
 
     public void testAntExpresssions() throws Exception {
@@ -138,4 +172,13 @@
         String text = expression.getExpressionText();
         assertEquals( "Wrong textual representation for expression text: ", expressionText, text);
     }
+
+    protected void assertExpressionNotExpressionText(String expressionText, Object expectedValue) throws Exception {
+        Expression expression = CompositeExpression.parse(expressionText, factory);
+        assertTrue( "Created a valid expression for: " + expressionText, expression != null );
+        Object value = expression.evaluate(context);
+        assertEquals( "Wrong result for expression: " + expressionText, expectedValue, value );
+    }
+
+
 }

Added: commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml
URL: http://svn.apache.org/viewvc/commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml?rev=718134&view=auto
==============================================================================
--- commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml (added)
+++ commons/proper/jelly/trunk/src/test/org/apache/commons/jelly/expression/jelly1.xml Sun Nov 16 14:46:49 2008
@@ -0,0 +1,6 @@
+<test xmlns="jelly:test">
+	
+	<echo id="1" attr="${ 1 + 2 }">${ 'hello' + " world" }</echo>
+	<echo id="2" attr="${ 2 + 3 }"><sometag>${ 'goodbye cruel' + " world" }</sometag></echo>
+	
+</test>



Mime
View raw message