KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > java2html > test > BasicTestCase


1 package de.java2html.test;
2
3 import junit.framework.TestCase;
4
5 /**
6  * @author Markus Gebhard
7  */

8 public abstract class BasicTestCase extends TestCase {
9   public static void assertThrowsException(Class JavaDoc expectedExceptionClass, IBlock block) {
10     try {
11       block.execute();
12       fail("Exception of type " + expectedExceptionClass + " expected."); //$NON-NLS-1$//$NON-NLS-2$
13
}
14     catch (Exception JavaDoc exception) {
15       assertTrue("Exception of type " //$NON-NLS-1$
16
+ expectedExceptionClass
17           + " expecrted, but was " //$NON-NLS-1$
18
+ exception.getClass(), expectedExceptionClass.isAssignableFrom(exception.getClass()));
19     }
20   }
21
22   public static void assertInstanceOf(Class JavaDoc expectedClass, Object JavaDoc actualObject) {
23     assertNotNull(actualObject);
24     assertTrue(expectedClass.isAssignableFrom(actualObject.getClass()));
25   }
26
27   public static interface IBlock {
28     public void execute() throws Exception JavaDoc;
29   }
30
31 }
Popular Tags