Set Jackson FAIL_ON_UNKNOWN_PROPERTIES property to false by default
Issue: SPR-11891
This commit is contained in:
@@ -81,7 +81,7 @@ public class Jackson2ObjectMapperBuilderTests {
|
||||
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
|
||||
assertNotNull(objectMapper);
|
||||
assertTrue(objectMapper.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertTrue(objectMapper.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertFalse(objectMapper.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertTrue(objectMapper.isEnabled(MapperFeature.AUTO_DETECT_FIELDS));
|
||||
assertTrue(objectMapper.isEnabled(MapperFeature.AUTO_DETECT_GETTERS));
|
||||
assertTrue(objectMapper.isEnabled(MapperFeature.AUTO_DETECT_SETTERS));
|
||||
@@ -241,7 +241,7 @@ public class Jackson2ObjectMapperBuilderTests {
|
||||
|
||||
assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.AUTO_DETECT_GETTERS));
|
||||
assertTrue(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertTrue(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.AUTO_DETECT_FIELDS));
|
||||
assertFalse(objectMapper.getFactory().isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE));
|
||||
assertFalse(objectMapper.getFactory().isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES));
|
||||
|
||||
@@ -260,7 +260,7 @@ public class Jackson2ObjectMapperFactoryBeanTests {
|
||||
|
||||
assertFalse(objectMapper.getSerializationConfig().isEnabled(MapperFeature.AUTO_DETECT_GETTERS));
|
||||
assertTrue(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION));
|
||||
assertTrue(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertFalse(objectMapper.getDeserializationConfig().isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
|
||||
assertFalse(objectMapper.getDeserializationConfig().isEnabled(MapperFeature.AUTO_DETECT_FIELDS));
|
||||
assertFalse(objectMapper.getFactory().isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE));
|
||||
assertFalse(objectMapper.getFactory().isEnabled(JsonGenerator.Feature.QUOTE_FIELD_NAMES));
|
||||
|
||||
@@ -146,12 +146,13 @@ public class MappingJackson2HttpMessageConverterTests {
|
||||
converter.read(MyBean.class, inputMessage);
|
||||
}
|
||||
|
||||
@Test(expected = HttpMessageNotReadableException.class)
|
||||
@Test
|
||||
public void readValidJsonWithUnknownProperty() throws IOException {
|
||||
String body = "{\"string\":\"string\",\"unknownProperty\":\"value\"}";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "json"));
|
||||
converter.read(MyBean.class, inputMessage);
|
||||
// Assert no HttpMessageNotReadableException is thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -102,12 +102,13 @@ public class MappingJackson2XmlHttpMessageConverterTests {
|
||||
converter.read(MyBean.class, inputMessage);
|
||||
}
|
||||
|
||||
@Test(expected = HttpMessageNotReadableException.class)
|
||||
@Test
|
||||
public void readValidXmlWithUnknownProperty() throws IOException {
|
||||
String body = "<MyBean><string>string</string><unknownProperty>value</unknownProperty></MyBean>";
|
||||
MockHttpInputMessage inputMessage = new MockHttpInputMessage(body.getBytes("UTF-8"));
|
||||
inputMessage.getHeaders().setContentType(new MediaType("application", "xml"));
|
||||
converter.read(MyBean.class, inputMessage);
|
||||
// Assert no HttpMessageNotReadableException is thrown
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user