- public static void assertException(ErroneousCode aObject, Class aType) {
- try {
- aObject.run();
- throw new RuntimeException("No exception occurred");
- } catch (Throwable t) {
- if ( aType.isInstance(t)) {
- LOG.info("Expected exception occured " + t.getMessage());
- return; // ok
- }
- else {
- throw new RuntimeException(t);
- }
- }
+ public static void assertException(ErroneousCode aObject, Class aType) {
+ try {
+ aObject.run();
+ throw new RuntimeException("No exception occurred");
+ } catch (Throwable t) {
+ if (aType.isInstance(t)) {
+ LOG.info("Expected exception occured " + t.getMessage());
+
+ return; // ok
+ }
+ throw new RuntimeException(t);
+ }
+ }
+
+ public static interface ErroneousCode {
+ void run() throws Exception;