Merge pull request #19 from eugenp/master

update
This commit is contained in:
Maiklins 2020-01-20 21:51:42 +01:00 committed by GitHub
commit 1200d8777a
4 changed files with 33 additions and 3 deletions

View File

@ -0,0 +1,7 @@
package com.baeldung.reflection.exception.invocationtarget;
public class InvocationTargetExample {
public int divideByZeroExample() {
return 1 / 0;
}
}

View File

@ -0,0 +1,23 @@
package com.baeldung.reflection.exception.invocationtarget;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.junit.jupiter.api.Test;
public class InvocationTargetUnitTest {
@Test
public void whenCallingMethodThrowsException_thenAssertCauseOfInvocationTargetException() throws Exception {
InvocationTargetExample targetExample = new InvocationTargetExample();
Method method = InvocationTargetExample.class.getMethod("divideByZeroExample");
Exception exception = assertThrows(InvocationTargetException.class, () -> method.invoke(targetExample));
assertEquals(ArithmeticException.class, exception.getCause().getClass());
}
}

View File

@ -814,7 +814,7 @@
<module>spring-rest-shell</module>
<module>spring-rest-simple</module>
<module>spring-resttemplate</module>
<!-- <module>spring-roo</module>-->
<module>spring-roo</module>
<module>spring-scheduling</module>
<module>spring-security-modules/spring-security-acl</module>
<module>spring-security-modules/spring-security-angular/server</module>
@ -1416,7 +1416,7 @@
<module>spring-rest-shell</module>
<module>spring-rest-simple</module>
<module>spring-resttemplate</module>
<!-- <module>spring-roo</module>-->
<module>spring-roo</module>
<module>spring-scheduling</module>
<module>spring-security-modules/spring-security-acl</module>

View File

@ -413,7 +413,7 @@
<repository>
<id>spring-roo-repository</id>
<name>Spring Roo Repository</name>
<url>http://repo.spring.io/spring-roo</url>
<url>https://repo.spring.io/spring-roo</url>
</repository>
</repositories>