Relaxed test assertion
This commit is contained in:
parent
0a4a84d357
commit
af82cbbfa9
|
|
@ -49,20 +49,22 @@ public class OnBeanConditionTypeDeductionFailureTests {
|
||||||
fail("Context refresh was successful");
|
fail("Context refresh was successful");
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Throwable beanTypeDeductionException = findBeanTypeDeductionException(ex);
|
Throwable beanTypeDeductionException = findNestedCause(ex,
|
||||||
|
BeanTypeDeductionException.class);
|
||||||
assertThat(beanTypeDeductionException)
|
assertThat(beanTypeDeductionException)
|
||||||
.hasMessage("Failed to deduce bean type for "
|
.hasMessage("Failed to deduce bean type for "
|
||||||
+ OnMissingBeanConfiguration.class.getName()
|
+ OnMissingBeanConfiguration.class.getName()
|
||||||
+ ".objectMapper");
|
+ ".objectMapper");
|
||||||
assertThat(beanTypeDeductionException)
|
assertThat(findNestedCause(beanTypeDeductionException,
|
||||||
.hasCauseInstanceOf(NoClassDefFoundError.class);
|
NoClassDefFoundError.class)).isNotNull();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Throwable findBeanTypeDeductionException(Throwable ex) {
|
private Throwable findNestedCause(Throwable ex, Class<? extends Throwable> target) {
|
||||||
Throwable candidate = ex;
|
Throwable candidate = ex;
|
||||||
while (candidate != null) {
|
while (candidate != null) {
|
||||||
if (candidate instanceof BeanTypeDeductionException) {
|
if (target.isInstance(candidate)) {
|
||||||
return candidate;
|
return candidate;
|
||||||
}
|
}
|
||||||
candidate = candidate.getCause();
|
candidate = candidate.getCause();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue