package org.apache.ibatis.reflection;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.UndeclaredThrowableException;

public class ExceptionUtilTest {

  @Test
  public void shouldUnwrapThrowable() {
    Exception exception = new Exception();
    assertEquals(exception, ExceptionUtil.unwrapThrowable(exception));
    assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(exception, "test")));
    assertEquals(exception, ExceptionUtil.unwrapThrowable(new UndeclaredThrowableException(exception, "test")));
  }


}

@@ -646,18 +646,319 @@
 )));%0D%0A  
-%7D%0D%0A
+  assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(new InvocationTargetException(exception, %22test%22), %22test%22)));%0D%0A    assertEquals(exception, ExceptionUtil.unwrapThrowable(new InvocationTargetException(new UndeclaredThrowableException(exception, %22test%22), %22test%22)));%0D%0A  %7D
 %0D%0A%0D%0A%7D%0D%0A

test updated