Refine Jackson2ObjectMapperBuilder#configureFeature exception handling
This commit changes the FatalBeanException previously thrown for an IllegalArgumentException which seems more suitable for that use case. Closes gh-29859
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -81,12 +81,10 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import kotlin.ranges.IntRange;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.http.ProblemDetail;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
@@ -105,7 +103,7 @@ class Jackson2ObjectMapperBuilderTests {
|
||||
|
||||
@Test
|
||||
void unknownFeature() {
|
||||
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(() ->
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
Jackson2ObjectMapperBuilder.json().featuresToEnable(Boolean.TRUE).build());
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2022 the original author or authors.
|
||||
* Copyright 2002-2023 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -59,11 +59,10 @@ import com.fasterxml.jackson.dataformat.smile.SmileFactory;
|
||||
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.FatalBeanException;
|
||||
import org.springframework.http.ProblemDetail;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Test cases for {@link Jackson2ObjectMapperFactoryBean}.
|
||||
@@ -86,8 +85,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
@Test
|
||||
public void unknownFeature() {
|
||||
this.factory.setFeaturesToEnable(Boolean.TRUE);
|
||||
assertThatExceptionOfType(FatalBeanException.class).isThrownBy(
|
||||
this.factory::afterPropertiesSet);
|
||||
assertThatIllegalArgumentException().isThrownBy(this.factory::afterPropertiesSet);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user