public static boolean expectedException ( final Exception actualException , final Collection < Class < ? extends Exception > > expectedExceptions ) { checkNotNull ( "actualException" , actualException ) ; if ( expectedExceptions == null || expectedExceptions . size ( ) == 0 ) { // All exceptions are expected return true ; } for ( final Class < ? extends Exception > expectedException : expectedExceptions ) { if ( expectedException . isAssignableFrom ( actualException . getClass ( ) ) ) { return true ; } } return false ; }
Verifies if an exception is of a given type .