Home | History | Annotate | Download | only in reflect
      1 package org.apache.harmony.tests.java.lang.reflect;
      2 
      3 import junit.framework.TestCase;
      4 
      5 import java.io.EOFException;
      6 import java.lang.reflect.UndeclaredThrowableException;
      7 
      8 public class UndeclaredThrowableExceptionTests extends TestCase {
      9 
     10     private static EOFException throwable = new EOFException();
     11     private static String msg = "TEST_MSG";
     12     /**
     13      * java.lang.reflect.UndeclaredThrowableException#getCause()
     14      */
     15     public void test_getCause() throws Exception {
     16         UndeclaredThrowableException ute = new UndeclaredThrowableException(
     17                 throwable);
     18         assertSame("Wrong cause returned", throwable, ute.getCause());
     19     }
     20 
     21     /**
     22      * java.lang.reflect.UndeclaredThrowableException#getUndeclaredThrowable()
     23      */
     24     public void test_getUndeclaredThrowable() throws Exception {
     25         UndeclaredThrowableException ute = new UndeclaredThrowableException(
     26                 throwable);
     27         assertSame("Wrong undeclared throwable returned", throwable, ute
     28                 .getUndeclaredThrowable());
     29     }
     30 
     31     /**
     32      * java.lang.reflect.UndeclaredThrowableException#UndeclaredThrowableException(java.lang.Throwable)
     33      */
     34     public void test_Constructor_Throwable() throws Exception {
     35         UndeclaredThrowableException e = new UndeclaredThrowableException(
     36                 throwable);
     37         assertEquals("Wrong cause returned", throwable, e.getCause());
     38         assertEquals("Wrong throwable returned", throwable, e
     39                 .getUndeclaredThrowable());
     40     }
     41 
     42     /**
     43      * java.lang.reflect.UndeclaredThrowableException#UndeclaredThrowableException(java.lang.Throwable, java.lang.String)
     44      */
     45     public void test_Constructor_Throwable_String() throws Exception {
     46        UndeclaredThrowableException e = new UndeclaredThrowableException(
     47                 throwable, msg);
     48         assertEquals("Wrong cause returned", throwable, e.getCause());
     49         assertEquals("Wrong throwable returned", throwable, e
     50                 .getUndeclaredThrowable());
     51         assertEquals("Wrong message returned", msg, e.getMessage());
     52     }
     53 }
     54