org.apache.commons.jelly.tags.junit
Class AssertThrowsTag

java.lang.Object
  extended byorg.apache.commons.jelly.TagSupport
      extended byorg.apache.commons.jelly.xpath.XPathTagSupport
          extended byorg.apache.commons.jelly.tags.junit.AssertTagSupport
              extended byorg.apache.commons.jelly.tags.junit.AssertThrowsTag
All Implemented Interfaces:
org.apache.commons.jelly.Tag

public class AssertThrowsTag
extends AssertTagSupport

Runs its body and asserts that an exception is thrown by it. If no exception is thrown the tag fails. By default all exceptions are caught. If however expected was specified the body must throw an exception of the given class, otherwise the assertion fails. The exception thrown by the body can also be of any subtype of the specified exception class. The optional var attribute can be specified if the caught exception is to be exported to a variable.


Field Summary
 
Fields inherited from class org.apache.commons.jelly.TagSupport
body, context, hasTrimmed, parent, shouldTrim
 
Constructor Summary
AssertThrowsTag()
           
 
Method Summary
 void doTag(org.apache.commons.jelly.XMLOutput output)
           
 java.lang.ClassLoader getClassLoader()
           
protected  java.lang.Class getThrowableClass()
          Returns the Class corresponding to the class specified by expected.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the class loader to be used to load the exception type
 void setExpected(java.lang.String expected)
          Sets the class name of exception expected to be thrown by the body.
 void setVar(java.lang.String var)
          Sets the variable name to define for this expression.
 
Methods inherited from class org.apache.commons.jelly.tags.junit.AssertTagSupport
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail, failNotEquals
 
Methods inherited from class org.apache.commons.jelly.xpath.XPathTagSupport
getXPathContext
 
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssertThrowsTag

public AssertThrowsTag()
Method Detail

doTag

public void doTag(org.apache.commons.jelly.XMLOutput output)
           throws org.apache.commons.jelly.JellyTagException
Throws:
org.apache.commons.jelly.JellyTagException

setExpected

public void setExpected(java.lang.String expected)
Sets the class name of exception expected to be thrown by the body. The class name must be fully qualified and can either be the expected exception class itself or any supertype of it, but must be a subtype of java.lang.Throwable.


setVar

public void setVar(java.lang.String var)
Sets the variable name to define for this expression.


setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the class loader to be used to load the exception type


getClassLoader

public java.lang.ClassLoader getClassLoader()

getThrowableClass

protected java.lang.Class getThrowableClass()
                                     throws java.lang.ClassNotFoundException
Returns the Class corresponding to the class specified by expected. If expected was either not specified then java. lang. Throwable is returned. Otherwise if the class couldn't be found or doesn't denote an exception class then an exception is thrown.

Returns:
Class The class of the exception to expect
Throws:
java.lang.ClassNotFoundException


Copyright © 2002-2006 Apache Software Foundation. All Rights Reserved.