aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/com/fasterxml/jackson
diff options
context:
space:
mode:
authorTatu Saloranta <tatu.saloranta@iki.fi>2020-07-02 15:05:26 -0700
committerTatu Saloranta <tatu.saloranta@iki.fi>2020-07-02 15:05:26 -0700
commitd16b8b1e0c70707ec294e4b0515ac316491ac24e (patch)
tree49718ca036431c88d74a8e10a959a04c85569be2 /src/test/java/com/fasterxml/jackson
parent94728344a3f7f1e4127301554a55456b53814cc3 (diff)
downloadjackson-databind-d16b8b1e0c70707ec294e4b0515ac316491ac24e.tar.gz
Add failing tests for #2783
Diffstat (limited to 'src/test/java/com/fasterxml/jackson')
-rw-r--r--src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java61
1 files changed, 52 insertions, 9 deletions
diff --git a/src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java b/src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java
index 3e224d7a6..794ee0366 100644
--- a/src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java
@@ -26,6 +26,12 @@ public class ObjectReaderTest extends BaseMapTest
public Map<String, Object> name;
}
+ /*
+ /**********************************************************
+ /* Test methods, simple read/write with defaults
+ /**********************************************************
+ */
+
public void testSimpleViaParser() throws Exception
{
final String JSON = "[1]";
@@ -89,6 +95,22 @@ public class ObjectReaderTest extends BaseMapTest
assertEquals(Collections.singletonMap("key", ABC.B), value);
}
+ public void testNodeHandling() throws Exception
+ {
+ JsonNodeFactory nodes = new JsonNodeFactory(true);
+ ObjectReader r = MAPPER.reader().with(nodes);
+ // but also no further changes if attempting again
+ assertSame(r, r.with(nodes));
+ assertTrue(r.createArrayNode().isArray());
+ assertTrue(r.createObjectNode().isObject());
+ }
+
+ /*
+ /**********************************************************
+ /* Test methods, some alternative JSON settings
+ /**********************************************************
+ */
+
public void testParserFeaturesComments() throws Exception
{
final String JSON = "[ /* foo */ 7 ]";
@@ -140,15 +162,11 @@ public class ObjectReaderTest extends BaseMapTest
assertEquals(1, result.size());
}
- public void testNodeHandling() throws Exception
- {
- JsonNodeFactory nodes = new JsonNodeFactory(true);
- ObjectReader r = MAPPER.reader().with(nodes);
- // but also no further changes if attempting again
- assertSame(r, r.with(nodes));
- assertTrue(r.createArrayNode().isArray());
- assertTrue(r.createObjectNode().isObject());
- }
+ /*
+ /**********************************************************
+ /* Test methods, config setting verification
+ /**********************************************************
+ */
public void testFeatureSettings() throws Exception
{
@@ -268,6 +286,31 @@ public class ObjectReaderTest extends BaseMapTest
assertEquals(MAPPER.constructType(String.class), r.getValueType());
}
+ public void testParserConfigViaMapper() throws Exception
+ {
+ try (JsonParser p = MAPPER.reader()
+ .with(StreamReadFeature.STRICT_DUPLICATE_DETECTION)
+ .createParser("[ ]")) {
+ assertTrue(p.isEnabled(StreamReadFeature.STRICT_DUPLICATE_DETECTION));
+ }
+
+ try (JsonParser p = MAPPER.reader()
+ .with(JsonReadFeature.ALLOW_JAVA_COMMENTS)
+ .createParser("[ ]")) {
+ assertTrue(p.isEnabled(JsonReadFeature.ALLOW_JAVA_COMMENTS.mappedFeature()));
+ }
+ }
+
+ public void testGeneratorConfigViaMapper() throws Exception
+ {
+ StringWriter sw = new StringWriter();
+ try (JsonGenerator g = MAPPER.writer()
+ .with(StreamWriteFeature.IGNORE_UNKNOWN)
+ .createGenerator(sw)) {
+ assertTrue(g.isEnabled(StreamWriteFeature.IGNORE_UNKNOWN));
+ }
+ }
+
/*
/**********************************************************
/* Test methods, JsonPointer