-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add JsonMapper.builderWithJackson2Defaults()
#5004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
71e8735
32d89cd
3f7a837
a6de4d5
27702b8
b89d580
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package tools.jackson.databind.json; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import tools.jackson.core.StreamReadFeature; | ||
import tools.jackson.core.json.JsonFactory; | ||
import tools.jackson.core.json.JsonWriteFeature; | ||
import tools.jackson.databind.DeserializationFeature; | ||
import tools.jackson.databind.ObjectMapper; | ||
import tools.jackson.databind.SerializationFeature; | ||
import tools.jackson.databind.testutil.DatabindTestUtil; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
// Test(s) to verify behaviors in JsonMapper.Builder | ||
public class JsonMapperBuilderTest extends DatabindTestUtil | ||
{ | ||
|
||
@Test | ||
public void testBuilderWithJackson2Defaults() | ||
{ | ||
ObjectMapper mapper = JsonMapper.builderWithJackson2Defaults().build(); | ||
JsonFactory jsonFactory = (JsonFactory) mapper.tokenStreamFactory(); | ||
assertFalse(mapper.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should also not verify streaming-level setting at databind level. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. People who want max Jackson2 compatibility will want mapper and factory level Jackson2-like config. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but it must be done at correct level -- streaming at streaming, databind at databind. Not with overlap. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. JsonMapper.builderWithJackson2Defaults() is a high level method that creates a factory for you. I have modified the lower level configureForJackson2 methods not to set factory level configs. |
||
assertFalse(mapper.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)); | ||
assertFalse(jsonFactory.isEnabled(JsonWriteFeature.ESCAPE_FORWARD_SLASHES)); | ||
assertFalse(jsonFactory.isEnabled(JsonWriteFeature.COMBINE_UNICODE_SURROGATES_IN_UTF8)); | ||
assertTrue(mapper.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)); | ||
assertTrue(mapper.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)); | ||
assertTrue(mapper.isEnabled(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)); | ||
assertFalse(mapper.isEnabled(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)); | ||
assertTrue(mapper.isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)); | ||
assertFalse(mapper.isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)); | ||
assertFalse(mapper.isEnabled(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)); | ||
assertFalse(mapper.isEnabled(DeserializationFeature.READ_ENUMS_USING_TO_STRING)); | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.