release 0.9.6
[debian/openrocket] / test / net / sf / openrocket / util / ReflectionTest.java
1 package net.sf.openrocket.util;
2
3 import static org.junit.Assert.*;
4
5 import java.io.IOException;
6 import java.lang.reflect.InvocationTargetException;
7
8 import org.junit.Test;
9
10 public class ReflectionTest {
11
12         @Test
13         public void textHandleInvocationTargetException() {
14                 Throwable cause = null;
15                 
16                 try {
17                         cause = new InvocationTargetException(null);
18                         Reflection.handleWrappedException((InvocationTargetException)cause);
19                         fail();
20                 } catch (BugException e) {
21                         assertTrue(cause == e.getCause());
22                 }
23                 
24                 try {
25                         cause = new IllegalStateException("Test");
26                         Reflection.handleWrappedException(new InvocationTargetException(cause));
27                         fail();
28                 } catch (IllegalStateException e) {
29                         assertTrue(cause == e);
30                 }
31                 
32                 try {
33                         cause = new AbstractMethodError();
34                         Reflection.handleWrappedException(new InvocationTargetException(cause));
35                         fail();
36                 } catch (AbstractMethodError e) { 
37                         assertTrue(cause == e);
38                 }
39                 
40                 try {
41                         cause = new IOException();
42                         Reflection.handleWrappedException(new InvocationTargetException(cause));
43                         fail();
44                 } catch (BugException e) { 
45                         assertTrue(cause == e.getCause());
46                 }
47                 
48         }
49         
50 }