org.fest.assertions.api
Class ThrowableAssert

java.lang.Object
  extended by org.fest.assertions.api.AbstractAssert<ThrowableAssert,Throwable>
      extended by org.fest.assertions.api.ThrowableAssert
All Implemented Interfaces:
Assert<ThrowableAssert,Throwable>, Descriptable<ThrowableAssert>, ExtensionPoints<ThrowableAssert,Throwable>

public class ThrowableAssert
extends AbstractAssert<ThrowableAssert,Throwable>

Assertion methods for Throwables.

To create a new instance of this class, invoke Assertions.assertThat(Throwable).

Author:
David DIDIER, Alex Ruiz, Joel Costigliola

Field Summary
 
Fields inherited from class org.fest.assertions.api.AbstractAssert
actual, myself
 
Constructor Summary
protected ThrowableAssert(Throwable actual)
           
 
Method Summary
 ThrowableAssert hasMessage(String message)
          Verifies that the message of the actual Throwable is equal to the given one.
 ThrowableAssert hasMessageContaining(String description)
          Verifies that the message of the actual Throwable contains with the given description.
 ThrowableAssert hasMessageEndingWith(String description)
          Verifies that the message of the actual Throwable ends with the given description.
 ThrowableAssert hasMessageStartingWith(String description)
          Verifies that the message of the actual Throwable starts with the given description.
 ThrowableAssert hasNoCause()
          Verifies that the actual Throwable does not have a cause.
 ThrowableAssert isExactlyInstanceOf(Class<? extends Throwable> type)
          Verifies that the actual Throwable is an instance of the given type.
 ThrowableAssert isInstanceOf(Class<? extends Throwable> type)
          Verifies that the actual Throwable is an instance of the given type.
 
Methods inherited from class org.fest.assertions.api.AbstractAssert
as, as, describedAs, describedAs, descriptionText, doesNotHave, equals, has, hashCode, is, isEqualTo, isIn, isIn, isNot, isNotEqualTo, isNotIn, isNotIn, isNotNull, isNotSameAs, isNull, isSameAs, usingComparator, usingDefaultComparator
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThrowableAssert

protected ThrowableAssert(Throwable actual)
Method Detail

isInstanceOf

public ThrowableAssert isInstanceOf(Class<? extends Throwable> type)
Verifies that the actual Throwable is an instance of the given type.

Parameters:
type - the type to check the actual Throwable against.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the actual Throwable is not an instance of the given type.
NullPointerException - if the given type is null.

isExactlyInstanceOf

public ThrowableAssert isExactlyInstanceOf(Class<? extends Throwable> type)
Verifies that the actual Throwable is an instance of the given type. In order for the assertion to pass, the type of the actual Throwable has to be exactly the same as the given type.

Parameters:
type - the type to check the actual Throwable against.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the actual Throwable is not an instance of the given type.
NullPointerException - if the given type is null.

hasMessage

public ThrowableAssert hasMessage(String message)
Verifies that the message of the actual Throwable is equal to the given one.

Parameters:
message - the expected message.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the message of the actual Throwable is not equal to the given one.

hasNoCause

public ThrowableAssert hasNoCause()
Verifies that the actual Throwable does not have a cause.

Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the actual Throwable has a cause.

hasMessageStartingWith

public ThrowableAssert hasMessageStartingWith(String description)
Verifies that the message of the actual Throwable starts with the given description.

Parameters:
description - the description expected to start the actual Throwable's message.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the message of the actual Throwable does not start with the given description.

hasMessageContaining

public ThrowableAssert hasMessageContaining(String description)
Verifies that the message of the actual Throwable contains with the given description.

Parameters:
description - the description expected to be contained in the actual Throwable's message.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the message of the actual Throwable does not contain the given description.

hasMessageEndingWith

public ThrowableAssert hasMessageEndingWith(String description)
Verifies that the message of the actual Throwable ends with the given description.

Parameters:
description - the description expected to end the actual Throwable's message.
Returns:
this assertion object.
Throws:
AssertionError - if the actual Throwable is null.
AssertionError - if the message of the actual Throwable does not end with the given description.


Copyright © 2007-2012 FEST (Fixtures for Easy Software Testing). All Rights Reserved.