diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasicTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasicTest.java
index 50a32dd7..9a385feb 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasicTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasicTest.java
@@ -2,6 +2,7 @@
import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
@@ -13,7 +14,7 @@ public class XsiNilBasicTest extends XmlTestUtil
{
private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
- protected static class DoubleWrapper {
+ public static class DoubleWrapper {
public Double d;
public DoubleWrapper() { }
@@ -22,14 +23,17 @@ public DoubleWrapper(Double value) {
}
}
- protected static class DoubleWrapper2 {
+ public static class DoubleWrapper2 {
public Double a = 100.0; // init to ensure it gets overwritten
public Double b = 200.0;
public DoubleWrapper2() { }
}
- private final XmlMapper MAPPER = newMapper();
+ // 30-Jan-2025, tatu: To tease out [dataformat-xml#714] let's do this:
+ private final XmlMapper MAPPER = mapperBuilder()
+ .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
+ .build();
@Test
public void testWithDoubleAsNull() throws Exception
@@ -94,6 +98,8 @@ public void testWithDoubleAsMixed() throws Exception
assertEquals(defaultValue.b, bean.b);
}
+ // [dataformat-xml#714]: trailing END_OBJECT
+ /*
@Test
public void testRootPojoAsNull() throws Exception
{
@@ -102,6 +108,7 @@ public void testRootPojoAsNull() throws Exception
Point.class);
assertNull(bean);
}
+ */
@Test
public void testRootPojoAsNonNull() throws Exception
@@ -142,6 +149,8 @@ public void testDisableXsiNilLeafProcessing() throws Exception
// [dataformat-xml#468]: Allow disabling xsi:nil special handling
+ // [dataformat-xml#714]: trailing END_OBJECT
+ /*
@Test
public void testDisableXsiNilRootProcessing() throws Exception
{
@@ -153,10 +162,10 @@ public void testDisableXsiNilRootProcessing() throws Exception
// 07-Jul-2021, tatu: Alas! 2.x sets format feature flags too late to
// affect root element (3.0 works correctly). So cannot test
-/*
+
ObjectReader noXsiNilReader = r.without(FromXmlParser.Feature.PROCESS_XSI_NIL);
assertEquals(a2q("{'nil':'true'}"),
noXsiNilReader.readValue(DOC).toString());
- */
}
+ */
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XsiNilBasic714Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XsiNilBasic714Test.java
new file mode 100644
index 00000000..d7ac244a
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XsiNilBasic714Test.java
@@ -0,0 +1,55 @@
+package com.fasterxml.jackson.dataformat.xml.tofix;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class XsiNilBasic714Test extends XmlTestUtil
+{
+ private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
+
+ // 30-Jan-2025, tatu: To tease out [dataformat-xml#714] let's do this:
+ private final XmlMapper MAPPER = mapperBuilder()
+ .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
+ .build();
+
+ // [dataformat-xml#714]: trailing END_OBJECT
+ @JacksonTestFailureExpected
+ @Test
+ public void testRootPojoAsNull() throws Exception
+ {
+ Point bean = MAPPER.readValue(
+"",
+ Point.class);
+ assertNull(bean);
+ }
+
+ // [dataformat-xml#468]: Allow disabling xsi:nil special handling
+
+ // [dataformat-xml#714]: trailing END_OBJECT
+ @JacksonTestFailureExpected
+ @Test
+ public void testDisableXsiNilRootProcessing() throws Exception
+ {
+ final ObjectReader r = MAPPER.readerFor(JsonNode.class);
+ final String DOC = "";
+
+ // with default processing:
+ assertEquals("null", r.readValue(DOC).toString());
+
+ // 07-Jul-2021, tatu: Alas! 2.x sets format feature flags too late to
+ // affect root element (3.0 works correctly). So cannot test
+
+ ObjectReader noXsiNilReader = r.without(FromXmlParser.Feature.PROCESS_XSI_NIL);
+ assertEquals(a2q("{'nil':'true'}"),
+ noXsiNilReader.readValue(DOC).toString());
+ }
+}