Use JUnit 4's expected exception support in BeanUtilsTests
This commit uses JUnit 4's built-in expected exception support in BeanUtilsTests, Closes gh-22354
This commit is contained in:
parent
9ac2e034e7
commit
670aa4b7ef
|
@ -47,28 +47,16 @@ import static org.junit.Assert.*;
|
||||||
*/
|
*/
|
||||||
public class BeanUtilsTests {
|
public class BeanUtilsTests {
|
||||||
|
|
||||||
@Test
|
@Test(expected = FatalBeanException.class)
|
||||||
public void testInstantiateClass() {
|
public void testInstantiateClassGivenInterface() {
|
||||||
// give proper class
|
|
||||||
BeanUtils.instantiateClass(ArrayList.class);
|
BeanUtils.instantiateClass(ArrayList.class);
|
||||||
|
|
||||||
try {
|
|
||||||
// give interface
|
|
||||||
BeanUtils.instantiateClass(List.class);
|
BeanUtils.instantiateClass(List.class);
|
||||||
fail("Should have thrown FatalBeanException");
|
|
||||||
}
|
|
||||||
catch (FatalBeanException ex) {
|
|
||||||
// expected
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
@Test(expected = FatalBeanException.class)
|
||||||
// give class without default constructor
|
public void testInstantiateClassGivenClassWithoutDefaultConstructor() {
|
||||||
|
BeanUtils.instantiateClass(ArrayList.class);
|
||||||
BeanUtils.instantiateClass(CustomDateEditor.class);
|
BeanUtils.instantiateClass(CustomDateEditor.class);
|
||||||
fail("Should have thrown FatalBeanException");
|
|
||||||
}
|
|
||||||
catch (FatalBeanException ex) {
|
|
||||||
// expected
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // gh-22531
|
@Test // gh-22531
|
||||||
|
@ -233,23 +221,14 @@ public class BeanUtilsTests {
|
||||||
assertSignatureEquals(desiredMethod, "doSomething()");
|
assertSignatureEquals(desiredMethod, "doSomething()");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test(expected = IllegalArgumentException.class)
|
||||||
public void testResolveInvalidSignature() throws Exception {
|
public void testResolveInvalidSignatureEndParen() {
|
||||||
try {
|
|
||||||
BeanUtils.resolveSignature("doSomething(", MethodSignatureBean.class);
|
BeanUtils.resolveSignature("doSomething(", MethodSignatureBean.class);
|
||||||
fail("Should not be able to parse with opening but no closing paren.");
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
// success
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void testResolveInvalidSignatureStartParen() {
|
||||||
BeanUtils.resolveSignature("doSomething)", MethodSignatureBean.class);
|
BeanUtils.resolveSignature("doSomething)", MethodSignatureBean.class);
|
||||||
fail("Should not be able to parse with closing but no opening paren.");
|
|
||||||
}
|
|
||||||
catch (IllegalArgumentException ex) {
|
|
||||||
// success
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue