org.apache.commons.jelly.tags.junit

## Class AssertThrowsTag

- java.lang.Object
- - org.apache.commons.jelly.TagSupport
  - - org.apache.commons.jelly.xpath.XPathTagSupport
    - - org.apache.commons.jelly.tags.junit.AssertTagSupport
      - - org.apache.commons.jelly.tags.junit.AssertThrowsTag

All Implemented Interfaces:
  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, parent`

### Constructor Summary

Constructors
Constructor and Description
`AssertThrowsTag()`

### Method Summary

Methods
`void` `doTag(XMLOutput output)` Evaluates this tag after all the tags properties have been initialized.
`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(XMLOutput output)
               throws JellyTagException

Description copied from interface: `Tag`
Evaluates this tag after all the tags properties have been initialized.

Throws:
  `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`