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/java/org/apache/commons/jelly/impl TagScript.java
Date Mon, 16 Dec 2002 10:46:43 GMT
jstrachan    2002/12/16 02:46:43

  Modified:    jelly/src/test/org/apache/commons/jelly/junit suite.jelly
               jelly/src/java/org/apache/commons/jelly/impl TagScript.java
  Log:
  Applied the new test case supplied by Todd Jonker that demonstrated the bug in missing line/col
info on a unit test case failure. 
  This bug has now been fixed as well.
  
  Revision  Changes    Path
  1.11      +5 -1      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/junit/suite.jelly
  
  Index: suite.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/junit/suite.jelly,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- suite.jelly	10 Dec 2002 08:59:42 -0000	1.10
  +++ suite.jelly	16 Dec 2002 10:46:42 -0000	1.11
  @@ -92,9 +92,13 @@
         </test:assertThrows>
       </j:catch>
       
  -		<test:assert test="${ex != null}">We should have created an exception</test:assert>
  +		<test:assert test="${ex != null}">assertThrows should fail when nothing is thrown
from within it</test:assert>
       <test:assert test="${ex.message.startsWith('No exception was thrown.')}"/>
   
  +    <test:assertEquals actual="${ex.elementName}" expected="test:assertThrows"/>
  +    <test:assert test="${ex.fileName != null}">fileName not set</test:assert>
  +    <test:assert test="${ex.lineNumber gt 0}">lineNumber not set</test:assert>
  +    <test:assert test="${ex.columnNumber gt 0}">columnNumber not set</test:assert>
     </test:case>
   
   <!--
  
  
  
  1.30      +30 -10    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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- TagScript.java	28 Nov 2002 08:35:48 -0000	1.29
  +++ TagScript.java	16 Dec 2002 10:46:42 -0000	1.30
  @@ -283,6 +283,9 @@
           catch (Exception e) {
               handleException(e);
           }
  +        catch (Error e) {
  +            handleException(e);
  +        }
       }
       
       
  @@ -632,14 +635,14 @@
        * while adding line number information etc.
        */
       protected void handleException(Exception e) throws Exception {
  -    	if (log.isTraceEnabled()) {
  -        	log.trace( "Caught exception: " + e, e );
  -    	}
  +        if (log.isTraceEnabled()) {
  +            log.trace( "Caught exception: " + e, e );
  +        }
   
           if (e instanceof LocationAware) {
               applyLocation((LocationAware) e);
           }
  -        
  +
           if ( e instanceof JellyException ) {
               e.fillInStackTrace();
               throw e;
  @@ -653,6 +656,23 @@
                                         lineNumber );
           }
   
  -        throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); 
          
  +        throw new JellyException(e, fileName, elementName, columnNumber, lineNumber);
  +    }
  +    
  +    /**
  +     * A helper method to handle this non-Jelly exception.
  +     * This method will rethrow the exception, wrapped in a JellyException
  +     * while adding line number information etc.
  +     */
  +    protected void handleException(Error e) throws Error, JellyException {
  +        if (log.isTraceEnabled()) {
  +            log.trace( "Caught exception: " + e, e );
  +        }
  +
  +        if (e instanceof LocationAware) {
  +            applyLocation((LocationAware) e);
  +        }
  +
  +        throw new JellyException(e, fileName, elementName, columnNumber, lineNumber);
       }
   }
  
  
  

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