org.h2.test.utils
Class AssertThrows

java.lang.Object
  extended by org.h2.test.utils.AssertThrows

public abstract class AssertThrows
extends java.lang.Object

Helper class to simplify negative testing. Usage:

 new AssertThrows() { public void test() {
     Integer.parseInt("not a number");
 }};
 


Constructor Summary
AssertThrows()
          Create a new assertion object, and call the test method to verify the expected exception is thrown.
AssertThrows(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass)
          Create a new assertion object, and call the test method to verify the expected exception is thrown.
AssertThrows(int expectedErrorCode)
          Create a new assertion object, and call the test method to verify the expected exception is thrown.
 
Method Summary
abstract  void test()
          The test method that is called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AssertThrows

public AssertThrows(java.lang.Class<? extends java.lang.Exception> expectedExceptionClass)
Create a new assertion object, and call the test method to verify the expected exception is thrown.

Parameters:
expectedExceptionClass - the expected exception class

AssertThrows

public AssertThrows()
Create a new assertion object, and call the test method to verify the expected exception is thrown.


AssertThrows

public AssertThrows(int expectedErrorCode)
Create a new assertion object, and call the test method to verify the expected exception is thrown.

Parameters:
expectedErrorCode - the error code of the exception
Method Detail

test

public abstract void test()
                   throws java.lang.Exception
The test method that is called.

Throws:
java.lang.Exception - the exception