Updates for 0.9.5
[debian/openrocket] / test / net / sf / openrocket / util / ReflectionTest.java
diff --git a/test/net/sf/openrocket/util/ReflectionTest.java b/test/net/sf/openrocket/util/ReflectionTest.java
new file mode 100644 (file)
index 0000000..217332b
--- /dev/null
@@ -0,0 +1,50 @@
+package net.sf.openrocket.util;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.junit.Test;
+
+public class ReflectionTest {
+
+       @Test
+       public void textHandleInvocationTargetException() {
+               Throwable cause = null;
+               
+               try {
+                       cause = new InvocationTargetException(null);
+                       Reflection.handleInvocationTargetException((InvocationTargetException)cause);
+                       fail();
+               } catch (BugException e) {
+                       assertTrue(cause == e.getCause());
+               }
+               
+               try {
+                       cause = new IllegalStateException("Test");
+                       Reflection.handleInvocationTargetException(new InvocationTargetException(cause));
+                       fail();
+               } catch (IllegalStateException e) {
+                       assertTrue(cause == e);
+               }
+               
+               try {
+                       cause = new AbstractMethodError();
+                       Reflection.handleInvocationTargetException(new InvocationTargetException(cause));
+                       fail();
+               } catch (AbstractMethodError e) { 
+                       assertTrue(cause == e);
+               }
+               
+               try {
+                       cause = new IOException();
+                       Reflection.handleInvocationTargetException(new InvocationTargetException(cause));
+                       fail();
+               } catch (BugException e) { 
+                       assertTrue(cause == e.getCause());
+               }
+               
+       }
+       
+}