Coverage report

  %line %branch
org.apache.commons.jelly.tags.junit.JellyAssertionFailedError
35% 
83% 

 1  
 /*
 2  
  * Copyright 2002,2004 The Apache Software Foundation.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 
 17  
 package org.apache.commons.jelly.tags.junit;
 18  
 
 19  
 import java.io.PrintStream;
 20  
 import java.io.PrintWriter;
 21  
 
 22  
 import junit.framework.AssertionFailedError;
 23  
 
 24  
 import org.apache.commons.jelly.LocationAware;
 25  
 
 26  
 /**
 27  
  * <p><code>JellyAssertionFailedError</code> is
 28  
  * a JUnit AssertionFailedError which is LocationAware so that it can include
 29  
  * details of where in the JellyUnit test case that the failure occurred.</p>
 30  
  *
 31  
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
 32  
  * @version $Revision: 1.5 $
 33  
  */
 34  
 
 35  
 public class JellyAssertionFailedError extends AssertionFailedError implements LocationAware {
 36  
 
 37  
     /** the underlying cause of the exception */
 38  
     private Throwable cause;
 39  
 
 40  
     /** the Jelly file which caused the problem */
 41  
     private String fileName;
 42  
 
 43  
     /** the tag name which caused the problem */
 44  
     private String elementName;
 45  
 
 46  
     /** the line number in the script of the error */
 47  10
     private int lineNumber = -1;
 48  
 
 49  
     /** the column number in the script of the error */
 50  10
     private int columnNumber = -1;
 51  
 
 52  0
     public JellyAssertionFailedError() {
 53  0
     }
 54  
 
 55  
     public JellyAssertionFailedError(String message) {
 56  10
         super(message);
 57  10
     }
 58  
 
 59  
     public JellyAssertionFailedError(String message, Throwable cause) {
 60  0
         super(message);
 61  0
         this.cause = cause;
 62  0
     }
 63  
 
 64  
     public JellyAssertionFailedError(Throwable cause) {
 65  0
         super(cause.getLocalizedMessage());
 66  0
         this.cause = cause;
 67  0
     }
 68  
 
 69  
     public Throwable getCause() {
 70  0
         return cause;
 71  
     }
 72  
 
 73  
 
 74  
     /**
 75  
      * @return the line number of the tag
 76  
      */
 77  
     public int getLineNumber() {
 78  10
         return lineNumber;
 79  
     }
 80  
 
 81  
     /**
 82  
      * Sets the line number of the tag
 83  
      */
 84  
     public void setLineNumber(int lineNumber) {
 85  10
         this.lineNumber = lineNumber;
 86  10
     }
 87  
 
 88  
     /**
 89  
      * @return the column number of the tag
 90  
      */
 91  
     public int getColumnNumber() {
 92  0
         return columnNumber;
 93  
     }
 94  
 
 95  
     /**
 96  
      * Sets the column number of the tag
 97  
      */
 98  
     public void setColumnNumber(int columnNumber) {
 99  10
         this.columnNumber = columnNumber;
 100  10
     }
 101  
 
 102  
     /**
 103  
      * @return the Jelly file which caused the problem
 104  
      */
 105  
     public String getFileName() {
 106  10
         return fileName;
 107  
     }
 108  
 
 109  
     /**
 110  
      * Sets the Jelly file which caused the problem
 111  
      */
 112  
     public void setFileName(String fileName) {
 113  10
         this.fileName = fileName;
 114  10
     }
 115  
 
 116  
 
 117  
     /**
 118  
      * @return the element name which caused the problem
 119  
      */
 120  
     public String getElementName() {
 121  10
         return elementName;
 122  
     }
 123  
 
 124  
     /**
 125  
      * Sets the element name which caused the problem
 126  
      */
 127  
     public void setElementName(String elementName) {
 128  10
         this.elementName = elementName;
 129  10
     }
 130  
 
 131  
 
 132  
     public String getMessage() {
 133  11
         return fileName + ":" + lineNumber + ":" + columnNumber + ": <" + elementName + "> " + super.getMessage();
 134  
     }
 135  
 
 136  
     public String getReason() {
 137  0
         return super.getMessage();
 138  
     }
 139  
 
 140  
     // #### overload the printStackTrace methods...
 141  
     public void printStackTrace(PrintWriter s) {
 142  0
         synchronized (s) {
 143  0
             super.printStackTrace(s);
 144  0
             if  (cause != null) {
 145  0
                 s.println("Root cause");
 146  0
                 cause.printStackTrace(s);
 147  
             }
 148  0
         }
 149  0
     }
 150  
 
 151  
     public void printStackTrace(PrintStream s) {
 152  0
         synchronized (s) {
 153  0
             super.printStackTrace(s);
 154  0
             if  (cause != null) {
 155  0
                 s.println("Root cause");
 156  0
                 cause.printStackTrace(s);
 157  
             }
 158  0
         }
 159  0
     }
 160  
 
 161  
     public void printStackTrace() {
 162  0
         super.printStackTrace();
 163  0
         if (cause != null) {
 164  0
             System.out.println("Root cause");
 165  0
             cause.printStackTrace();
 166  
         }
 167  0
     }
 168  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.