subtypes, PolymorphicTypeValidator ptv)
{
- super(baseType, typeFactory, ptv);
+ super(baseType, typeFactory, subtypes, ptv);
}
@Override
diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java
index 8bb339689..ccdf5889c 100644
--- a/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java
+++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/FromXmlParser.java
@@ -67,6 +67,9 @@ public enum Feature implements FormatFeature
* matching {@code ToXmlGenerator.Feature#AUTO_DETECT_XSI_TYPE} feature,
* usually used for Polymorphic handling where it is difficult
* to specify proper XML Namespace for type identifier.
+ *
+ * Default setting is {@code false} in Jackson 2.x (for backwards compatibility):
+ * will be changed to true in Jackson 3.x
*
* @since 2.17
*/
@@ -79,7 +82,7 @@ public enum Feature implements FormatFeature
* returned as `null` tokens, they will be returned as {@link JsonToken#VALUE_STRING}
* tokens with textual value of "" (empty String).
*
- * Default setting was {@code true} (for backwards compatibility from 2.9 to 2.11 (inclusive)
+ * Default setting was {@code true} (for backwards compatibility) from 2.9 to 2.11 (inclusive)
* but was changed in 2.12 to be {@code false} (see [dataformat-xml#411] for details)
*
* @since 2.9
@@ -250,7 +253,7 @@ private Feature(boolean defaultState) {
*/
/**
- * Bitfield that indicates which numeric representations
+ * Bit field that indicates which numeric representations
* have been calculated for the current type
*/
protected int _numTypesValid = NR_UNKNOWN;
@@ -294,6 +297,8 @@ public FromXmlParser(IOContext ctxt, int genericParserFeatures, int xmlFeatures,
// changed in 2.10.2
if (_xmlTokens.hasXsiNil()) {
_nextToken = JsonToken.VALUE_NULL;
+ // 21-Apr-2025, tatu: [dataformat-xml#714] Must "flush" the stream
+ _xmlTokens.markAsStreamEnd();
} else {
switch (firstToken) {
case XmlTokenStream.XML_START_ELEMENT:
@@ -516,6 +521,10 @@ public void close() throws IOException
{
if (!_closed) {
_closed = true;
+ // 30-May-2025, tatu: was missing before 2.20
+ if (JsonParser.Feature.CLEAR_CURRENT_TOKEN_ON_CLOSE.enabledIn(_features)) {
+ _currToken = null;
+ }
try {
if (_ioContext.isResourceManaged() || isEnabled(JsonParser.Feature.AUTO_CLOSE_SOURCE)) {
_xmlTokens.closeCompletely();
@@ -686,16 +695,16 @@ public JsonToken nextToken() throws IOException
{
JsonToken t = nextToken0();
if (t != null) {
- final String loc = (_parsingContext == null) ? "NULL" : String.valueOf(_parsingContext.pathAsPointer());
+ final String loc = (_parsingContext == null) ? "" : "'"+String.valueOf(_parsingContext.pathAsPointer())+"'";
switch (t) {
case FIELD_NAME:
- System.out.printf("FromXmlParser.nextToken() at '%s': JsonToken.FIELD_NAME '%s'\n", loc, _parsingContext.currentName());
+ System.out.printf("FromXmlParser.nextToken() at %s: JsonToken.FIELD_NAME '%s'\n", loc, _parsingContext.getCurrentName());
break;
case VALUE_STRING:
- System.out.printf("FromXmlParser.nextToken() at '%s': JsonToken.VALUE_STRING '%s'\n", loc, getText());
+ System.out.printf("FromXmlParser.nextToken() at %s: JsonToken.VALUE_STRING '%s'\n", loc, getText());
break;
default:
- System.out.printf("FromXmlParser.nextToken() at '%s': %s\n", loc, t);
+ System.out.printf("FromXmlParser.nextToken() at %s: %s\n", loc, t);
}
}
return t;
diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlTokenStream.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlTokenStream.java
index 8e1320165..2a7c78be4 100644
--- a/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlTokenStream.java
+++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/deser/XmlTokenStream.java
@@ -269,9 +269,6 @@ public int next() throws XMLStreamException
case XML_START_ELEMENT:
System.out.printf(" XmlTokenStream.next(): XML_START_ELEMENT '%s' %s\n", _localName, _loc());
break;
- case XML_DELAYED_START_ELEMENT:
- System.out.printf(" XmlTokenStream.next(): XML_DELAYED_START_ELEMENT '%s' %s\n", _localName, _loc());
- break;
case XML_END_ELEMENT:
// 24-May-2020, tatu: no name available for end element so do not print
System.out.printf(" XmlTokenStream.next(): XML_END_ELEMENT %s\n", _loc());
@@ -406,6 +403,16 @@ protected void pushbackCurrentToken()
_repeatCurrentToken = true;
}
+ /**
+ * Method that can be called to mark stream as having reached end of stream.
+ *
+ * @since 2.19
+ */
+ protected void markAsStreamEnd()
+ {
+ _currentState = XML_END;
+ }
+
/**
* Method called to skip any attributes current START_ELEMENT may have,
* so that they are not returned as token.
@@ -460,6 +467,7 @@ private final int _next() throws XMLStreamException
// 08-Jul-2021, tatu: as per [dataformat-xml#467] just skip anything
// element might have, no need to ensure it was empty
_xmlReader.skipElement();
+//System.out.println(" XmlTokenStream._next(): Got xsi:nil, skipping element");
return _handleEndElement();
}
if (_nextAttributeIndex < _attributeCount) {
@@ -693,7 +701,7 @@ private final void _checkXsiAttributes() {
int count = _xmlReader.getAttributeCount();
_attributeCount = count;
- // [dataformat-xml#354]: xsi:nul handling; at first only if first attribute
+ // [dataformat-xml#354]: xsi:nil handling; at first only if first attribute
if (count >= 1) {
// [dataformat-xml#468]: may disable xsi:nil processing
if (_cfgProcessXsiNil
@@ -703,6 +711,7 @@ private final void _checkXsiAttributes() {
_nextAttributeIndex = 1;
// but only mark as nil marker if enabled
_xsiNilFound = "true".equals(_xmlReader.getAttributeValue(0));
+//System.out.println(" XMLTokenStream._checkXsiAttributes(), _xsiNilFound: "+_xsiNilFound);
return;
}
}
@@ -813,6 +822,8 @@ private final int _handleEndElement()
}
} else {
+//System.out.println(" XMLTokenStream._handleEndElement(): no wrapper");
+
// Not (necessarily) known, as per above, so:
_localName = "";
_namespaceURI = "";
diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/ToXmlGenerator.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/ToXmlGenerator.java
index 7721faebe..ebe4a07d3 100644
--- a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/ToXmlGenerator.java
+++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/ToXmlGenerator.java
@@ -51,6 +51,15 @@ public enum Feature implements FormatFeature
*/
WRITE_XML_DECLARATION(false),
+ /**
+ * Feature that controls whether XML declaration should include the standalone attribute
+ * when generator is initialized (true) or not (false). Only honored when
+ * {@link Feature#WRITE_XML_DECLARATION WRITE_XML_DECLARATION} is enabled
+ *
+ * @since 2.19
+ */
+ WRITE_STANDALONE_YES_TO_XML_DECLARATION(false),
+
/**
* Feature that controls whether output should be done as XML 1.1; if so,
* certain aspects may differ from default (1.0) processing: for example,
@@ -70,7 +79,8 @@ public enum Feature implements FormatFeature
* If enabled, `xsi:nil` attribute will be added to the empty element; if disabled,
* it will not.
*
- * Feature is disabled by default for backwards compatibility.
+ * Default setting is {@code disabled} in Jackson 2.x for backwards compatibility:
+ * but will be changed in 3.0 to {@code enabled}.
*
* @since 2.10
*/
@@ -88,7 +98,7 @@ public enum Feature implements FormatFeature
* configured, or {@code ObjectNode} otherwise).
*
* Default setting is {@code disabled} in Jackson 2.x, for backwards compatibility:
- * likely to be changed in 3.0 to {@code enabled}.
+ * but will be changed in 3.0 to {@code enabled}.
*
* @since 2.13
*/
@@ -102,6 +112,9 @@ public enum Feature implements FormatFeature
* and output is indicated to be done as XML Attribute.
* This is mostly desirable for Polymorphic handling where it is difficult
* to specify XML Namespace for type identifier
+ *
+ * Default setting is {@code disabled} in Jackson 2.x for backwards compatibility:
+ * but will be changed in 3.0 to {@code enabled}.
*
* @since 2.17
*/
@@ -132,7 +145,8 @@ public enum Feature implements FormatFeature
* so there is no corresponding
* {@link com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature}.
*
- * Feature is disabled by default for backwards compatibility.
+ * Feature is {@code disabled} by default in Jackson 2.x for backwards compatibility:
+ * but will be changed in 3.0 to {@code enabled}.
*
* @since 2.17
*/
@@ -292,15 +306,24 @@ public void initGenerator() throws IOException
_initialized = true;
try {
boolean xmlDeclWritten;
- if (Feature.WRITE_XML_1_1.enabledIn(_formatFeatures)) {
- _xmlWriter.writeStartDocument("UTF-8", "1.1");
- xmlDeclWritten = true;
- } else if (Feature.WRITE_XML_DECLARATION.enabledIn(_formatFeatures)) {
- _xmlWriter.writeStartDocument("UTF-8", "1.0");
+
+ if (Feature.WRITE_XML_1_1.enabledIn(_formatFeatures) ||
+ Feature.WRITE_XML_DECLARATION.enabledIn(_formatFeatures)) {
+
+ String xmlVersion = Feature.WRITE_XML_1_1.enabledIn(_formatFeatures) ? "1.1" : "1.0";
+ String encoding = "UTF-8";
+
+ if (Feature.WRITE_STANDALONE_YES_TO_XML_DECLARATION.enabledIn(_formatFeatures)) {
+ _xmlWriter.writeStartDocument(xmlVersion, encoding, true);
+ } else {
+ _xmlWriter.writeStartDocument(encoding, xmlVersion);
+ }
+
xmlDeclWritten = true;
} else {
xmlDeclWritten = false;
}
+
// as per [dataformat-xml#172], try adding indentation
if (xmlDeclWritten && (_xmlPrettyPrinter != null)) {
// ... but only if it is likely to succeed:
diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializer.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializer.java
index b3335d201..5967a764b 100644
--- a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializer.java
+++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializer.java
@@ -96,7 +96,6 @@ protected BeanSerializerBase asArraySerializer()
* - have any getter
*/
if ((_objectIdWriter == null)
- && (_anyGetterWriter == null)
&& (_propertyFilterId == null)
) {
return new BeanAsArraySerializer(this);
diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializerBase.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializerBase.java
index 20acd0e08..12ce6b36d 100644
--- a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializerBase.java
+++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlBeanSerializerBase.java
@@ -218,12 +218,6 @@ protected void serializeFields(Object bean, JsonGenerator gen0, SerializerProvid
xgen.setNextIsUnwrapped(false);
}
}
- if (_anyGetterWriter != null) {
- // For [#117]: not a clean fix, but with @JsonTypeInfo, we'll end up
- // with accidental attributes otherwise
- xgen.setNextIsAttribute(false);
- _anyGetterWriter.getAndSerialize(bean, xgen, provider);
- }
} catch (Exception e) {
String name = (i == props.length) ? "[anySetter]" : props[i].getName();
wrapAndThrow(provider, e, bean, name);
@@ -300,13 +294,6 @@ protected void serializeFieldsFiltered(Object bean, JsonGenerator gen0,
xgen.setNextIsUnwrapped(false);
}
}
- if (_anyGetterWriter != null) {
- // For [#117]: not a clean fix, but with @JsonTypeInfo, we'll end up
- // with accidental attributes otherwise
- xgen.setNextIsAttribute(false);
- // 24-Jul-2019, tatu: Fixed for [dataformat-xml#351]
- _anyGetterWriter.getAndFilter(bean, xgen, provider, filter);
- }
} catch (Exception e) {
String name = (i == props.length) ? "[anySetter]" : props[i].getName();
wrapAndThrow(provider, e, bean, name);
diff --git a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlSerializerProvider.java b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlSerializerProvider.java
index 7a2d3d78c..ffc0a18ae 100644
--- a/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlSerializerProvider.java
+++ b/src/main/java/com/fasterxml/jackson/dataformat/xml/ser/XmlSerializerProvider.java
@@ -315,7 +315,7 @@ protected void _serializeUnwrappedObjectNode(ToXmlGenerator xgen, Object value,
JsonSerializer ser) throws IOException
{
ObjectNode root = (ObjectNode) value;
- Map.Entry entry = root.fields().next();
+ Map.Entry entry = root.properties().iterator().next();
final JsonNode newRoot = entry.getValue();
// No namespace associated with JsonNode:
diff --git a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/jdk17/Java17CollectionsTest.java b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/jdk17/Java17CollectionsTest.java
index 8e88837bd..bd529d225 100644
--- a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/jdk17/Java17CollectionsTest.java
+++ b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/jdk17/Java17CollectionsTest.java
@@ -1,16 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.jdk17;
+import org.junit.jupiter.api.Test;
+
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class Java17CollectionsTest extends XmlTestBase
+public class Java17CollectionsTest extends XmlTestUtil
{
private final XmlMapper _xmlMapper = new XmlMapper();
+ @Test
public void testStreamOf()
throws Exception
{
diff --git a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/XmlEmptyRecordDeser508Test.java b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/XmlEmptyRecordDeser508Test.java
new file mode 100644
index 000000000..1763deedb
--- /dev/null
+++ b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/XmlEmptyRecordDeser508Test.java
@@ -0,0 +1,29 @@
+package com.fasterxml.jackson.dataformat.xml.records;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+// [dataformat-xml#508]
+public class XmlEmptyRecordDeser508Test extends XmlTestUtil
+{
+ static class EmptyClass508 {
+ }
+
+ public record EmptyRecord508() {
+ }
+
+ private final XmlMapper MAPPER = new XmlMapper();
+
+ @Test
+ public void testEmptyPOJO() throws Exception {
+ assertNotNull(MAPPER.readValue(" ", EmptyClass508.class));
+ }
+
+ @Test
+ public void testEmptyRecord() throws Exception {
+ assertNotNull(MAPPER.readValue(" ", EmptyRecord508.class));
+ }
+}
diff --git a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlRecordDeser734Test.java b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlRecordDeser734Test.java
index 34fd96fbc..be9ffd3bf 100644
--- a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlRecordDeser734Test.java
+++ b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlRecordDeser734Test.java
@@ -1,25 +1,24 @@
package com.fasterxml.jackson.dataformat.xml.records.failing;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
// [dataformat-xml#734]
-public class XmlRecordDeser734Test extends XmlTestBase
+public class XmlRecordDeser734Test extends XmlTestUtil
{
-
record Amount(@JacksonXmlText String value,
@JacksonXmlProperty(isAttribute = true, localName = "Ccy") String currency) {}
private final String XML =
a2q("1 ");
- //@JacksonTestFailureExpected
+ @JacksonTestFailureExpected
@Test
public void testDeser() throws Exception {
XmlMapper mapper = new XmlMapper();
diff --git a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlWrapperRecord517Test.java b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlWrapperRecord517Test.java
index b4f953cf6..aa632fe68 100644
--- a/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlWrapperRecord517Test.java
+++ b/src/test-jdk17/java/com/fasterxml/jackson/dataformat/xml/records/failing/XmlWrapperRecord517Test.java
@@ -2,18 +2,20 @@
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
// [databind#517] XML wrapper doesn't work with java records
// Equivalent to on in jdk17/.../deser/XmlWrapperRecord517Test.java
public class XmlWrapperRecord517Test
- extends XmlTestBase
+ extends XmlTestUtil
{
-
public record Request(
@JacksonXmlElementWrapper(localName = "messages")
@JacksonXmlProperty(localName = "message")
@@ -21,14 +23,14 @@ public record Request(
) {
public Request {}
- private Request() {this(null);}
+ protected Request() {this(null);}
}
public record Message(String text) {
public Message {
}
- private Message() {
+ protected Message() {
this(null);
}
}
@@ -42,6 +44,7 @@ private Message() {
"" +
"";
+ @JacksonTestFailureExpected
@Test
public void testWrapper() throws Exception {
XmlWrapperRecord517Test.Request request = new Request(List.of(new Message("Hello, World!")));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/FeatureDefaultsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/FeatureDefaultsTest.java
index 07e78340b..902dd331f 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/FeatureDefaultsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/FeatureDefaultsTest.java
@@ -1,20 +1,26 @@
package com.fasterxml.jackson.dataformat.xml;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
-public class FeatureDefaultsTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+
+public class FeatureDefaultsTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testDeserDefaults() throws Exception
{
ObjectReader r = MAPPER.reader();
assertNotSame(r, r.with(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL));
}
+ @Test
public void testSerDefaults() throws Exception
{
ObjectWriter w = MAPPER.writer();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java
index 58449474e..4674ffc3b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/MapperCopyTest.java
@@ -2,6 +2,8 @@
import java.io.*;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
@@ -9,7 +11,9 @@
import com.fasterxml.jackson.dataformat.xml.ser.XmlSerializerProvider;
import com.fasterxml.jackson.dataformat.xml.util.XmlRootNameLookup;
-public class MapperCopyTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class MapperCopyTest extends XmlTestUtil
{
@JsonRootName("AnnotatedName")
static class Pojo282
@@ -17,6 +21,7 @@ static class Pojo282
public int a = 3;
}
+ @Test
public void testMapperCopy()
{
XmlMapper mapper1 = mapperBuilder()
@@ -41,18 +46,20 @@ public void testMapperCopy()
SerializationConfig sc2 = mapper2.getSerializationConfig();
assertNotSame(sc1, sc2);
assertEquals(
- "serialization features did not get copied",
sc1.getSerializationFeatures(),
- sc2.getSerializationFeatures()
+ sc2.getSerializationFeatures(),
+ "serialization features did not get copied"
);
}
+ @Test
public void testSerializerProviderCopy() {
DefaultSerializerProvider provider = new XmlSerializerProvider(new XmlRootNameLookup());
DefaultSerializerProvider copy = provider.copy();
assertNotSame(provider, copy);
}
+ @Test
public void testMapperSerialization() throws Exception
{
XmlMapper mapper1 = mapperBuilder()
@@ -74,6 +81,7 @@ public void testMapperSerialization() throws Exception
// [dataformat-xml#282]
@SuppressWarnings("deprecation")
+ @Test
public void testCopyWith() throws Exception
{
XmlMapper xmlMapper = newMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/MediaItem.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/MediaItem.java
index d7eec803f..02abdd53e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/MediaItem.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/MediaItem.java
@@ -1,6 +1,7 @@
package com.fasterxml.jackson.dataformat.xml;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/RoundtripContentTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/RoundtripContentTest.java
index e3fa0b91e..2a35926fb 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/RoundtripContentTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/RoundtripContentTest.java
@@ -1,12 +1,18 @@
package com.fasterxml.jackson.dataformat.xml;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
-public class RoundtripContentTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class RoundtripContentTest extends XmlTestUtil
{
private final XmlMapper MAPPER = new XmlMapper();
+ @Test
public void testRoundtrip() throws Exception
{
MediaItem.Content content = new MediaItem.Content();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/VersionInfoTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/VersionInfoTest.java
index 3dca6dd6d..0b569e2d4 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/VersionInfoTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/VersionInfoTest.java
@@ -1,10 +1,16 @@
package com.fasterxml.jackson.dataformat.xml;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.core.Versioned;
-public class VersionInfoTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+public class VersionInfoTest extends XmlTestUtil
{
+ @Test
public void testMapperVersions()
{
assertVersion(new XmlMapper());
@@ -20,7 +26,7 @@ public void testMapperVersions()
private void assertVersion(Versioned vers)
{
final Version v = vers.version();
- assertFalse("Should find version information (got "+v+")", v.isUnknownVersion());
+ assertFalse(v.isUnknownVersion(), "Should find version information (got "+v+")");
Version exp = PackageVersion.VERSION;
assertEquals(exp.toFullString(), v.toFullString());
assertEquals(exp, v);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestBase.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestBase.java
index b794ff979..fc91b95af 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestBase.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestBase.java
@@ -7,20 +7,16 @@
import junit.framework.TestCase;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
import com.fasterxml.jackson.core.*;
-
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.type.TypeFactory;
-
-import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
-
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
+@Deprecated // since 2.19
public abstract class XmlTestBase
extends TestCase
{
-
protected static final String DEFAULT_NEW_LINE;
static {
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestUtil.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestUtil.java
new file mode 100644
index 000000000..818264434
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/XmlTestUtil.java
@@ -0,0 +1,388 @@
+package com.fasterxml.jackson.dataformat.xml;
+
+import java.io.*;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
+
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.core.*;
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
+import com.fasterxml.jackson.databind.type.TypeFactory;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationIntrospector;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public abstract class XmlTestUtil
+{
+
+ protected static final String DEFAULT_NEW_LINE;
+
+ static {
+ String newLine = System.getProperty("line.separator");
+ DEFAULT_NEW_LINE = newLine == null ? "\n" : newLine;
+ }
+
+ @JsonPropertyOrder({ "first", "last", "id" })
+ protected static class NameBean {
+ @JacksonXmlProperty(isAttribute=true)
+ public int age;
+ public String last, first;
+
+ public NameBean() { }
+ public NameBean(int age, String f, String l) {
+ this.age = age;
+ first = f;
+ last = l;
+ }
+ }
+
+ /**
+ * Sample class from Jackson tutorial ("JacksonInFiveMinutes")
+ */
+ public static class FiveMinuteUser {
+ public enum Gender { MALE, FEMALE };
+
+ public static class Name
+ {
+ private String _first, _last;
+
+ public Name() { }
+ public Name(String f, String l) {
+ _first = f;
+ _last = l;
+ }
+
+ public String getFirst() { return _first; }
+ public String getLast() { return _last; }
+
+ public void setFirst(String s) { _first = s; }
+ public void setLast(String s) { _last = s; }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o == this) return true;
+ if (o == null || o.getClass() != getClass()) return false;
+ Name other = (Name) o;
+ return _first.equals(other._first) && _last.equals(other._last);
+ }
+ }
+
+ private Gender _gender;
+ private Name _name;
+ private boolean _isVerified;
+ private byte[] _userImage;
+
+ public FiveMinuteUser() { }
+
+ public FiveMinuteUser(String first, String last, boolean verified, Gender g, byte[] data)
+ {
+ _name = new Name(first, last);
+ _isVerified = verified;
+ _gender = g;
+ _userImage = data;
+ }
+
+ public Name getName() { return _name; }
+ public boolean isVerified() { return _isVerified; }
+ public Gender getGender() { return _gender; }
+ public byte[] getUserImage() { return _userImage; }
+
+ public void setName(Name n) { _name = n; }
+ public void setVerified(boolean b) { _isVerified = b; }
+ public void setGender(Gender g) { _gender = g; }
+ public void setUserImage(byte[] b) { _userImage = b; }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (o == this) return true;
+ if (o == null || o.getClass() != getClass()) return false;
+ FiveMinuteUser other = (FiveMinuteUser) o;
+ if (_isVerified != other._isVerified) return false;
+ if (_gender != other._gender) return false;
+ if (!_name.equals(other._name)) return false;
+ byte[] otherImage = other._userImage;
+ if (otherImage.length != _userImage.length) return false;
+ for (int i = 0, len = _userImage.length; i < len; ++i) {
+ if (_userImage[i] != otherImage[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ protected static class StringBean
+ {
+ public String text;
+
+ public StringBean() { this("foobar"); }
+ public StringBean(String s) { text = s; }
+
+ @Override
+ public String toString() {
+ if (text == null) return "NULL";
+ return "\""+text+"\"";
+ }
+ }
+
+ /**
+ * Simple wrapper around String type, usually to test value
+ * conversions or wrapping
+ */
+ protected static class StringWrapper {
+ public String str;
+
+ public StringWrapper() { }
+ public StringWrapper(String value) {
+ str = value;
+ }
+ }
+
+ protected static class IntWrapper {
+ public int i;
+
+ public IntWrapper() { }
+ public IntWrapper(int value) {
+ i = value;
+ }
+ }
+
+ public static class Point {
+ public int x, y;
+
+ protected Point() { } // for deser
+ public Point(int x0, int y0) {
+ x = x0;
+ y = y0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (!(o instanceof Point)) {
+ return false;
+ }
+ Point other = (Point) o;
+ return (other.x == x) && (other.y == y);
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[x=%d, y=%d]", x, y);
+ }
+ }
+
+ /*
+ /**********************************************************
+ /* Some sample documents:
+ /**********************************************************
+ */
+
+ protected final static int SAMPLE_SPEC_VALUE_WIDTH = 800;
+ protected final static int SAMPLE_SPEC_VALUE_HEIGHT = 600;
+ protected final static String SAMPLE_SPEC_VALUE_TITLE = "View from 15th Floor";
+ protected final static String SAMPLE_SPEC_VALUE_TN_URL = "http://www.example.com/image/481989943";
+ protected final static int SAMPLE_SPEC_VALUE_TN_HEIGHT = 125;
+ protected final static String SAMPLE_SPEC_VALUE_TN_WIDTH = "100";
+ protected final static int SAMPLE_SPEC_VALUE_TN_ID1 = 116;
+ protected final static int SAMPLE_SPEC_VALUE_TN_ID2 = 943;
+ protected final static int SAMPLE_SPEC_VALUE_TN_ID3 = 234;
+ protected final static int SAMPLE_SPEC_VALUE_TN_ID4 = 38793;
+
+ protected final static String SAMPLE_DOC_JSON_SPEC =
+ "{\n"
+ +" \"Image\" : {\n"
+ +" \"Width\" : "+SAMPLE_SPEC_VALUE_WIDTH+",\n"
+ +" \"Height\" : "+SAMPLE_SPEC_VALUE_HEIGHT+","
+ +"\"Title\" : \""+SAMPLE_SPEC_VALUE_TITLE+"\",\n"
+ +" \"Thumbnail\" : {\n"
+ +" \"Url\" : \""+SAMPLE_SPEC_VALUE_TN_URL+"\",\n"
+ +"\"Height\" : "+SAMPLE_SPEC_VALUE_TN_HEIGHT+",\n"
+ +" \"Width\" : \""+SAMPLE_SPEC_VALUE_TN_WIDTH+"\"\n"
+ +" },\n"
+ +" \"IDs\" : ["+SAMPLE_SPEC_VALUE_TN_ID1+","+SAMPLE_SPEC_VALUE_TN_ID2+","+SAMPLE_SPEC_VALUE_TN_ID3+","+SAMPLE_SPEC_VALUE_TN_ID4+"]\n"
+ +" }"
+ +"}"
+ ;
+
+ /*
+ /**********************************************************
+ /* Construction, factory methods
+ /**********************************************************
+ */
+
+ protected XmlTestUtil() {
+ super();
+ }
+
+ protected XmlFactoryBuilder streamFactoryBuilder() {
+ return XmlFactory.builder();
+ }
+
+ protected static XmlMapper newMapper() {
+ return new XmlMapper();
+ }
+
+ protected static XmlMapper.Builder mapperBuilder() {
+ return XmlMapper.builder();
+ }
+
+ protected static XmlMapper.Builder mapperBuilder(boolean useListWrapping) {
+ return XmlMapper.builder()
+ .defaultUseWrapper(useListWrapping);
+ }
+
+ protected static XmlMapper.Builder mapperBuilder(XmlFactory f) {
+ return XmlMapper.builder(f);
+ }
+
+ protected XmlMapper xmlMapper(boolean useListWrapping)
+ {
+ return mapperBuilder(useListWrapping).build();
+ }
+
+ protected AnnotationIntrospector jakartaXMLBindAnnotationIntrospector() {
+ return new JakartaXmlBindAnnotationIntrospector(TypeFactory.defaultInstance());
+ }
+
+ /*
+ /**********************************************************
+ /* Additional assertion methods
+ /**********************************************************
+ */
+
+ protected void assertToken(JsonToken expToken, JsonToken actToken)
+ {
+ if (actToken != expToken) {
+ fail("Expected token "+expToken+", current token "+actToken);
+ }
+ }
+
+ protected void assertToken(JsonToken expToken, JsonParser jp)
+ {
+ assertToken(expToken, jp.getCurrentToken());
+ }
+
+ /**
+ * Method that gets textual contents of the current token using
+ * available methods, and ensures results are consistent, before
+ * returning them
+ */
+ protected String getAndVerifyText(JsonParser jp)
+ throws IOException, JsonParseException
+ {
+ // Ok, let's verify other accessors
+ int actLen = jp.getTextLength();
+ char[] ch = jp.getTextCharacters();
+ String str2 = new String(ch, jp.getTextOffset(), actLen);
+ String str = jp.getText();
+
+ if (str.length() != actLen) {
+ fail("Internal problem (jp.token == "+jp.getCurrentToken()+"): jp.getText().length() ['"+str+"'] == "+str.length()+"; jp.getTextLength() == "+actLen);
+ }
+ assertEquals(str, str2, "String access via getText(), getTextXxx() must be the same");
+
+ return str;
+ }
+
+ protected void verifyFieldName(JsonParser jp, String expName)
+ throws IOException
+ {
+ assertEquals(expName, jp.getText());
+ assertEquals(expName, jp.currentName());
+ }
+
+ protected void verifyException(Throwable e, String... matches)
+ {
+ String msg = e.getMessage();
+ String lmsg = (msg == null) ? "" : msg.toLowerCase();
+ for (String match : matches) {
+ String lmatch = match.toLowerCase();
+ if (lmsg.indexOf(lmatch) >= 0) {
+ return;
+ }
+ }
+ fail("Expected an exception with one of substrings ("+Arrays.asList(matches)+"): got one ("+
+ e.getClass().getName()+") with message \""+msg+"\"");
+ }
+
+ /*
+ /**********************************************************
+ /* Helper methods, other
+ /**********************************************************
+ */
+
+ protected static String a2q(String content) {
+ return content.replace("'", "\"");
+ }
+
+ protected byte[] utf8Bytes(String str) {
+ return str.getBytes(StandardCharsets.UTF_8);
+ }
+
+ /**
+ * Helper method that tries to remove unnecessary namespace
+ * declaration that default JDK XML parser (SJSXP) sees fit
+ * to add.
+ */
+ protected static String removeSjsxpNamespace(String xml)
+ {
+ final String match = " xmlns=\"\"";
+ int ix = xml.indexOf(match);
+ if (ix > 0) {
+ xml = xml.substring(0, ix) + xml.substring(ix+match.length());
+ }
+ return xml;
+ }
+
+ protected String readAll(File f) throws IOException
+ {
+ StringBuilder sb = new StringBuilder();
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
+ String line;
+
+ while ((line = br.readLine()) != null) {
+ sb.append(line).append("\n");
+ }
+ br.close();
+ return sb.toString();
+ }
+
+ protected byte[] readResource(String ref)
+ {
+ ByteArrayOutputStream bytes = new ByteArrayOutputStream();
+ final byte[] buf = new byte[4000];
+
+ InputStream in = getClass().getResourceAsStream(ref);
+ if (in != null) {
+ try {
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ bytes.write(buf, 0, len);
+ }
+ in.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to read resource '"+ref+"': "+e);
+ }
+ }
+ if (bytes.size() == 0) {
+ throw new IllegalArgumentException("Failed to read resource '"+ref+"': empty resource?");
+ }
+ return bytes.toByteArray();
+ }
+
+ public String jaxbSerialized(Object ob, Class>... classes) throws Exception
+ {
+ StringWriter sw = new StringWriter();
+ if (classes.length == 0) {
+ jakarta.xml.bind.JAXB.marshal(ob, sw);
+ } else {
+ jakarta.xml.bind.JAXBContext.newInstance(classes).createMarshaller().marshal(ob, sw);
+ }
+ sw.close();
+ return sw.toString();
+ }
+}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/adapters/TestIssue47Attribute.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/adapters/TestIssue47Attribute.java
index 8c01e8e78..ff7f1b292 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/adapters/TestIssue47Attribute.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/adapters/TestIssue47Attribute.java
@@ -2,10 +2,15 @@
import java.util.List;
-import com.fasterxml.jackson.dataformat.xml.*;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class TestIssue47Attribute extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class TestIssue47Attribute extends XmlTestUtil
{
public static class Response
{
@@ -20,6 +25,7 @@ public static class Item
public String b;
}
+ @Test
public void testEmptyStringFromElemAndAttr() throws Exception
{
final XmlMapper MAPPER = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CaseInsensitiveDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CaseInsensitiveDeserTest.java
index 06839f6dd..ecd9e4adc 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CaseInsensitiveDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CaseInsensitiveDeserTest.java
@@ -2,18 +2,19 @@
import java.util.List;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
-public class CaseInsensitiveDeserTest extends XmlTestBase
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.annotation.*;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+public class CaseInsensitiveDeserTest extends XmlTestUtil
{
static class BaseResponse {
public int errorCode;
@@ -80,6 +81,7 @@ public void setName(String n) {
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
.build();
+ @Test
public void testCaseInsensitive1036() throws Exception
{
final String DOC =
@@ -100,6 +102,7 @@ public void testCaseInsensitive1036() throws Exception
}
// [dataformat-xml#273]
+ @Test
public void testCaseInsensitiveComplex() throws Exception
{
final String DOC =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CoerceFromEmptyStringTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CoerceFromEmptyStringTest.java
index 96377db26..a60e62daf 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CoerceFromEmptyStringTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CoerceFromEmptyStringTest.java
@@ -3,13 +3,17 @@
import java.util.List;
import java.util.Map;
-import com.fasterxml.jackson.core.type.TypeReference;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// Note: copied from coercion tests of `jackson-databind`
-public class CoerceFromEmptyStringTest extends XmlTestBase
+public class CoerceFromEmptyStringTest extends XmlTestUtil
{
static class PointWrapper {
public Point p;
@@ -46,6 +50,7 @@ public NoCtorPOJO(boolean b) { }
private final static String EMPTY_XML = " ";
+ @Test
public void testNullsToEmptyPojo() throws Exception
{
PointWrapper pw = MAPPER.readValue("
",
@@ -56,6 +61,7 @@ public void testNullsToEmptyPojo() throws Exception
assertEquals(0, pw.p.y);
}
+ @Test
public void testNullsToGenericPojo() throws Exception
{
// String xml = MAPPER.writeValueAsString(new GeneralEmpty(new Point(1, 2)));
@@ -67,6 +73,7 @@ public void testNullsToGenericPojo() throws Exception
assertEquals(0, p.y);
}
+ @Test
public void testNullsToEmptyCollection() throws Exception
{
GeneralEmpty> result = MAPPER.readValue(EMPTY_XML,
@@ -81,6 +88,7 @@ public void testNullsToEmptyCollection() throws Exception
assertEquals(0, result2.value.size());
}
+ @Test
public void testNullsToEmptyMap() throws Exception
{
GeneralEmpty> result = MAPPER.readValue(EMPTY_XML,
@@ -89,6 +97,7 @@ public void testNullsToEmptyMap() throws Exception
assertEquals(0, result.value.size());
}
+ @Test
public void testNullsToEmptyArrays() throws Exception
{
final String doc = EMPTY_XML;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DefaultTyping325Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DefaultTyping325Test.java
index 6ae3267fe..f41dad10b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DefaultTyping325Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DefaultTyping325Test.java
@@ -2,13 +2,18 @@
import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.testutil.NoCheckSubTypeValidator;
-public class DefaultTyping325Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class DefaultTyping325Test extends XmlTestUtil
{
static class Simple325 {
protected String[] list;
@@ -18,6 +23,7 @@ static class Simple325 {
}
// [dataformat-xml#325]
+ @Test
public void testDefaultTypingWithInnerClass() throws IOException
{
ObjectMapper mapper = mapperBuilder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DelegatingCreator254Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DelegatingCreator254Test.java
index 63f472d4e..f20876dc5 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DelegatingCreator254Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DelegatingCreator254Test.java
@@ -1,10 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class DelegatingCreator254Test extends XmlTestBase
+public class DelegatingCreator254Test extends XmlTestUtil
{
static class Foo {
public Bar bar;
@@ -29,6 +35,7 @@ public Bar(int i) {
// [dataformat-xml#254]: Coercion needed for int-taking creator (as XML can
// not natively detect scalars other than Strings)
+ @Test
public void testIntDelegatingCreator() throws Exception
{
Foo foo = MAPPER.readValue(
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DeserErrorHandling236Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DeserErrorHandling236Test.java
index 44485ad96..5647e2fb7 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DeserErrorHandling236Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/DeserErrorHandling236Test.java
@@ -1,9 +1,14 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.fail;
-public class DeserErrorHandling236Test extends XmlTestBase
+public class DeserErrorHandling236Test extends XmlTestUtil
{
static class Employee {
public String name;
@@ -18,6 +23,7 @@ static class Employee {
protected XmlMapper MAPPER = new XmlMapper();
// [dataformat-xml#236]
+ @Test
public void testExceptionWrapping() throws Exception
{
final String XML = "monica& ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ElementWithScalarAndAttr412Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ElementWithScalarAndAttr412Test.java
index 7514ff354..dc98c6c6a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ElementWithScalarAndAttr412Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ElementWithScalarAndAttr412Test.java
@@ -4,13 +4,17 @@
import java.util.Date;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class ElementWithScalarAndAttr412Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class ElementWithScalarAndAttr412Test extends XmlTestUtil
{
@JsonRootName("container")
static class Bean412 {
@@ -100,6 +104,7 @@ static class TaggedDate412 {
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#412]
+ @Test
public void testIntFromElemAndAttrInList() throws Exception
{
String XML = "\n"
@@ -124,6 +129,7 @@ public void testIntFromElemAndAttrInList() throws Exception
assertEquals(42, many.v.get(1).count);
}
+ @Test
public void testIntFromElemAndAttr() throws Exception
{
TaggedInt412 result;
@@ -151,6 +157,7 @@ public void testIntFromElemAndAttr() throws Exception
/**********************************************************
*/
+ @Test
public void testBooleanFromElemAndAttr() throws Exception
{
final String XML = "true 3 ";
@@ -166,6 +173,7 @@ public void testBooleanFromElemAndAttr() throws Exception
}
}
+ @Test
public void testDoubleFromElemAndAttr() throws Exception
{
final String XML = "28 0.25 ";
@@ -182,6 +190,7 @@ public void testDoubleFromElemAndAttr() throws Exception
}
}
+ @Test
public void testStringFromElemAndAttr() throws Exception
{
TaggedString412 result = MAPPER.readValue(
@@ -191,6 +200,7 @@ public void testStringFromElemAndAttr() throws Exception
assertEquals(7, result.count);
}
+ @Test
public void testURIFromElemAndAttr() throws Exception
{
TaggedURI412 result = MAPPER.readValue(
@@ -202,6 +212,7 @@ public void testURIFromElemAndAttr() throws Exception
assertEquals(11, result.count);
}
+ @Test
public void testDateFromElemAndAttr() throws Exception
{
TaggedDate412 result = MAPPER.readValue(
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyBeanDeser318Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyBeanDeser318Test.java
index dd30204b0..cb2406bb6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyBeanDeser318Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyBeanDeser318Test.java
@@ -1,12 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
-public class EmptyBeanDeser318Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class EmptyBeanDeser318Test extends XmlTestUtil
{
static class Wrapper {
@JacksonXmlProperty(localName = "id")
@@ -40,6 +45,7 @@ static class Bean579 {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testEmptyString() throws Exception {
String s = ""
+ " id "
@@ -52,6 +58,7 @@ public void testEmptyString() throws Exception {
assertNull(value.nested.nested2);
}
+ @Test
public void testBlankString() throws Exception {
String s = ""
+ " id "
@@ -67,6 +74,7 @@ public void testBlankString() throws Exception {
assertNull(value.nested.nested2);
}
+ @Test
public void testBlankString2() throws Exception {
String s = ""
+ " id "
@@ -80,6 +88,7 @@ public void testBlankString2() throws Exception {
assertNull(value.nested.nested2);
}
+ @Test
public void testMissing() throws Exception {
String s = ""
+ " id "
@@ -90,6 +99,7 @@ public void testMissing() throws Exception {
assertNull(value.nested);
}
+ @Test
public void testValidStructure() throws Exception {
String s = ""
+ " id "
@@ -105,6 +115,7 @@ public void testValidStructure() throws Exception {
}
// [dataformat-xml#579]
+ @Test
public void testEmptyRootElem579() throws Exception
{
Bean579 bean;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyStringValueTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyStringValueTest.java
index 79f729719..d1d44669e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyStringValueTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyStringValueTest.java
@@ -3,13 +3,17 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class EmptyStringValueTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class EmptyStringValueTest extends XmlTestUtil
{
static class Name {
public String first;
@@ -56,6 +60,7 @@ static class Product427 {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testEmptyString162() throws Exception
{
Name name = MAPPER.readValue("Ryan ",
@@ -65,6 +70,7 @@ public void testEmptyString162() throws Exception
assertEquals("", name.last);
}
+ @Test
public void testEmptyElement() throws Exception
{
final String XML = " ";
@@ -85,6 +91,7 @@ public void testEmptyElement() throws Exception
assertEquals("", name.last);
}
+ @Test
public void testEmptyStringElement() throws Exception
{
// then with empty element
@@ -97,6 +104,7 @@ public void testEmptyStringElement() throws Exception
}
// [dataformat-xml#25]
+ @Test
public void testEmptyStringFromElemAndAttr() throws Exception
{
EmptyStrings25 ob = MAPPER.readValue(" ",
@@ -107,6 +115,7 @@ public void testEmptyStringFromElemAndAttr() throws Exception
}
// [dataformat-xml#427]
+ @Test
public void testEmptyIssue427() throws Exception
{
String xml = " ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyWithScalarsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyWithScalarsTest.java
index 6a15de23a..16ee90998 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyWithScalarsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EmptyWithScalarsTest.java
@@ -3,17 +3,20 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import static org.junit.jupiter.api.Assertions.*;
+
// [dataformat-xml#473]: 2.11 -> 2.12 coercion of empty to "default"
// [dataformat-xml#474]: no failure for primitives, no null
-public class EmptyWithScalarsTest extends XmlTestBase
+public class EmptyWithScalarsTest extends XmlTestUtil
{
@JacksonXmlRootElement(localName = "w")
static class NumbersPrimitive {
@@ -52,6 +55,7 @@ static class MiscOther {
/**********************************************************************
*/
+ @Test
public void testPrimitiveIntsWithEmpty() throws Exception
{
NumbersPrimitive p = MAPPER.readValue(_emptyWrapped("i"),
@@ -62,6 +66,7 @@ public void testPrimitiveIntsWithEmpty() throws Exception
assertEquals(0L, p.l);
}
+ @Test
public void testPrimitiveFPsWithEmpty() throws Exception
{
NumbersPrimitive p = MAPPER.readValue(_emptyWrapped("d"),
@@ -74,6 +79,7 @@ public void testPrimitiveFPsWithEmpty() throws Exception
// [dataformat-xml#474]: no failure for primitives, no null
// (will try to fix in 2.13, but not 2.12)
+ @Test
public void testPrimitivesNoNulls() throws Exception
{
ObjectReader r = MAPPER
@@ -101,6 +107,7 @@ private void _testPrimitivesNoNulls(ObjectReader r, String doc) throws Exception
/**********************************************************************
*/
+ @Test
public void testIntegralsWithEmpty() throws Exception
{
NumbersWrapper w = MAPPER.readValue(_emptyWrapped("I"),
@@ -115,6 +122,7 @@ public void testIntegralsWithEmpty() throws Exception
assertNull(o.bi);
}
+ @Test
public void testFPWithEmpty() throws Exception
{
NumbersWrapper w = MAPPER.readValue(_emptyWrapped("D"),
@@ -135,6 +143,7 @@ public void testFPWithEmpty() throws Exception
/**********************************************************************
*/
+ @Test
public void testOtherScalarWithEmpty() throws Exception
{
MiscOther o = MAPPER.readValue(_emptyWrapped("B"),
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java
index 308fa3742..3e181a914 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java
@@ -1,11 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-import com.fasterxml.jackson.dataformat.xml.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class EnumDeserTest extends XmlTestBase
+public class EnumDeserTest extends XmlTestUtil
{
static enum TestEnum { A, B, C; }
@@ -48,6 +53,7 @@ public static Country682 fromValue(String value) {
private final XmlMapper MAPPER = new XmlMapper();
+ @Test
public void testEnumInBean() throws Exception
{
String xml = MAPPER.writeValueAsString(new EnumBean(TestEnum.B));
@@ -57,6 +63,7 @@ public void testEnumInBean() throws Exception
}
// [dataformat-xml#121]
+ @Test
public void testRootEnum() throws Exception
{
String xml = MAPPER.writeValueAsString(TestEnum.B);
@@ -66,6 +73,7 @@ public void testRootEnum() throws Exception
}
// [dataformat-xml#682]
+ @Test
public void testEnumDeser682() throws Exception {
String xml = MAPPER.writeValueAsString(Country682.ITALY);
assertEquals("Italy ", xml);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ExceptionDeserializationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ExceptionDeserializationTest.java
index 04b5b9a5f..8b6ef0670 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ExceptionDeserializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/ExceptionDeserializationTest.java
@@ -2,10 +2,15 @@
import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class ExceptionDeserializationTest extends XmlTestBase
+public class ExceptionDeserializationTest extends XmlTestUtil
{
/*
/**********************************************************
@@ -16,6 +21,7 @@ public class ExceptionDeserializationTest extends XmlTestBase
private final XmlMapper MAPPER = new XmlMapper();
// [dataformat-xml#250]
+ @Test
public void testEmptyString162() throws Exception
{
IOException src = new IOException("test");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/Issue274PropertyNameTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/Issue274PropertyNameTest.java
index 6c07c0b6f..4791aef53 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/Issue274PropertyNameTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/Issue274PropertyNameTest.java
@@ -1,13 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.*;
-
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// [dataformat-xml#274]: Actually passes... can not reproduce failure
-public class Issue274PropertyNameTest extends XmlTestBase
+public class Issue274PropertyNameTest extends XmlTestUtil
{
private static final String XML =
"\n" +
@@ -46,6 +49,7 @@ static class RootObject {
*/
// [dataformat-xml#274]
+ @Test
public void testIssue274() throws Exception
{
final ObjectMapper xm = mapperBuilder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapDeserializationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapDeserializationTest.java
index 301d57388..7d9dddd3d 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapDeserializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapDeserializationTest.java
@@ -1,13 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.deser;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
+import java.util.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class MapDeserializationTest extends XmlTestBase
+public class MapDeserializationTest extends XmlTestUtil
{
/*
/**********************************************************
@@ -18,6 +21,7 @@ public class MapDeserializationTest extends XmlTestBase
private final XmlMapper XML_MAPPER = newMapper();
// [dataformat-xml#14]
+ @Test
public void testMapWithAttr() throws Exception
{
final String xml = "John Smith ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapWithDupsDeser498Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapWithDupsDeser498Test.java
index 10fd105e0..4cb901145 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapWithDupsDeser498Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/MapWithDupsDeser498Test.java
@@ -2,13 +2,16 @@
import java.util.Map;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class MapWithDupsDeser498Test extends XmlTestBase
+public class MapWithDupsDeser498Test extends XmlTestUtil
{
/*
/**********************************************************************
@@ -21,6 +24,7 @@ public class MapWithDupsDeser498Test extends XmlTestBase
private final ObjectMapper JSON_MAPPER = new JsonMapper();
// [dataformat-xml#498]
+ @Test
public void testRootLevelMap() throws Exception
{
final String xml = "\n"
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NullConversionsSkipTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NullConversionsSkipTest.java
index 318d2addd..0f903ce29 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NullConversionsSkipTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NullConversionsSkipTest.java
@@ -1,13 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
// for [databind#1402]; configurable null handling, specifically with SKIP
-public class NullConversionsSkipTest extends XmlTestBase
+public class NullConversionsSkipTest extends XmlTestUtil
{
static class NullSkipField {
public String nullsOk = "a";
@@ -48,6 +53,7 @@ public void setValue(String v) {
.enable(FromXmlParser.Feature.EMPTY_ELEMENT_AS_NULL)
.build();
+ @Test
public void testSkipNullField1() throws Exception
{
// first, ok if assigning non-null to not-nullable, null for nullable
@@ -59,6 +65,7 @@ public void testSkipNullField1() throws Exception
assertNull(result.nullsOk);
}
+ @Test
public void testSkipNullField2() throws Exception
{
// and then see that nulls are not ok for non-nullable
@@ -68,6 +75,7 @@ public void testSkipNullField2() throws Exception
assertEquals("a", result.nullsOk);
}
+ @Test
public void testSkipNullMethod1() throws Exception
{
NullSkipMethod result = NULL_EXPOSING_MAPPER.readValue(
@@ -78,6 +86,7 @@ public void testSkipNullMethod1() throws Exception
assertNull(result._nullsOk);
}
+ @Test
public void testSkipNullMethod2() throws Exception
{
NullSkipMethod result = NULL_EXPOSING_MAPPER.readValue(" ",
@@ -92,6 +101,7 @@ public void testSkipNullMethod2() throws Exception
/**********************************************************
*/
+ @Test
public void testSkipNullWithDefaults() throws Exception
{
// String doc = " ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NumberDeserWithXMLTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NumberDeserWithXMLTest.java
index da5b5173b..cea08164e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NumberDeserWithXMLTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NumberDeserWithXMLTest.java
@@ -2,21 +2,19 @@
import java.math.BigDecimal;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonSubTypes;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.annotation.JsonUnwrapped;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.*;
// Tests copied from databind "JDKNumberDeserTest" (only a small subset)
-public class NumberDeserWithXMLTest extends XmlTestBase
+public class NumberDeserWithXMLTest extends XmlTestUtil
{
// [databind#2644]
@JsonRootName("Root")
@@ -76,6 +74,24 @@ static class NestedFloatHolder2784 {
public FloatHolder2784 holder;
}
+ static class DeserializationIssue4917 {
+ public DecimalHolder4917 decimalHolder;
+ public double number;
+ }
+
+ static class DecimalHolder4917 {
+ public BigDecimal value;
+
+ private DecimalHolder4917(BigDecimal value) {
+ this.value = value;
+ }
+
+ @JsonCreator(mode = JsonCreator.Mode.DELEGATING)
+ static DecimalHolder4917 of(BigDecimal value) {
+ return new DecimalHolder4917(value);
+ }
+ }
+
/*
/**********************************************************************
/* Test methods
@@ -85,6 +101,7 @@ static class NestedFloatHolder2784 {
private final XmlMapper MAPPER = newMapper();
// [databind#2644]
+ @Test
public void testBigDecimalSubtypes() throws Exception
{
ObjectMapper mapper = mapperBuilder()
@@ -101,6 +118,7 @@ public void testBigDecimalSubtypes() throws Exception
}
// [databind#2784]
+ @Test
public void testBigDecimalUnwrapped() throws Exception
{
// mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
@@ -109,6 +127,7 @@ public void testBigDecimalUnwrapped() throws Exception
assertEquals(new BigDecimal("5.00"), result.holder.value);
}
+ @Test
public void testDoubleUnwrapped() throws Exception
{
final String DOC = "125.123456789 ";
@@ -116,6 +135,7 @@ public void testDoubleUnwrapped() throws Exception
assertEquals(Double.parseDouble("125.123456789"), result.holder.value);
}
+ @Test
public void testFloatUnwrapped() throws Exception
{
final String DOC = "125.123 ";
@@ -123,6 +143,7 @@ public void testFloatUnwrapped() throws Exception
assertEquals(Float.parseFloat("125.123"), result.holder.value);
}
+ @Test
public void testVeryBigDecimalUnwrapped() throws Exception
{
final int len = 1200;
@@ -136,11 +157,12 @@ public void testVeryBigDecimalUnwrapped() throws Exception
MAPPER.readValue(DOC, NestedBigDecimalHolder2784.class);
fail("expected JsonMappingException");
} catch (JsonMappingException jme) {
- assertTrue("unexpected exception message: " + jme.getMessage(),
- jme.getMessage().startsWith("Number value length (1200) exceeds the maximum allowed"));
+ assertTrue(jme.getMessage().startsWith("Number value length (1200) exceeds the maximum allowed"),
+ "unexpected exception message: " + jme.getMessage());
}
}
+ @Test
public void testVeryBigDecimalUnwrappedWithUnlimitedNumLength() throws Exception
{
final int len = 1200;
@@ -156,4 +178,15 @@ public void testVeryBigDecimalUnwrappedWithUnlimitedNumLength() throws Exception
NestedBigDecimalHolder2784 result = new XmlMapper(f).readValue(DOC, NestedBigDecimalHolder2784.class);
assertEquals(new BigDecimal(value), result.holder.value);
}
+
+ // [databind#4917]
+ @Test
+ public void bigDecimal4917() throws Exception
+ {
+ DeserializationIssue4917 issue = MAPPER.readValue(
+ "100.00 50 ",
+ DeserializationIssue4917.class);
+ assertEquals(new BigDecimal("100.00"), issue.decimalHolder.value);
+ assertEquals(50.0, issue.number);
+ }
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/RootValueDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/RootValueDeserTest.java
index 2c1ff7298..b8de6e065 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/RootValueDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/RootValueDeserTest.java
@@ -3,11 +3,15 @@
import java.math.BigDecimal;
import java.math.BigInteger;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
// New tests (2.12) for root-level values
-public class RootValueDeserTest extends XmlTestBase
+public class RootValueDeserTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
@@ -17,6 +21,7 @@ public class RootValueDeserTest extends XmlTestBase
/**********************************************************
*/
+ @Test
public void testNumbers() throws Exception
{
_testScalar(Integer.valueOf(42), "42 ");
@@ -25,6 +30,7 @@ public void testNumbers() throws Exception
_testScalar(BigInteger.valueOf(31337), "31337 ");
}
+ @Test
public void testNumbersWithENotation() throws Exception
{
BigInteger bigInteger = new BigDecimal("2e308").toBigInteger();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/SimpleStringValuesTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/SimpleStringValuesTest.java
index 2e29d9f70..02cafec76 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/SimpleStringValuesTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/SimpleStringValuesTest.java
@@ -1,11 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.deser.EmptyStringValueTest.Name;
import com.fasterxml.jackson.dataformat.xml.deser.EmptyStringValueTest.Names;
-public class SimpleStringValuesTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class SimpleStringValuesTest extends XmlTestUtil
{
protected static class Bean2
{
@@ -29,6 +33,7 @@ static class Issue167Bean {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testSimpleStringElement() throws Exception
{
// first, simple one to verify baseline
@@ -43,6 +48,7 @@ public void testSimpleStringElement() throws Exception
// build Bean, but with gets empty String, passed via String-creator.
// 06-Sep-2022, tatu: With 2.14 behavior should become closer to 2.11 in
// this respect.
+ @Test
public void testMissingString() throws Exception
{
StringBean bean = MAPPER.readValue(" ", StringBean.class);
@@ -56,6 +62,7 @@ public void testMissingString() throws Exception
/**********************************************************
*/
+ @Test
public void testStringWithAttribute() throws Exception
{
// and then the money shot: with 'standard' attribute...
@@ -64,6 +71,7 @@ public void testStringWithAttribute() throws Exception
assertEquals("Pulla", bean.text);
}
+ @Test
public void testStringsWithAttribute() throws Exception
{
Bean2 bean = MAPPER.readValue(
@@ -78,6 +86,7 @@ public void testStringsWithAttribute() throws Exception
assertEquals("def", bean.b);
}
+ @Test
public void testStringArrayWithAttribute() throws Exception
{
// should even work for arrays of those
@@ -95,6 +104,7 @@ public void testStringArrayWithAttribute() throws Exception
assertEquals("Good stuff", beans[2].text);
}
+ @Test
public void testEmptyElementToString() throws Exception
{
final String XML =
@@ -115,6 +125,7 @@ public void testEmptyElementToString() throws Exception
/**********************************************************
*/
+ @Test
public void testStringsInList() throws Exception
{
Names input = new Names();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestBinaryData.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestBinaryData.java
index 6336c0639..f1c8bb233 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestBinaryData.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestBinaryData.java
@@ -1,10 +1,14 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class TestBinaryData extends XmlTestBase
+public class TestBinaryData extends XmlTestUtil
{
public static class Data {
public byte[] bytes;
@@ -24,6 +28,7 @@ public static class TwoData {
// private final XmlMapper MAPPER = new XmlMapper();
// for [https://github.com/FasterXML/jackson-dataformat-xml/issues/29]
+ @Test
public void testTwoBinaryProps() throws Exception
{
/* Hmmh. Looks like XmlMapper has some issues with convertValue:
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestViews.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestViews.java
index ee344c1f3..9ecee45da 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestViews.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TestViews.java
@@ -2,20 +2,25 @@
import java.io.IOException;
-import com.fasterxml.jackson.annotation.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
/*
* Tests for ('JSON') Views, other filtering.
*/
-public class TestViews extends XmlTestBase
+public class TestViews extends XmlTestUtil
{
static class RestrictedView { };
@@ -61,9 +66,8 @@ public class Issue44Bean {
protected XmlMapper _xmlMapper;
// let's actually reuse XmlMapper to make things bit faster
- @Override
+ @BeforeEach
public void setUp() throws Exception {
- super.setUp();
_xmlMapper = new XmlMapper();
}
@@ -73,6 +77,7 @@ public void setUp() throws Exception {
/**********************************************************
*/
+ @Test
public void testIssue7() throws Exception
{
Foo foo = new Foo();
@@ -104,12 +109,14 @@ public void testIssue7() throws Exception
assertEquals(11, result.bars[1].restrictedBarProperty);
}
+ @Test
public void testNullSuppression() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new NonNullBean());
assertEquals("Bob ", xml);
}
+ @Test
public void testIssue44() throws IOException
{
String exp = "13 ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TypeAttributeOrder242Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TypeAttributeOrder242Test.java
index 656225c22..e3b53994e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TypeAttributeOrder242Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/TypeAttributeOrder242Test.java
@@ -2,14 +2,18 @@
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class TypeAttributeOrder242Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TypeAttributeOrder242Test extends XmlTestUtil
{
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", defaultImpl = B.class)
@JsonSubTypes({
@@ -41,6 +45,7 @@ static class B extends A {
private final XmlMapper MAPPER = new XmlMapper();
+ @Test
public void testAttributeOrder() throws Exception
{
String content1 = " ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UnexpectedNonWhitespaceText509Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UnexpectedNonWhitespaceText509Test.java
index 1d7f2c037..81da17309 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UnexpectedNonWhitespaceText509Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UnexpectedNonWhitespaceText509Test.java
@@ -2,15 +2,13 @@
import java.util.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import com.fasterxml.jackson.dataformat.xml.annotation.*;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
// For [dataformat-xml#509]
public class UnexpectedNonWhitespaceText509Test {
@@ -57,7 +55,7 @@ public String toString() {
@Test
public void testDeSerData() throws Exception {
Data value = deSer("Text Editor ", Data.class);
- assertEquals("\"key\" attribute not correctly deserialized", value.getKey(), "MadeWith");
+ assertEquals(value.getKey(), "MadeWith", "\"key\" attribute not correctly deserialized");
}
@Test
@@ -67,11 +65,11 @@ public void testDeSerMetaData() throws Exception {
+ " 1.0.0 \n" //
+ "", MetaData.class);
List entries = value.getData();
- assertEquals("\"data\" not correctly deserialized", entries.size(), 2);
+ assertEquals(2, entries.size(), "\"data\" not correctly deserialized");
Data entry = entries.get(0);
- assertEquals("\"key\" attribute not correctly deserialized", entry.getKey(), "MadeWith");
+ assertEquals(entry.getKey(), "MadeWith", "\"key\" attribute not correctly deserialized");
entry = entries.get(1);
- assertEquals("\"key\" attribute not correctly deserialized", entry.getKey(), "Version");
+ assertEquals(entry.getKey(), "Version", "\"key\" attribute not correctly deserialized");
}
private T deSer(String xmlString, Class clazz) throws Exception {
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UntypedObjectDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UntypedObjectDeserTest.java
index 64fbfb56c..e2a9ee7f2 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UntypedObjectDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/UntypedObjectDeserTest.java
@@ -1,23 +1,25 @@
package com.fasterxml.jackson.dataformat.xml.deser;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
-public class UntypedObjectDeserTest extends XmlTestBase
+public class UntypedObjectDeserTest extends XmlTestUtil
{
private final ObjectMapper XML_MAPPER = newMapper();
// for [dataformat-xml#205], handling "untyped" ({@code java.lang.Object}-targeted)
// deserialization, including handling of element sequences
+ @Test
public void testRepeatingElements() throws Exception
{
final String XML =
@@ -68,6 +70,7 @@ public void testRepeatingElements() throws Exception
}
// [dataformat-xml#405]: support mixed content
+ @Test
public void testMixedContent() throws Exception
{
final String XML = "first123 secondabc last ";
@@ -88,6 +91,7 @@ public void testMixedContent() throws Exception
// [dataformat-xml#445]: problem with earlier #205 implementation (from 2.12.0),
// fixed in 2.12.2
+ @Test
public void testDuplicateListDeser445() throws Exception
{
final String XML =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlNumberParsingGetType1433Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlNumberParsingGetType1433Test.java
new file mode 100644
index 000000000..ffaae244a
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlNumberParsingGetType1433Test.java
@@ -0,0 +1,54 @@
+package com.fasterxml.jackson.dataformat.xml.deser;
+
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.core.*;
+import com.fasterxml.jackson.core.exc.StreamReadException;
+
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class XmlNumberParsingGetType1433Test
+ extends XmlTestUtil
+{
+ private final XmlMapper XML_MAPPER = xmlMapper(false);
+
+ // Bit different for XML as there's rarely "native" number tokens
+ @Test
+ void getNumberType() throws Exception
+ {
+ JsonParser p;
+
+ p = _createParser("123 ");
+ _verifyGetNumberTypeFail(p, "null");
+ assertToken(JsonToken.START_OBJECT, p.nextToken());
+ _verifyGetNumberTypeFail(p, "START_OBJECT");
+ assertToken(JsonToken.FIELD_NAME, p.nextToken());
+ _verifyGetNumberTypeFail(p, "FIELD_NAME");
+ assertToken(JsonToken.VALUE_STRING, p.nextToken());
+ assertTrue(p.isExpectedNumberIntToken());
+ assertToken(JsonToken.VALUE_NUMBER_INT, p.currentToken());
+ assertEquals(JsonParser.NumberType.INT, p.getNumberType());
+ assertToken(JsonToken.END_OBJECT, p.nextToken());
+ _verifyGetNumberTypeFail(p, "END_OBJECT");
+ p.close();
+ _verifyGetNumberTypeFail(p, "null");
+ }
+
+ private void _verifyGetNumberTypeFail(JsonParser p, String token) throws Exception
+ {
+ try {
+ p.getNumberType();
+ fail("Should not pass");
+ } catch (StreamReadException e) {
+ verifyException(e, "Current token ("+token+") not numeric, can not use numeric");
+ }
+ }
+
+ private JsonParser _createParser(String text) throws Exception {
+ return XML_MAPPER.createParser(text);
+ }
+}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlWrapperClass517Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlWrapperClass517Test.java
index 92267c022..61cffafe0 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlWrapperClass517Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XmlWrapperClass517Test.java
@@ -1,20 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.deser;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// [databind#517] XML wrapper doesn't work with java records
// Equivalent to on in jdk17/.../records/XmlWrapperRecord517Test.java
public class XmlWrapperClass517Test
- extends XmlTestBase
+ extends XmlTestUtil
{
public static final class Request {
@JacksonXmlElementWrapper(localName = "messages")
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasic714Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasic714Test.java
new file mode 100644
index 000000000..3b6f2c239
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilBasic714Test.java
@@ -0,0 +1,53 @@
+package com.fasterxml.jackson.dataformat.xml.deser;
+
+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 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
+ @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
+ @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). Need a new mapper
+ XmlMapper mapper2 = mapperBuilder()
+ .enable(DeserializationFeature.FAIL_ON_TRAILING_TOKENS)
+ .disable(FromXmlParser.Feature.PROCESS_XSI_NIL)
+ .build();
+ assertEquals(a2q("{'nil':'true'}"),
+ mapper2.readerFor(JsonNode.class).readValue(DOC).toString());
+ }
+}
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 c6ea26b3a..9a385feb2 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
@@ -1,15 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+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.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class XsiNilBasicTest extends XmlTestBase
+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() { }
@@ -18,15 +23,19 @@ 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
{
DoubleWrapper bean = MAPPER.readValue(
@@ -44,6 +53,7 @@ public void testWithDoubleAsNull() throws Exception
// actually we should perhaps also verify there is no content but... for now, let's leave it.
}
+ @Test
public void testWithDoubleAsNonNull() throws Exception
{
DoubleWrapper bean = MAPPER.readValue(
@@ -53,6 +63,7 @@ public void testWithDoubleAsNonNull() throws Exception
assertEquals(Double.valueOf(0.25), bean.d);
}
+ @Test
public void testWithDoubleAsMixed() throws Exception
{
DoubleWrapper2 bean = MAPPER.readValue(
@@ -87,6 +98,9 @@ public void testWithDoubleAsMixed() throws Exception
assertEquals(defaultValue.b, bean.b);
}
+ // [dataformat-xml#714]: trailing END_OBJECT
+ /*
+ @Test
public void testRootPojoAsNull() throws Exception
{
Point bean = MAPPER.readValue(
@@ -94,7 +108,9 @@ public void testRootPojoAsNull() throws Exception
Point.class);
assertNull(bean);
}
+ */
+ @Test
public void testRootPojoAsNonNull() throws Exception
{
Point bean = MAPPER.readValue(
@@ -104,6 +120,7 @@ public void testRootPojoAsNonNull() throws Exception
}
// [dataformat-xml#467]: Ok to have contents within "xsi:nil" element
+ @Test
public void testXsiNilWithNonEmptyElement() throws Exception
{
JsonNode node = MAPPER.readTree(
@@ -116,6 +133,7 @@ public void testXsiNilWithNonEmptyElement() throws Exception
}
// [dataformat-xml#468]: Allow disabling xsi:nil special handling
+ @Test
public void testDisableXsiNilLeafProcessing() throws Exception
{
final ObjectReader r = MAPPER.readerFor(JsonNode.class);
@@ -131,6 +149,9 @@ 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
{
final ObjectReader r = MAPPER.readerFor(JsonNode.class);
@@ -141,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/deser/XsiNilForStringsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilForStringsTest.java
index f4ca4ac9a..c9799434c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilForStringsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilForStringsTest.java
@@ -1,9 +1,13 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class XsiNilForStringsTest extends XmlTestBase
+public class XsiNilForStringsTest extends XmlTestUtil
{
private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
@@ -14,6 +18,7 @@ protected static class StringPair {
private final XmlMapper MAPPER = newMapper();
// [dataformat-xml#378]
+ @Test
public void testWithStringAsNull() throws Exception
{
StringPair bean;
@@ -27,6 +32,7 @@ public void testWithStringAsNull() throws Exception
}
// [dataformat-xml#378]
+ @Test
public void testWithStringAsNull2() throws Exception
{
StringPair bean;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilNestingTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilNestingTest.java
index fe5ccea9f..eb904cbea 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilNestingTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiNilNestingTest.java
@@ -1,9 +1,13 @@
package com.fasterxml.jackson.dataformat.xml.deser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class XsiNilNestingTest extends XmlTestBase
+public class XsiNilNestingTest extends XmlTestUtil
{
// for [dataformat-xml#366]
protected static class Parent366 {
@@ -22,6 +26,7 @@ protected static class Level2 {
private final XmlMapper MAPPER = newMapper();
// for [dataformat-xml#366]
+ @Test
public void testDoesNotAffectHierarchy() throws Exception
{
String xml = ""
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiTypeReadTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiTypeReadTest.java
index beb1fdebb..b58ca480b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiTypeReadTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/XsiTypeReadTest.java
@@ -1,16 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.deser;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// [dataformat-xml#634]
-public class XsiTypeReadTest extends XmlTestBase
+public class XsiTypeReadTest extends XmlTestUtil
{
@JsonRootName("Typed")
static class TypeBean {
@@ -37,6 +39,7 @@ protected PolyBean() { }
.configure(FromXmlParser.Feature.AUTO_DETECT_XSI_TYPE, true)
.build();
+ @Test
public void testExplicitXsiTypeReadEnabled() throws Exception
{
final String XML = XSI_ENABLED_MAPPER.writeValueAsString(new TypeBean("type0"));
@@ -44,6 +47,7 @@ public void testExplicitXsiTypeReadEnabled() throws Exception
assertEquals("type0", result.typeId);
}
+ @Test
public void testXsiTypeAsTypeReadeEnabled() throws Exception
{
final String XML = XSI_ENABLED_MAPPER.writeValueAsString(new PolyBean(42));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderSimpleTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderSimpleTest.java
index 821368919..2338a3bd3 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderSimpleTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderSimpleTest.java
@@ -1,18 +1,23 @@
package com.fasterxml.jackson.dataformat.xml.deser.builder;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.Version;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class BuilderSimpleTest extends XmlTestBase
+public class BuilderSimpleTest extends XmlTestUtil
{
// // Simple 2-property value class, builder with standard naming
@@ -253,6 +258,7 @@ public Version version() {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testSimple() throws Exception
{
String doc = "1 2 ";
@@ -266,6 +272,7 @@ public void testSimple() throws Exception
}
// related to [databind#1214]
+ @Test
public void testSimpleWithIgnores() throws Exception
{
// 'z' is unknown, and would fail by default:
@@ -293,6 +300,7 @@ public void testSimpleWithIgnores() throws Exception
assertEquals(value._y, 3);
}
+ @Test
public void testMultiAccess() throws Exception
{
String doc = "3 2 -9 ";
@@ -313,6 +321,7 @@ public void testMultiAccess() throws Exception
}
// test for Immutable builder, to ensure return value is used
+ @Test
public void testImmutable() throws Exception
{
ValueImmutable value = MAPPER.readValue("13 ",
@@ -321,6 +330,7 @@ public void testImmutable() throws Exception
}
// test with custom 'with-prefix'
+ @Test
public void testCustomWith() throws Exception
{
ValueFoo value = MAPPER.readValue("1 ", ValueFoo.class);
@@ -329,22 +339,25 @@ public void testCustomWith() throws Exception
// for [databind#761]
+ @Test
public void testBuilderMethodReturnMoreGeneral() throws Exception
{
ValueInterface value = MAPPER.readValue("1 ", ValueInterface.class);
assertEquals(2, value.getX());
}
+ @Test
public void testBuilderMethodReturnMoreSpecific() throws Exception
{
- final String json = "1 }";
+ final String json = "1 ";
ValueInterface2 value = MAPPER.readValue(json, ValueInterface2.class);
assertEquals(2, value.getX());
}
+ @Test
public void testSelfBuilder777() throws Exception
{
- SelfBuilder777 result = MAPPER.readValue("3 '",
+ SelfBuilder777 result = MAPPER.readValue("3 ",
SelfBuilder777.class);
assertNotNull(result);
assertEquals(3, result.x);
@@ -353,6 +366,7 @@ public void testSelfBuilder777() throws Exception
// Won't work well with XML, omit:
// public void testWithAnySetter822() throws Exception
+ @Test
public void testPOJOConfigResolution1557() throws Exception
{
final String json = "1 ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderWithXmlText345Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderWithXmlText345Test.java
index 710a0b9ee..be8f669c8 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderWithXmlText345Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/builder/BuilderWithXmlText345Test.java
@@ -1,14 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.deser.builder;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
-public class BuilderWithXmlText345Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class BuilderWithXmlText345Test extends XmlTestUtil
{
@JsonRootName("example")
@JsonDeserialize(builder = Example345.ExampleBuilder.class)
@@ -67,6 +72,7 @@ public ExampleBuilder value(String value) {
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#345]
+ @Test
public void testXmlTextViaBuilder345() throws Exception
{
Example345 in = Example345.builder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceStringToIntsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceStringToIntsTest.java
index 0045833f8..117c866a6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceStringToIntsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceStringToIntsTest.java
@@ -3,19 +3,23 @@
import java.math.BigInteger;
import java.util.concurrent.atomic.AtomicLong;
-import com.fasterxml.jackson.databind.*;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import com.fasterxml.jackson.databind.type.LogicalType;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
// 2020-12-18, tatu: Modified from "jackson-databind" version: XML
// backend MUST NOT prevent coercion from String since XML has no
// native number representation (although TBH JsonParser.isExpectedNumberInt()
// can work around that in many cases)
public class CoerceStringToIntsTest
- extends XmlTestBase
+ extends XmlTestUtil
{
private final ObjectMapper DEFAULT_MAPPER = newMapper();
private final ObjectMapper MAPPER_LEGACY_FAIL = mapperBuilder()
@@ -84,10 +88,12 @@ public DoubleWrapper() { }
// even if seemingly prevented -- this because XML has no native
// number type and Strings present all scalar values, essentially
+ @Test
public void testDefaultStringToIntCoercion() throws Exception {
_verifyLegacyFromStringSucceeds(DEFAULT_MAPPER);
}
+ @Test
public void testLegacyFailStringToInt() throws Exception {
_verifyLegacyFromStringSucceeds(MAPPER_LEGACY_FAIL);
}
@@ -129,6 +135,7 @@ private void _verifyLegacyFromStringSucceeds(ObjectMapper mapper) throws Excepti
// When explicitly enabled, should pass
+ @Test
public void testCoerceConfigStringToNull() throws Exception {
_verifyCoercionFromStringSucceeds(MAPPER_TO_NULL);
}
@@ -136,14 +143,17 @@ public void testCoerceConfigStringToNull() throws Exception {
// But even if blocked, or changed to null, should pass since with
// XML, "String" is a native representation of numbers
+ @Test
public void testCoerceConfigStringToEmpty() throws Exception {
_verifyCoercionFromStringSucceeds(MAPPER_TO_EMPTY);
}
+ @Test
public void testCoerceConfigStringConvert() throws Exception {
_verifyCoercionFromStringSucceeds(MAPPER_TRY_CONVERT);
}
+ @Test
public void testCoerceConfigFailFromString() throws Exception {
_verifyCoercionFromStringSucceeds(MAPPER_TO_FAIL);
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceToBooleanTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceToBooleanTest.java
index cdd446ead..3ca2b5559 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceToBooleanTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/convert/CoerceToBooleanTest.java
@@ -3,18 +3,21 @@
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import com.fasterxml.jackson.databind.type.LogicalType;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.*;
// 2020-12-18, tatu: Modified from "jackson-databind" version: XML
// backend MUST NOT prevent coercion from String since XML has no
// native boolean representation
public class CoerceToBooleanTest
- extends XmlTestBase
+ extends XmlTestUtil
{
static class BooleanPOJO {
public boolean value;
@@ -43,6 +46,7 @@ static class BooleanPOJO {
*/
// for [databind#403]
+ @Test
public void testEmptyStringFailForBooleanPrimitive() throws IOException
{
final ObjectReader reader = MAPPER_EMPTY_TO_BOOLEAN_FAIL
@@ -56,6 +60,7 @@ public void testEmptyStringFailForBooleanPrimitive() throws IOException
}
}
+ @Test
public void testDefaultStringToBooleanCoercionOk() throws Exception {
_verifyStringToBooleanOk(DEFAULT_MAPPER);
}
@@ -66,6 +71,7 @@ public void testDefaultStringToBooleanCoercionOk() throws Exception {
/**********************************************************
*/
+ @Test
public void testStringToBooleanOkDespiteCoercionConfig() throws Exception {
_verifyStringToBooleanOk(MAPPER_STRING_TO_BOOLEAN_FAIL);
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/ImplicitParamsForCreatorTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/ImplicitParamsForCreatorTest.java
index 5ed510b40..a93accb50 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/ImplicitParamsForCreatorTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/ImplicitParamsForCreatorTest.java
@@ -1,20 +1,21 @@
package com.fasterxml.jackson.dataformat.xml.deser.creator;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
-
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
-import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
-import com.fasterxml.jackson.databind.introspect.AnnotatedParameter;
-import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
-
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.databind.introspect.*;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// copied form [jackson-databind]
public class ImplicitParamsForCreatorTest
- extends XmlTestBase
+ extends XmlTestUtil
{
@SuppressWarnings("serial")
static class MyParamIntrospector extends JacksonAnnotationIntrospector
@@ -80,6 +81,7 @@ public int serializedAs() {
.annotationIntrospector(new MyParamIntrospector())
.build();
+ @Test
public void testNonSingleArgCreator() throws Exception
{
XY value = MAPPER.readValue(
@@ -91,6 +93,7 @@ public void testNonSingleArgCreator() throws Exception
}
// [databind#2932]
+ @Test
public void testJsonCreatorWithOtherAnnotations() throws Exception
{
Bean2932 bean = MAPPER.readValue(
@@ -105,6 +108,7 @@ public void testJsonCreatorWithOtherAnnotations() throws Exception
// 04-Feb-2024, tatu: XML does not have type information wrt Integer so this
// can't work
/*
+ @Test
public void testDelegatingInferFromJsonValue() throws Exception
{
// First verify serialization via `@JsonValue`
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NestedSingleArgCtors547Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NestedSingleArgCtors547Test.java
index b19552807..0b82be92b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NestedSingleArgCtors547Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NestedSingleArgCtors547Test.java
@@ -1,12 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.deser.creator;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class NestedSingleArgCtors547Test extends XmlTestBase
+public class NestedSingleArgCtors547Test extends XmlTestUtil
{
private static final XmlMapper XML_MAPPER = newMapper();
@@ -38,6 +41,7 @@ public Inner547Props(@JsonProperty("value") String v) {
}
// [dataformat-xml#547]
+ @Test
public void testNested1ArgCtorsDelegating() throws Exception
{
String xml = " ";
@@ -47,6 +51,7 @@ public void testNested1ArgCtorsDelegating() throws Exception
}
// [dataformat-xml#547]
+ @Test
public void testNested1ArgCtorsProps() throws Exception
{
String xml = " ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NoArgCtorDeser491Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NoArgCtorDeser491Test.java
index bcc1d0ff2..dd616ac1b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NoArgCtorDeser491Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/NoArgCtorDeser491Test.java
@@ -1,12 +1,14 @@
package com.fasterxml.jackson.dataformat.xml.deser.creator;
-import com.fasterxml.jackson.annotation.*;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Reproduces no default no-arg ctor found deserialization regression
@@ -24,7 +26,7 @@
* Use cases where (non-empty) element needs to map to Scalar types is now handled
* with mechanism introduced in 2.13.
*/
-public class NoArgCtorDeser491Test extends XmlTestBase
+public class NoArgCtorDeser491Test extends XmlTestUtil
{
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
@@ -83,6 +85,7 @@ public int getStatus() {
/**
* Passes on 2.11.4 and 2.12.{0..4}.
*/
+ @Test
public void test_empty_Problem_JSON_deserialization() throws Exception
{
Problem problem = JSON_MAPPER.readValue("{}", Problem.class);
@@ -93,6 +96,7 @@ public void test_empty_Problem_JSON_deserialization() throws Exception
/**
* Passes on 2.11.4, but fails on 2.12.{0..4}.
*/
+ @Test
public void test_empty_Problem_XML_deserialization() throws Exception
{
Problem problem = XML_MAPPER.readValue(
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/PojoWithCreatorRequired538Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/PojoWithCreatorRequired538Test.java
index a3e7f3a33..be524f67a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/PojoWithCreatorRequired538Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/deser/creator/PojoWithCreatorRequired538Test.java
@@ -1,14 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.deser.creator;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-public class PojoWithCreatorRequired538Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class PojoWithCreatorRequired538Test extends XmlTestUtil
{
@JsonRootName(value = "bar")
static class Bar538
@@ -35,6 +37,7 @@ public Bar538(@JsonProperty(value = "foo", required = true) final int foo)
.build();
// [dataformat-xml#538]
+ @Test
public void testPojoWithRequiredFromEmpty() throws Exception
{
// Should fail
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz463_32872_XmlDeclTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz463_32872_XmlDeclTest.java
index c88f50a92..6485d5f2e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz463_32872_XmlDeclTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz463_32872_XmlDeclTest.java
@@ -2,16 +2,22 @@
import java.nio.charset.StandardCharsets;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.exc.StreamReadException;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.fail;
// [dataformat-xml#463]
// (but root cause of https://github.com/FasterXML/woodstox/issues/123)
-public class Fuzz463_32872_XmlDeclTest extends XmlTestBase
+public class Fuzz463_32872_XmlDeclTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testInvalidXmlDecl() throws Exception
{
final byte[] doc = "".getBytes(StandardCharsets.UTF_8);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz465_32906_CDataReadTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz465_32906_CDataReadTest.java
index 82250565c..a23aff2c6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz465_32906_CDataReadTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz465_32906_CDataReadTest.java
@@ -1,14 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.fuzz;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.JsonNode;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.fail;
-public class Fuzz465_32906_CDataReadTest extends XmlTestBase
+public class Fuzz465_32906_CDataReadTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testIssue465() throws Exception
{
byte[] doc = readResource("/data/fuzz-32906.xml");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz618_64655_InvalidXMLTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz618_64655_InvalidXMLTest.java
index 0e3d66f8a..f09bfb01f 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz618_64655_InvalidXMLTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/Fuzz618_64655_InvalidXMLTest.java
@@ -1,26 +1,31 @@
package com.fasterxml.jackson.dataformat.xml.fuzz;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-public class Fuzz618_64655_InvalidXMLTest extends XmlTestBase
+public class Fuzz618_64655_InvalidXMLTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testWithInvalidXml1() throws Exception {
_testWithInvalidXml(1, "Unexpected end of input", // Woodstox
"Internal processing error by `XMLStreamReader` of type" // SJSXP
);
}
+ @Test
public void testWithInvalidXml2() throws Exception {
_testWithInvalidXml(2, "Unexpected character 'a'", // Woodstox
"Internal processing error by `XMLInputFactory` of type " // SJSXP
);
}
+ @Test
public void testWithInvalidXml3() throws Exception {
_testWithInvalidXml(3, "Unexpected EOF; was expecting a close tag", // Woodstox
"XML document structures must start and end" // SJSXP
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/FuzzXXX_32969_UTF32Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/FuzzXXX_32969_UTF32Test.java
index 8cf44a36a..6c105f7ba 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/FuzzXXX_32969_UTF32Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/fuzz/FuzzXXX_32969_UTF32Test.java
@@ -1,18 +1,24 @@
package com.fasterxml.jackson.dataformat.xml.fuzz;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.exc.StreamReadException;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.fail;
// [dataformat-xml#???]
// (but root cause of https://github.com/FasterXML/woodstox/issues/125)
//
// NOTE! Not reproducible for some reason with these settings (probably
// has different buffer sizes or... something
-public class FuzzXXX_32969_UTF32Test extends XmlTestBase
+public class FuzzXXX_32969_UTF32Test extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testUTF32() throws Exception
{
final byte[] doc = readResource("/data/fuzz-32906.xml");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/IncrementalWritingTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/IncrementalWritingTest.java
index 94d561560..1e63e3d58 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/IncrementalWritingTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/IncrementalWritingTest.java
@@ -1,18 +1,22 @@
package com.fasterxml.jackson.dataformat.xml.incr;
-import java.io.*;
-
+import java.io.StringWriter;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamWriter;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
-public class IncrementalWritingTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class IncrementalWritingTest extends XmlTestUtil
{
private final XmlMapper MAPPER = xmlMapper(true);
+ @Test
public void testSimple() throws Exception
{
StringWriter strw = new StringWriter();
@@ -35,6 +39,7 @@ public void testSimple() throws Exception
}
// @since 2.17
+ @Test
public void testWriteUsingXMLStreamWriter() throws Exception
{
XMLOutputFactory staxF = MAPPER.getFactory().getXMLOutputFactory();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/PartialReadTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/PartialReadTest.java
index 1d787a2d3..c1afc0880 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/PartialReadTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/incr/PartialReadTest.java
@@ -1,16 +1,23 @@
package com.fasterxml.jackson.dataformat.xml.incr;
-import java.io.*;
+import java.io.StringReader;
import javax.xml.stream.*;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonParser;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class PartialReadTest extends XmlTestBase
+public class PartialReadTest extends XmlTestUtil
{
private final XmlMapper MAPPER = xmlMapper(true);
+ @Test
public void testSimpleRead() throws Exception
{
final String XML = ""
@@ -21,9 +28,8 @@ public void testSimpleRead() throws Exception
assertEquals(sr.next(), XMLStreamConstants.START_ELEMENT);
assertEquals("root", sr.getLocalName());
- /* 30-May-2014, tatu: This is bit tricky... need to ensure that currently
- * pointed to START_ELEMENT is sort of re-read.
- */
+ // 30-May-2014, tatu: This is bit tricky... need to ensure that currently
+ // pointed to START_ELEMENT is sort of re-read.
assertEquals(sr.next(), XMLStreamConstants.START_ELEMENT);
assertEquals("NameBean", sr.getLocalName());
@@ -46,6 +52,7 @@ public void testSimpleRead() throws Exception
}
// @since 2.17
+ @Test
public void testReadUsingXMLStreamReader() throws Exception
{
final String DOC = "1 2 ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/interop/NonWoodstoxStaxImpl482Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/interop/NonWoodstoxStaxImpl482Test.java
index b55b9abcb..31bdafb22 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/interop/NonWoodstoxStaxImpl482Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/interop/NonWoodstoxStaxImpl482Test.java
@@ -1,15 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.interop;
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.sun.xml.stream.ZephyrParserFactory;
import com.sun.xml.stream.ZephyrWriterFactory;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// to verify issue behind [dataformat-xml#482]
-public class NonWoodstoxStaxImpl482Test extends XmlTestBase
+public class NonWoodstoxStaxImpl482Test extends XmlTestUtil
{
static class Root {
public int value = 3;
@@ -23,6 +26,7 @@ static class Root {
.build();
// [dataformat-xml#482]
+ @Test
public void testSjsxpFromByteArray() throws Exception
{
byte[] xml0 = SJSXP_MAPPER.writeValueAsBytes(new Root());
@@ -34,6 +38,7 @@ public void testSjsxpFromByteArray() throws Exception
}
// [dataformat-xml#482]
+ @Test
public void testSjsxpFromCharArray() throws Exception
{
char[] xml0 = SJSXP_MAPPER.writeValueAsString(new Root()).toCharArray();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/AttributesWithJAXBTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/AttributesWithJAXBTest.java
index 113860043..77144c78b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/AttributesWithJAXBTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/AttributesWithJAXBTest.java
@@ -4,11 +4,15 @@
import jakarta.xml.bind.annotation.*;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.MapperFeature;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class AttributesWithJAXBTest extends XmlTestBase
+public class AttributesWithJAXBTest extends XmlTestUtil
{
@XmlAccessorType(value = XmlAccessType.FIELD)
public class Jurisdiction {
@@ -38,6 +42,7 @@ public Problem(String id, String description) {
/**********************************************************
*/
+ @Test
public void testTwoAttributes() throws IOException
{
XmlMapper mapper = XmlMapper.builder()
@@ -48,6 +53,7 @@ public void testTwoAttributes() throws IOException
assertEquals("", xml);
}
+ @Test
public void testAttributeAndElement() throws IOException
{
XmlMapper mapper = XmlMapper.builder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/BuilderWithJAXB291Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/BuilderWithJAXB291Test.java
index 381f8372c..f2c29e038 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/BuilderWithJAXB291Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/BuilderWithJAXB291Test.java
@@ -2,6 +2,8 @@
import jakarta.xml.bind.annotation.XmlElement;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -9,14 +11,14 @@
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.dataformat.xml.*;
-import com.fasterxml.jackson.dataformat.xml.XmlAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// Test for [dataformat-xml#291]: works via field, not constructor
// (name mismatch to fix in test case)
-public class BuilderWithJAXB291Test extends XmlTestBase
+public class BuilderWithJAXB291Test extends XmlTestUtil
{
@JsonDeserialize(builder = Address.AddressBuilder.class)
static class Address
@@ -82,8 +84,9 @@ static class AddressBuilder {
String county;
@JsonCreator
- public AddressBuilder(@JsonProperty("address1") String address1, @JsonProperty("city") String city, @JsonProperty("stateProvince") String stateProvince,
- @JsonProperty("postalCode") String postalCode, @JsonProperty("country") String country) {
+ public AddressBuilder(@JsonProperty("Address1") String address1, @JsonProperty("City") String city,
+ @JsonProperty("StateProvince") String stateProvince,
+ @JsonProperty("PostalCode") String postalCode, @JsonProperty("Country") String country) {
this.address1 = address1;
this.city = city;
this.stateProvince = stateProvince;
@@ -108,6 +111,7 @@ public Address build() {
/**********************************************************************
*/
+ @Test
public void testBuilder291() throws Exception
{
final String DOC = "\n" +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/ElementWrapperTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/ElementWrapperTest.java
index 1017d25ee..f22575108 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/ElementWrapperTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/ElementWrapperTest.java
@@ -3,18 +3,18 @@
import java.util.ArrayList;
import java.util.List;
-import jakarta.xml.bind.annotation.XmlElement;
-import jakarta.xml.bind.annotation.XmlElementWrapper;
-import jakarta.xml.bind.annotation.XmlRootElement;
+import jakarta.xml.bind.annotation.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.dataformat.xml.*;
-import com.fasterxml.jackson.dataformat.xml.XmlAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class ElementWrapperTest extends XmlTestBase
+public class ElementWrapperTest extends XmlTestUtil
{
@XmlRootElement(name = "Individual")
static class MyPerson {
@@ -38,6 +38,7 @@ static class MyPerson2 {
/**********************************************************************
*/
+ @Test
public void testElementWrapper() throws Exception
{
XmlMapper _jaxbMapper = new XmlMapper();
@@ -63,6 +64,7 @@ public void testElementWrapper() throws Exception
}
// And with JAXB, default should be "no wrapper"
+ @Test
public void testNoElementWrapper() throws Exception
{
XmlMapper jaxbMapper = mapperBuilder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JAXBObjectId170Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JAXBObjectId170Test.java
index 08568096f..d9acc914a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JAXBObjectId170Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JAXBObjectId170Test.java
@@ -4,17 +4,17 @@
import java.util.List;
import jakarta.xml.bind.annotation.*;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.*;
-
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
+import com.fasterxml.jackson.dataformat.xml.*;
-import com.fasterxml.jackson.dataformat.xml.XmlAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class JAXBObjectId170Test extends XmlTestBase
+public class JAXBObjectId170Test extends XmlTestUtil
{
static class Company
{
@@ -85,6 +85,7 @@ static class LaptopComputer extends Computer {
*/
// for [dataformat-xml#178]
+ @Test
public void testPolyIdList178() throws Exception
{
final String XML =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JaxbXmlValue418Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JaxbXmlValue418Test.java
index fcf3d1220..408d69d70 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JaxbXmlValue418Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/JaxbXmlValue418Test.java
@@ -1,18 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.jaxb;
-import jakarta.xml.bind.annotation.XmlAttribute;
-import jakarta.xml.bind.annotation.XmlRootElement;
-import jakarta.xml.bind.annotation.XmlValue;
+import jakarta.xml.bind.annotation.*;
-import com.fasterxml.jackson.annotation.JsonRootName;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.ObjectMapper;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// Problem with handling of `@XmlValue` via JAXBAnnotationIntrospector
// is that by default it gives implicit name of `value` for virtual
// property. Although accessor itself will be specially processed, this
@@ -23,7 +23,7 @@
// binding can not be relied on)
// 2. Override default implicit name to be `null`, which should allow
// combination of accessors
-public class JaxbXmlValue418Test extends XmlTestBase
+public class JaxbXmlValue418Test extends XmlTestUtil
{
// [dataformat-xml#418]
@XmlRootElement(name = "ROOT")
@@ -98,6 +98,7 @@ public void setEl(String el) {
private static final String EXPECTED_418 = "text ";
// [dataformat-xml#418]
+ @Test
public void testWithJaxbAnnotations() throws Exception {
final RootWithJaxbAnnotations value = new RootWithJaxbAnnotations();
@@ -113,6 +114,7 @@ public void testWithJaxbAnnotations() throws Exception {
assertEquals(EXPECTED_418, xml);
}
+ @Test
public void testWithJacksonAnnotations() throws Exception {
final RootWithJacksonAnnotations value = new RootWithJacksonAnnotations();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/NamespaceViaJAXB18Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/NamespaceViaJAXB18Test.java
index 663c6786a..cb4525da3 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/NamespaceViaJAXB18Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/NamespaceViaJAXB18Test.java
@@ -1,12 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.jaxb;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlRootElement;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.fail;
-public class NamespaceViaJAXB18Test extends XmlTestBase
+public class NamespaceViaJAXB18Test extends XmlTestUtil
{
final static String TEST_NAMESPACE = "http://namespace-base";
@@ -36,6 +39,7 @@ static class HouseWithNoNamespace2 implements Facility {
.build();
// [dataformat-xml#18]
+ @Test
public void testNamespaceViaJAXB() throws Exception
{
String xml = MAPPER.writeValueAsString(new House());
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/WithJAXBAnnotationsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/WithJAXBAnnotationsTest.java
index 67604b01f..ba3124f9c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/WithJAXBAnnotationsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/jaxb/WithJAXBAnnotationsTest.java
@@ -3,21 +3,24 @@
import java.io.IOException;
import jakarta.xml.bind.annotation.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.dataformat.xml.XmlAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Although XML-backed data binding does not rely (or directly build) on JAXB
* annotations, it should be possible to use them similar to how they are used
* with default Jackson JSON data binding. Let's verify this is the case.
*/
-public class WithJAXBAnnotationsTest extends XmlTestBase
+public class WithJAXBAnnotationsTest extends XmlTestUtil
{
/*
/**********************************************************************
@@ -91,9 +94,8 @@ public void setLastName(final String lastName) {
protected XmlMapper _nonJaxbMapper;
// let's actually reuse XmlMapper to make things bit faster
- @Override
+ @BeforeEach
public void setUp() throws Exception {
- super.setUp();
_jaxbMapper = new XmlMapper();
_nonJaxbMapper = new XmlMapper();
// Use JAXB-then-Jackson annotation introspector
@@ -112,6 +114,7 @@ public void setUp() throws Exception {
* Unit test for verifying that root element name can be overridden
* with {@link XmlRootElement} annotation.
*/
+ @Test
public void testRootName() throws Exception
{
RootBean bean = new RootBean();
@@ -124,6 +127,7 @@ public void testRootName() throws Exception
* Unit test for verifying that a property defaults to being written as
* element, but can be redefined with {@link XmlAttribute} annotation.
*/
+ @Test
public void testSerializeAsAttr() throws Exception
{
AttrBean bean = new AttrBean();
@@ -135,6 +139,7 @@ public void testSerializeAsAttr() throws Exception
* Unit test for verifying correct handling of
* {@link XmlValue} annotation.
*/
+ @Test
public void testAsTextWithJAXB() throws IOException
{
// first: serialize
@@ -148,6 +153,7 @@ public void testAsTextWithJAXB() throws IOException
assertEquals("else", result.text);
}
+ @Test
public void testPersonAsXml() throws Exception {
MyPerson person = new MyPerson();
person.id = Long.valueOf(1L);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/DeserializePolyList178Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/DeserializePolyList178Test.java
index 8e315d858..34907e37a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/DeserializePolyList178Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/DeserializePolyList178Test.java
@@ -3,11 +3,16 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class DeserializePolyList178Test extends XmlTestBase
+public class DeserializePolyList178Test extends XmlTestUtil
{
static class Company {
public List computers;
@@ -64,6 +69,7 @@ static class LaptopComputer extends Computer {
private final XmlMapper MAPPER = new XmlMapper();
// for [dataformat-xml#178]
+ @Test
public void testPolyIdList178() throws Exception
{
Company input = new Company();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java
index a444fa7b2..d8de591fe 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/EmptyListDeserTest.java
@@ -3,14 +3,19 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.type.TypeReference;
-
-import com.fasterxml.jackson.dataformat.xml.*;
-import com.fasterxml.jackson.dataformat.xml.annotation.*;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
-public class EmptyListDeserTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class EmptyListDeserTest extends XmlTestUtil
{
// for [dataformat-xml#124]
public static class TestList124 {
@@ -73,6 +78,7 @@ public void test124() throws Exception {
}
// [dataformat-xml#177]
+ @Test
public void testEmptyList() throws Exception
{
Config r = MAPPER.readValue(
@@ -88,6 +94,7 @@ public void testEmptyList() throws Exception
}
// [dataformat-xml#319]
+ @Test
public void testEmptyList319() throws Exception
{
final String DOC = " ";
@@ -104,6 +111,7 @@ public void testEmptyList319() throws Exception
}
// [dataformat-xml#435]
+ @Test
public void testEmptyListAsNull435() throws Exception
{
XmlMapper mapper = mapperBuilder()
@@ -116,6 +124,7 @@ public void testEmptyListAsNull435() throws Exception
}
// [dataformat-xml#460]
+ @Test
public void testWrappedEmptyListWithWhitespace458() throws Exception
{
String input = "\n" +
@@ -124,7 +133,7 @@ public void testWrappedEmptyListWithWhitespace458() throws Exception
"\n" +
" ";
ChannelSet460 set = MAPPER.readValue(input, ChannelSet460.class);
- assertEquals("List should be empty", 0,
- set.channels.size());
+ assertEquals(0, set.channels.size(),
+ "List should be empty");
}
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/Issue101UnwrappedListAttributesTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/Issue101UnwrappedListAttributesTest.java
index 76de78436..32aa5a7b1 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/Issue101UnwrappedListAttributesTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/Issue101UnwrappedListAttributesTest.java
@@ -1,15 +1,22 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-import com.fasterxml.jackson.dataformat.xml.annotation.*;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// Failing unit test(s) wrt [Issue#64]
-public class Issue101UnwrappedListAttributesTest extends XmlTestBase
+public class Issue101UnwrappedListAttributesTest extends XmlTestUtil
{
// For [dataformat-xml#101]
@JsonRootName("root")
@@ -46,6 +53,7 @@ public UnwrappedElement (String id, String type) {
private final XmlMapper MAPPER = new XmlMapper();
// [dataformat-xml#101]
+ @Test
public void testWithTwoAttributes() throws Exception
{
final String EXP = ""
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/IterableCollectionBuilder646Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/IterableCollectionBuilder646Test.java
index 55ba423a9..79b521945 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/IterableCollectionBuilder646Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/IterableCollectionBuilder646Test.java
@@ -3,15 +3,20 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// [dataformat-xml#646]
-public class IterableCollectionBuilder646Test extends XmlTestBase
+public class IterableCollectionBuilder646Test extends XmlTestUtil
{
@JsonDeserialize(builder = Parent.Builder.class)
@JacksonXmlRootElement(localName = "parent")
@@ -78,6 +83,7 @@ public Child build() {
// -- Test Methods --//
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testIssue646() throws Exception {
final String XML = "1 ";
Parent parent = MAPPER.readValue(XML, Parent.class);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAnnotationSharingTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAnnotationSharingTest.java
index fe19487e7..af27c064c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAnnotationSharingTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAnnotationSharingTest.java
@@ -1,16 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// for [dataformat-xml#55]
-public class ListAnnotationSharingTest extends XmlTestBase
+public class ListAnnotationSharingTest extends XmlTestUtil
{
static class Wrapper {
@JacksonXmlElementWrapper(localName = "Points", useWrapping = true)
@@ -40,7 +44,8 @@ public Point() { }
private final XmlMapper MAPPER = new XmlMapper();
- public void testAnnotationSharing() throws Exception
+ @Test
+ public void testAnnotationSharing() throws Exception
{
Wrapper input = new Wrapper();
input.points.add(new Point(1, 2));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAsObject76Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAsObject76Test.java
index 31aa4339d..376726b38 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAsObject76Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListAsObject76Test.java
@@ -1,23 +1,24 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
+import java.util.*;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// Test originally from [dataformat-xml#76].
//
// Should pass on JDK17+ too on Jackson 2.15+
@SuppressWarnings("serial")
-public class ListAsObject76Test extends XmlTestBase
+public class ListAsObject76Test extends XmlTestUtil
{
static final class Value {
@XmlElement(name = "v")
@@ -46,6 +47,7 @@ static final class Values extends LinkedList
void setValues(final List values) { this.values = values; }
}
+ @Test
public void testCollection() throws Exception {
final Values values = new XmlMapper().readValue("" +
" c " +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser393Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser393Test.java
index 8a5bc5958..353b8ea7c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser393Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser393Test.java
@@ -1,15 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
-import com.fasterxml.jackson.annotation.JsonRootName;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.ObjectMapper;
-
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-public class ListDeser393Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class ListDeser393Test extends XmlTestUtil
{
@JsonRootName("prices")
static class Prices393 {
@@ -61,6 +65,7 @@ public String getNum() {
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#393]
+ @Test
public void testDeser393() throws Exception
{
String content =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser399Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser399Test.java
index 948feb0c1..89ee084c6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser399Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser399Test.java
@@ -1,13 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class ListDeser399Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class ListDeser399Test extends XmlTestUtil
{
static class Main {
@JacksonXmlProperty(localName = "test")
@@ -22,7 +26,8 @@ static class Test {
}
private final XmlMapper MAPPER = newMapper();
-
+
+ @org.junit.jupiter.api.Test
public void testIssue399() throws Exception {
final String XML =
"\n" +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser469Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser469Test.java
index 9c9758642..b6becde9f 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser469Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeser469Test.java
@@ -1,16 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// Trying to reproduce [dataformat-xml#469]
-public class ListDeser469Test extends XmlTestBase
+public class ListDeser469Test extends XmlTestUtil
{
static class OuterBean {
@JacksonXmlProperty(localName = "Middle", namespace = "http://jackson.test.model")
@@ -71,6 +75,7 @@ protected InnerNoWrappers() { }
/**********************************************************************
*/
+ @Test
public void testIssue469WithDefaults() throws Exception
{
// Here we just use default settings (which defaults to using wrappers)
@@ -115,6 +120,7 @@ public void testIssue469WithDefaults() throws Exception
}
// But alternatively can try setting default to "no wrappers":
+ @Test
public void testIssue469WithNoWrapper() throws Exception
{
final XmlMapper mapper = XmlMapper.builder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeserializationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeserializationTest.java
index e2dda4aca..6022ff27d 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeserializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListDeserializationTest.java
@@ -1,20 +1,21 @@
package com.fasterxml.jackson.dataformat.xml.lists;
import java.math.BigDecimal;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
-import com.fasterxml.jackson.annotation.JsonAlias;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-import com.fasterxml.jackson.annotation.JsonRootName;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.SerializationFeature;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-import com.fasterxml.jackson.dataformat.xml.annotation.*;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class ListDeserializationTest extends XmlTestBase
+public class ListDeserializationTest extends XmlTestUtil
{
@JsonRootName(value = "person", namespace ="http://example.org/person" )
public static class Person
@@ -212,6 +213,7 @@ static class Price433 {
*
* Problems deserializing otherwise properly wrapped lists
*/
+ @Test
public void testWrappedList() throws Exception
{
Person p = new Person( "Name", 30 );
@@ -227,6 +229,7 @@ public void testWrappedList() throws Exception
assertEquals("note 2", result.notes.get(1));
}
+ @Test
public void testWrappedListWithGetters() throws Exception
{
PersonWithGetters p = new PersonWithGetters("abc");
@@ -241,6 +244,7 @@ public void testWrappedListWithGetters() throws Exception
assertEquals("note 2", result._notes.get(1));
}
+ @Test
public void testWrappedListBeanDeser() throws Exception
{
ListBeanWrapped bean = MAPPER.readValue(
@@ -255,6 +259,7 @@ public void testWrappedListBeanDeser() throws Exception
}
// for [dataformat-xml#33]
+ @Test
public void testWrappedListWithAttribute() throws Exception
{
ListBeanWrapped bean = MAPPER.readValue(
@@ -270,6 +275,7 @@ public void testWrappedListWithAttribute() throws Exception
assertEquals(2, bean.values.size());
}
+ @Test
public void testUnwrappedListBeanDeser() throws Exception
{
/*
@@ -292,6 +298,7 @@ public void testUnwrappedListBeanDeser() throws Exception
assertEquals(Integer.valueOf(3), bean.values.get(2));
}
+ @Test
public void testUnwrappedAliasListBeanDeser() throws Exception
{
ListBeanUnwrapped bean = MAPPER.readValue(
@@ -306,6 +313,7 @@ public void testUnwrappedAliasListBeanDeser() throws Exception
}
// [dataformat-xml#191]
+ @Test
public void testListDeser191() throws Exception
{
final String XML =
@@ -324,6 +332,7 @@ public void testListDeser191() throws Exception
}
// [dataformat-xml#256]
+ @Test
public void testListWithMixinDeser256() throws Exception
{
final String XML =
@@ -351,6 +360,7 @@ public void testListWithMixinDeser256() throws Exception
}
// [dataformat-xml#294]
+ @Test
public void testNestedLists294() throws Exception
{
RootLevel294 tree = new RootLevel294();
@@ -375,6 +385,7 @@ private Sublevel294 _newSublevel(Integer id, String sublevel) {
}
// [dataformat-xml#307]
+ @Test
public void testListDeser307() throws Exception
{
final String XML = "\n" +
@@ -400,6 +411,7 @@ public void testListDeser307() throws Exception
}
// [dataformat-xml#433]
+ @Test
public void testListDeser433() throws Exception {
final String XML =
"\n" +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListRoundtripTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListRoundtripTest.java
index f6faae2e5..03401aae3 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListRoundtripTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListRoundtripTest.java
@@ -1,14 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.*;
-public class ListRoundtripTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class ListRoundtripTest extends XmlTestUtil
{
@JsonRootName("parents")
public static class Parents {
@@ -89,6 +95,7 @@ static class Optionals {
// MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
}
+ @Test
public void testParentListRoundtrip() throws Exception
{
Parents root = new Parents();
@@ -119,6 +126,7 @@ public void testParentListRoundtrip() throws Exception
assertEquals("2", prop2.value);
}
+ @Test
public void testListWithAttrOnlyValues() throws Exception
{
PointContainer obj = new PointContainer();
@@ -143,6 +151,7 @@ public void testListWithAttrOnlyValues() throws Exception
// // [Issue#64]
+ @Test
public void testOptionals() throws Exception
{
Optionals ob = MAPPER.readValue("123-456-7890 ",
@@ -157,6 +166,7 @@ public void testOptionals() throws Exception
}
/*// comment out for release
+ @Test
public void testOptionalsWithMissingType() throws Exception
{
// Optionals ob = MAPPER.readValue("123-456-7890 ",
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListSerializationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListSerializationTest.java
index 35d544528..8ecb61d3c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListSerializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListSerializationTest.java
@@ -4,12 +4,14 @@
import java.util.ArrayList;
import java.util.List;
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-public class ListSerializationTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class ListSerializationTest extends XmlTestUtil
{
/*
/**********************************************************
@@ -53,6 +55,7 @@ public StringListBean(String... texts)
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testSimpleWrappedList() throws IOException
{
String xml = MAPPER.writeValueAsString(new ListBean(1, 2, 3));
@@ -71,6 +74,7 @@ public void testSimpleWrappedList() throws IOException
xml);
}
+ @Test
public void testStringList() throws IOException
{
StringListBean list = new StringListBean("a", "b", "c");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListWithAttributesDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListWithAttributesDeserTest.java
index 7e94f25fe..f619f953d 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListWithAttributesDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/ListWithAttributesDeserTest.java
@@ -1,16 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.databind.*;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.annotation.*;
+import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.*;
-public class ListWithAttributesDeserTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class ListWithAttributesDeserTest extends XmlTestUtil
{
// [dataformat-xml#43]
static class Name {
@@ -131,6 +134,7 @@ public void setAnother(String s) {
.build();
// [dataformat-xml#43]
+ @Test
public void testIssue43() throws Exception
{
String xmlData = ""
@@ -143,6 +147,7 @@ public void testIssue43() throws Exception
}
// [dataformat-xml#99]: allow skipping unknown properties
+ @Test
public void testListWithAttributes() throws Exception
{
String source = ""
@@ -157,6 +162,7 @@ public void testListWithAttributes() throws Exception
}
// [dataformat-xml#108]: unwrapped lists, more than one entry, id attributes
+ @Test
public void testIdsFromAttributes() throws Exception {
Foo foo = new Foo();
Bar bar1 = new Bar();
@@ -172,6 +178,7 @@ public void testIdsFromAttributes() throws Exception {
assertEquals(foo.secondBar.get(0).id, fooRead.secondBar.get(0).id);
}
+ @Test
public void testIssue301WithAttr() throws Exception {
final String XML =
"" +
@@ -187,6 +194,7 @@ public void testIssue301WithAttr() throws Exception {
}
// [dataformat-xml#314]
+ @Test
public void testDeser314Order1() throws Exception
{
String content = ""
@@ -201,6 +209,7 @@ public void testDeser314Order1() throws Exception
assertNotNull(result);
}
+ @Test
public void testDeser314Order2() throws Exception
{
String content = ""
@@ -215,6 +224,7 @@ public void testDeser314Order2() throws Exception
assertNotNull(result);
}
+ @Test
public void testDeser314Address() throws Exception
{
String content = ""
@@ -228,6 +238,7 @@ public void testDeser314Address() throws Exception
}
// [dataformat-xml#390]
+ @Test
public void testDeser390() throws Exception
{
String XML = "\n"
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists180Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists180Test.java
index 8990a2069..d8101a2b0 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists180Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists180Test.java
@@ -1,13 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class NestedUnwrappedLists180Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class NestedUnwrappedLists180Test extends XmlTestUtil
{
static class Records {
@JacksonXmlElementWrapper(useWrapping=false)
@@ -35,6 +41,7 @@ protected Field() { }
private final XmlMapper MAPPER = new XmlMapper();
+ @Test
public void testNestedUnwrappedLists180() throws Exception
{
/*
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists86Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists86Test.java
index 670e75e99..e29d27543 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists86Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedLists86Test.java
@@ -1,18 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class NestedUnwrappedLists86Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class NestedUnwrappedLists86Test extends XmlTestUtil
{
@JsonRootName("test")
public static class Issue86 {
@@ -61,6 +62,7 @@ public String toString() {
/***********************************************************************
*/
+ @Test
public void testDeserializeUnwrappedListWhenLocalNameForRootElementAndXmlPropertyMatch() throws Exception
{
final String sourceIndented =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedListsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedListsTest.java
index 19104a771..42ee031b2 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedListsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/NestedUnwrappedListsTest.java
@@ -2,13 +2,17 @@
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class NestedUnwrappedListsTest extends XmlTestBase
+public class NestedUnwrappedListsTest extends XmlTestUtil
{
// // // Test
@@ -45,6 +49,7 @@ static class VehicleActivity {
/**********************************************************************
*/
+ @Test
public void testNested1_2() throws Exception
{
final String XML =
@@ -77,6 +82,7 @@ public void testNested1_2() throws Exception
assertEquals("2013-09-12T09:29:07.536-04:00", act.recordedAtTime);
}
+ @Test
public void testNestedWithEmpty() throws Exception
{
final String XML =
@@ -94,6 +100,7 @@ public void testNestedWithEmpty() throws Exception
assertEquals(1, svc.vehicleMonitoringDelivery.size());
}
+ @Test
public void testNestedWithEmpty2() throws Exception
{
final String XML =
@@ -116,6 +123,7 @@ public void testNestedWithEmpty2() throws Exception
assertEquals(1, del.vehicleActivity.size());
}
+ @Test
public void testNested1_2b() throws Exception
{
final String XML =
@@ -149,6 +157,7 @@ public void testNested1_2b() throws Exception
assertEquals("2013-09-12T09:29:07.536-04:00", act.recordedAtTime);
}
+ @Test
public void testNested2_1() throws Exception
{
final String XML =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/PolymorphicList97Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/PolymorphicList97Test.java
index 90dfdd7b2..cfd919bd7 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/PolymorphicList97Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/PolymorphicList97Test.java
@@ -1,22 +1,24 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.List;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-import static org.hamcrest.MatcherAssert.assertThat;
+import org.junit.jupiter.api.Test;
-import org.junit.*;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.annotation.*;
-import com.fasterxml.jackson.annotation.JsonTypeInfo.*;
-import com.fasterxml.jackson.dataformat.xml.*;
-import com.fasterxml.jackson.dataformat.xml.annotation.*;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.MatcherAssert.assertThat;
/**
* @author pgelinas
*/
-public class PolymorphicList97Test extends XmlTestBase
+public class PolymorphicList97Test extends XmlTestUtil
{
@JsonTypeInfo(property = "type", use = Id.NAME)
public static abstract class Foo {
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/RootListHandlingTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/RootListHandlingTest.java
index d601314ea..ac21ac930 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/RootListHandlingTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/RootListHandlingTest.java
@@ -1,21 +1,24 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.*;
/**
* Tests for verifying that Lists (and arrays) can be serialized even
* when they are root values.
*/
-public class RootListHandlingTest extends XmlTestBase
+public class RootListHandlingTest extends XmlTestUtil
{
@JsonRootName("SR")
@JsonPropertyOrder({ "id", "name", "description" })
@@ -64,6 +67,7 @@ public void setDescription(String description) {
// Test for ensuring that we can use ".withRootName()" to override
// default name AND annotation
+ @Test
public void testRenamedRootItem() throws Exception
{
XmlMapper xmlMapper = new XmlMapper();
@@ -77,6 +81,7 @@ public void testRenamedRootItem() throws Exception
}
// for [Issue#38] -- root-level Collections not supported
+ @Test
public void testListSerialization() throws Exception
{
_testListSerialization(true);
@@ -137,6 +142,7 @@ private void _testListSerialization(boolean useWrapping) throws Exception
}
// Related to #38 as well
+ @Test
public void testArraySerialization() throws Exception
{
_testArraySerialization(true);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/StringListRoundtripTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/StringListRoundtripTest.java
index 09297c614..f8fcf914c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/StringListRoundtripTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/StringListRoundtripTest.java
@@ -1,10 +1,8 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -13,9 +11,7 @@
import static com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.Feature.PROCESS_XSI_NIL;
import static com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator.Feature.WRITE_NULLS_AS_XSI_NIL;
import static java.util.Arrays.asList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
// [dataformat-xml#584]
public class StringListRoundtripTest
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListWithEmptyCData129Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListWithEmptyCData129Test.java
index 577da05eb..48d3c1113 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListWithEmptyCData129Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListWithEmptyCData129Test.java
@@ -3,13 +3,16 @@
import java.util.List;
import jakarta.xml.bind.annotation.XmlElement;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-public class UnwrappedListWithEmptyCData129Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class UnwrappedListWithEmptyCData129Test extends XmlTestUtil
{
static class ListValues {
@XmlElement(name = "value", required = true)
@@ -25,6 +28,7 @@ static class ListValues {
}
// for [dataformat-xml#129]
+ @Test
public void testListWithEmptyCData() throws Exception
{
_testListWithEmptyCData(" ");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListsTest.java
index 1372d0b5a..69852a5a9 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedListsTest.java
@@ -2,15 +2,18 @@
import java.util.List;
-import jakarta.xml.bind.annotation.*;
+import jakarta.xml.bind.annotation.XmlElementWrapper;
+import jakarta.xml.bind.annotation.XmlRootElement;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.*;
-public class UnwrappedListsTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class UnwrappedListsTest extends XmlTestUtil
{
static class Value {
public String v;
@@ -60,6 +63,7 @@ public Optional() { }
/**********************************************************************
*/
+ @Test
public void testWrappedLists() throws Exception
{
XmlMapper mapper = new XmlMapper();
@@ -79,6 +83,7 @@ public void testWrappedLists() throws Exception
assertEquals(2, output.value.length);
}
+ @Test
public void testUnwrappedLists() throws Exception
{
XmlMapper mapper = new XmlMapper();
@@ -102,6 +107,7 @@ public void testUnwrappedLists() throws Exception
/**
* Test to verify that default wrapping setting is used
*/
+ @Test
public void testDefaultWrapping() throws Exception
{
// by default, should be using wrapping, so:
@@ -125,6 +131,7 @@ public void testDefaultWrapping() throws Exception
assertEquals(2, output.value.length);
}
+ @Test
public void testDefaultWrappingWithEmptyLists() throws Exception
{
// by default, should be using wrapping, so:
@@ -145,6 +152,7 @@ public void testDefaultWrappingWithEmptyLists() throws Exception
}
// // [Issue#64]
+ @Test
public void testOptionalsWithMissingType() throws Exception
{
XmlMapper mapper = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedPolymorphicList490Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedPolymorphicList490Test.java
index f737fd7a4..248cfec10 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedPolymorphicList490Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/UnwrappedPolymorphicList490Test.java
@@ -1,19 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
+import java.util.*;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonSubTypes;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-public class UnwrappedPolymorphicList490Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class UnwrappedPolymorphicList490Test extends XmlTestUtil
{
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
@@ -37,6 +35,7 @@ public MyType490(
}
// [dataformat-xml#490]
+ @Test
public void testPolymorphicUnwrappedList490() throws Exception
{
XmlMapper xmlMapper = XmlMapper.builder()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/WrappedListsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/WrappedListsTest.java
index 64de3b88d..25e9953d6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/WrappedListsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/lists/WrappedListsTest.java
@@ -1,13 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.lists;
-import java.util.*;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class WrappedListsTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class WrappedListsTest extends XmlTestUtil
{
static class Order {
@JacksonXmlElementWrapper(localName = "line_items")
@@ -30,6 +34,7 @@ static class ListItem {
private final XmlMapper MAPPER = xmlMapper(true);
// For [Issue#103]
+ @Test
public void testEmptyList() throws Exception
{
String xml = MAPPER.writeValueAsString(new Order());
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ArrayConversionsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ArrayConversionsTest.java
index d21131bff..61e45e04a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ArrayConversionsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ArrayConversionsTest.java
@@ -1,21 +1,23 @@
package com.fasterxml.jackson.dataformat.xml.misc;
-import java.util.*;
import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-/* NOTE: copied from jackson-databind (with some pruning)
- */
+import static org.junit.jupiter.api.Assertions.*;
/**
* Conversion tests to ensure that standard ObjectMapper conversions
* work despite XmlMapper having to add XML-specific work-arounds.
*/
-public class ArrayConversionsTest extends XmlTestBase
+public class ArrayConversionsTest extends XmlTestUtil
{
static class IntListWrapper {
public List values;
@@ -34,6 +36,7 @@ public IntArrayWrapper() { }
/********************************************************
*/
+ @Test
public void testNullXform() throws Exception {
_testNullXform(xmlMapper(true));
_testNullXform(xmlMapper(false));
@@ -52,6 +55,7 @@ private void _testNullXform(ObjectMapper mapper) throws Exception
* correctly, i.e. type -> type gives equal (although
* not necessarily same) output
*/
+ @Test
public void testArrayIdentityTransforms() throws Exception {
_testArrayIdentityTransforms(xmlMapper(true));
_testArrayIdentityTransforms(xmlMapper(false));
@@ -70,6 +74,7 @@ private void _testArrayIdentityTransforms(ObjectMapper mapper) throws Exception
verifyDoubleArrayConversion(mapper, doubles(), float[].class);
}
+ @Test
public void testByteArrayFrom() throws Exception {
_testByteArrayFrom(xmlMapper(true));
_testByteArrayFrom(xmlMapper(false));
@@ -86,6 +91,7 @@ private void _testByteArrayFrom(ObjectMapper mapper) throws Exception
verifyIntegralArrays(exp, data, exp.length);
}
+ @Test
public void testShortArrayToX() throws Exception
{
final XmlMapper mapper = new XmlMapper();
@@ -95,6 +101,7 @@ public void testShortArrayToX() throws Exception
verifyShortArrayConversion(mapper, data, long[].class);
}
+ @Test
public void testIntArrayToX() throws Exception
{
final XmlMapper mapper = new XmlMapper();
@@ -110,6 +117,7 @@ public void testIntArrayToX() throws Exception
assertEquals(expNums, actNums);
}
+ @Test
public void testLongArrayToX() throws Exception
{
final XmlMapper mapper = new XmlMapper();
@@ -123,6 +131,7 @@ public void testLongArrayToX() throws Exception
assertEquals(expNums, actNums);
}
+ @Test
public void testListToIntArray() throws Exception
{
_testListToIntArray(true);
@@ -143,6 +152,7 @@ private void _testListToIntArray(boolean wrap) throws Exception
}
}
+ @Test
public void testListAsProperty() throws Exception
{
_testListAsProperty(true);
@@ -240,7 +250,7 @@ private void verifyIntegralArrays(Object inputArray, Object outputArray, int siz
Number n2 = (Number) Array.get(outputArray, i);
double value1 = ((Number) n1).longValue();
double value2 = ((Number) n2).longValue();
- assertEquals("Entry #"+i+"/"+size+" not equal", value1, value2);
+ assertEquals(value1, value2, "Entry #"+i+"/"+size+" not equal");
}
}
@@ -251,7 +261,7 @@ private void verifyDoubleArrays(Object inputArray, Object outputArray, int size)
Number n2 = (Number) Array.get(outputArray, i);
double value1 = ((Number) n1).doubleValue();
double value2 = ((Number) n2).doubleValue();
- assertEquals("Entry #"+i+"/"+size+" not equal", value1, value2);
+ assertEquals(value1, value2, "Entry #"+i+"/"+size+" not equal");
}
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/BadEncodingTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/BadEncodingTest.java
index aef424976..30c6655e2 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/BadEncodingTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/BadEncodingTest.java
@@ -2,18 +2,22 @@
import java.util.Map;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// [dataformat-xml#428]: problem with an encoding supported via JDK
-public class BadEncodingTest extends XmlTestBase
+public class BadEncodingTest extends XmlTestUtil
{
// private static final String xml = " ";
private static final String xml = " ";
private final ObjectMapper XML_MAPPER = newMapper();
+ @Test
public void testEncoding() throws Exception {
final byte[] b = xml.getBytes("UTF-8");
assertNotNull(XML_MAPPER.readValue(b, Map.class));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/CustomAnnotationIntrospectorNoWrapperTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/CustomAnnotationIntrospectorNoWrapperTest.java
index a81177c6c..2e85ad4b7 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/CustomAnnotationIntrospectorNoWrapperTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/CustomAnnotationIntrospectorNoWrapperTest.java
@@ -5,17 +5,21 @@
import java.util.Arrays;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.PropertyName;
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.NopAnnotationIntrospector;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* A regression test for https://github.com/FasterXML/jackson-databind/issues/4595
*/
-public class CustomAnnotationIntrospectorNoWrapperTest extends XmlTestBase
+public class CustomAnnotationIntrospectorNoWrapperTest extends XmlTestUtil
{
public static class Foo {
private final List bar;
@@ -48,6 +52,7 @@ public PropertyName findWrapperName(Annotated ann) {
private final XmlMapper VANILLA_MAPPER = newMapper();
+ @Test
public void testNoWrapper() throws Exception {
Foo foo = new Foo(Arrays.asList("Value1", "Value2"));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/DTDSupportTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/DTDSupportTest.java
index b80498d4f..fe52e5779 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/DTDSupportTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/DTDSupportTest.java
@@ -2,11 +2,17 @@
import java.util.Map;
-import com.fasterxml.jackson.dataformat.xml.*;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.fail;
// for [databind-xml#211]
-public class DTDSupportTest extends XmlTestBase
+public class DTDSupportTest extends XmlTestUtil
{
+ @Test
public void testDTDAttempt() throws Exception
{
XmlMapper mapper = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ObjectId104Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ObjectId104Test.java
index 656f5d60d..da40d91dd 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ObjectId104Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/ObjectId104Test.java
@@ -3,15 +3,20 @@
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
/**
* Unit test to showcase issue #104, based on TestObjectIdDeserialization unit test in databind package.
*/
-public class ObjectId104Test extends XmlTestBase {
+public class ObjectId104Test extends XmlTestUtil {
// // Classes for external id from property annotations:
static class IdWrapper
@@ -36,6 +41,7 @@ static class ValueNode {
private final XmlMapper MAPPER = newMapper();
// Another test to ensure ordering is not required (i.e. can do front references)
+ @Test
public void testSimpleCollectionDeserWithForwardRefs() throws Exception
{
IdWrapper result = MAPPER.readValue("7 1 1 "
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/PolymorphicTypesTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/PolymorphicTypesTest.java
index 37a5efa55..8f5b0659c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/PolymorphicTypesTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/PolymorphicTypesTest.java
@@ -3,17 +3,15 @@
import java.util.ArrayList;
import java.util.List;
-import com.fasterxml.jackson.annotation.JsonCreator;
-import com.fasterxml.jackson.annotation.JsonIdentityInfo;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonSubTypes;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.annotation.ObjectIdGenerators;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-public class PolymorphicTypesTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class PolymorphicTypesTest extends XmlTestUtil
{
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY)
static class BaseTypeWithClassProperty { }
@@ -77,6 +75,7 @@ public String getProperty1() {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testAsClassProperty() throws Exception
{
String xml = MAPPER.writeValueAsString(new SubTypeWithClassProperty("Foobar"));
@@ -95,6 +94,7 @@ public void testAsClassProperty() throws Exception
assertEquals("Foobar", ((SubTypeWithClassProperty) result).name);
}
+ @Test
public void testAsClassObject() throws Exception
{
String xml = MAPPER.writeValueAsString(new SubTypeWithClassObject("Foobar"));
@@ -105,6 +105,7 @@ public void testAsClassObject() throws Exception
}
// Test for [dataformat-xml#81]
+ @Test
public void testAsPropertyWithObjectId() throws Exception
{
List data = new ArrayList();
@@ -120,6 +121,7 @@ public void testAsPropertyWithObjectId() throws Exception
}
// Test for [dataformat-xml#451]
+ @Test
public void testDeduction() throws Exception
{
String xml = MAPPER.writeValueAsString(new Child451("value1"));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameTest.java
index 59a8676bb..a4afb8310 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameTest.java
@@ -4,16 +4,21 @@
import java.util.ArrayList;
import java.util.Arrays;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.PropertyName;
-
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
// NOTE: even tho `@JacksonXmlRootElement` will be deprecated in near
// future (possibly in 2.13) -- to be replaced by `@JsonRootName` -- this
// test will use it to ensure we handle both annotations as expected
-public class RootNameTest extends XmlTestBase
+public class RootNameTest extends XmlTestUtil
{
static class RootBeanBase
{
@@ -54,6 +59,7 @@ public StringList(String...strings) {
protected XmlMapper _xmlMapper = new XmlMapper();
// Unit test to verify that root name is properly set
+ @Test
public void testRootNameAnnotation() throws IOException
{
String xml = _xmlMapper.writeValueAsString(new StringBean());
@@ -79,6 +85,7 @@ public void testRootNameAnnotation() throws IOException
}
}
+ @Test
public void testDynamicRootName() throws IOException
{
String xml;
@@ -96,6 +103,7 @@ public void testDynamicRootName() throws IOException
assertEquals("", xml);
}
+ @Test
public void testDynamicRootNameForList() throws IOException
{
String xml;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameWrapping374Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameWrapping374Test.java
index 6ec2428c2..becd2f3ce 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameWrapping374Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/RootNameWrapping374Test.java
@@ -1,13 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.misc;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// Test originally for [dataformat-xml#374] but later (2.13)
// for [dataformat-xml#485]
-public class RootNameWrapping374Test extends XmlTestBase
+public class RootNameWrapping374Test extends XmlTestUtil
{
@JsonRootName("Root")
static class Root {
@@ -28,6 +34,7 @@ static class Root {
.enable(DeserializationFeature.UNWRAP_ROOT_VALUE)
.build();
+ @Test
public void testWriteIgnoresWrapping() throws Exception
{
// Writing is without wrapping no matter what...
@@ -38,6 +45,7 @@ public void testWriteIgnoresWrapping() throws Exception
assertEquals(xmlDefault, xmlWrapEnabled);
}
+ @Test
public void testReadWithoutWrapping() throws Exception
{
String xml = DEFAULT_MAPPER.writeValueAsString(new Root());
@@ -45,6 +53,7 @@ public void testReadWithoutWrapping() throws Exception
assertNotNull(result);
}
+ @Test
public void testReadWithWrapping() throws Exception
{
String xml = DEFAULT_MAPPER.writeValueAsString(new Root());
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/SequenceWrite493Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/SequenceWrite493Test.java
index d2b85bcf8..6deb06095 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/SequenceWrite493Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/SequenceWrite493Test.java
@@ -1,17 +1,23 @@
package com.fasterxml.jackson.dataformat.xml.misc;
-import java.io.*;
+import java.io.StringWriter;
+import java.io.Writer;
import java.util.HashMap;
import java.util.Map;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.SequenceWriter;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class SequenceWrite493Test extends XmlTestBase
+public class SequenceWrite493Test extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testIssue493() throws Exception
{
try (Writer w = new StringWriter()) {
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/StreamingDecoratorsTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/StreamingDecoratorsTest.java
index 160475e01..cb74a81c2 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/StreamingDecoratorsTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/StreamingDecoratorsTest.java
@@ -2,18 +2,25 @@
import java.io.*;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.testutil.PrefixInputDecorator;
import com.fasterxml.jackson.dataformat.xml.testutil.PrefixOutputDecorator;
-public class StreamingDecoratorsTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class StreamingDecoratorsTest extends XmlTestUtil
{
@JsonRootName("wrapper")
static class Value {
public String value = "all";
}
+ @Test
public void testInputDecorators() throws IOException
{
final byte[] DOC = utf8Bytes("\n");
@@ -29,6 +36,7 @@ public void testInputDecorators() throws IOException
assertEquals("test2", value.value);
}
+ @Test
public void testOutputDecorators() throws IOException
{
final String PREFIX = "///////";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TagEscapeTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TagEscapeTest.java
index b102a43c4..113986570 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TagEscapeTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TagEscapeTest.java
@@ -1,16 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.misc;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlNameProcessors;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class TagEscapeTest extends XmlTestBase {
+public class TagEscapeTest extends XmlTestUtil {
public static class DTO {
public Map badMap = new HashMap<>();
@@ -36,6 +37,7 @@ public int hashCode() {
}
}
+ @Test
public void testGoodMapKeys() throws JsonProcessingException {
DTO dto = new DTO();
@@ -51,6 +53,7 @@ public void testGoodMapKeys() throws JsonProcessingException {
assertEquals(dto, reversed);
}
+ @Test
public void testBase64() throws JsonProcessingException {
DTO dto = new DTO();
@@ -67,6 +70,7 @@ public void testBase64() throws JsonProcessingException {
assertEquals(dto, reversed);
}
+ @Test
public void testAlwaysOnBase64() throws JsonProcessingException {
DTO dto = new DTO();
@@ -83,6 +87,7 @@ public void testAlwaysOnBase64() throws JsonProcessingException {
assertEquals(dto, reversed);
}
+ @Test
public void testReplace() throws JsonProcessingException {
DTO dto = new DTO();
@@ -103,6 +108,7 @@ public static class BadVarNameDTO {
public int $someVar$ = 5;
}
+ @Test
public void testBadVarName() throws JsonProcessingException {
BadVarNameDTO dto = new BadVarNameDTO();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TextValueTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TextValueTest.java
index cc3c6a4e0..a313c4777 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TextValueTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/TextValueTest.java
@@ -2,16 +2,18 @@
import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
-
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
-import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-import com.fasterxml.jackson.dataformat.xml.annotation.*;
+import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class TextValueTest extends XmlTestBase
+public class TextValueTest extends XmlTestUtil
{
static class Simple
{
@@ -98,6 +100,7 @@ public TextOnlyWrapper(String a, String b) {
private final XmlMapper MAPPER = new XmlMapper();
+ @Test
public void testSerializeAsText() throws IOException
{
String xml = MAPPER.writeValueAsString(new Simple());
@@ -107,6 +110,7 @@ public void testSerializeAsText() throws IOException
assertEquals("something " + DEFAULT_NEW_LINE, xml);
}
+ @Test
public void testDeserializeAsText() throws IOException
{
Simple result = MAPPER.readValue("else ", Simple.class);
@@ -114,6 +118,7 @@ public void testDeserializeAsText() throws IOException
assertEquals("else", result.text);
}
+ @Test
public void testIssue24() throws Exception
{
final String TEXT = "+/null/this is a long string";
@@ -132,6 +137,7 @@ public void testIssue24() throws Exception
}
// for [dataformat-xml#36]
+ @Test
public void testAlternateTextElementName() throws IOException
{
final String XML = "foo ";
@@ -151,6 +157,7 @@ public void testAlternateTextElementName() throws IOException
}
// [dataformat-xml#66], implicit property from "XmlText"
+ @Test
public void testIssue66() throws Exception
{
JacksonXmlModule module = new JacksonXmlModule();
@@ -169,6 +176,7 @@ public void testIssue66() throws Exception
}
// [dataformat-xml#72]
+ @Test
public void testTextOnlyPojo() throws Exception
{
XmlMapper mapper = xmlMapper(true);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappedJsonIdentityConflict286Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappedJsonIdentityConflict286Test.java
index 466cd7dbd..3eb654c8c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappedJsonIdentityConflict286Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappedJsonIdentityConflict286Test.java
@@ -1,16 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.misc;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// for [dataformat-xml#286]: parser getting confused with unwrapped lists,
// object id
-public class UnwrappedJsonIdentityConflict286Test extends XmlTestBase
+public class UnwrappedJsonIdentityConflict286Test extends XmlTestUtil
{
static class Town
{
@@ -41,6 +45,7 @@ static class School
public String name;
}
+ @Test
public void testCaseInsensitiveComplex() throws Exception
{
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappingWithXMLTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappingWithXMLTest.java
index ac47a4115..5db749ced 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappingWithXMLTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/UnwrappingWithXMLTest.java
@@ -1,13 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.misc;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
// for #12
-public class UnwrappingWithXMLTest extends XmlTestBase
+public class UnwrappingWithXMLTest extends XmlTestUtil
{
@JsonPropertyOrder({"x", "y"})
final static class Location {
@@ -86,6 +91,7 @@ public LocationWithAttributes(int x, int y) {
* Simple test to verify that explicit schema mapping works fine
* with unwrapped entities
*/
+ @Test
public void testSimpleUnwrappingRoundtrip()
throws Exception
{
@@ -101,6 +107,7 @@ public void testSimpleUnwrappingRoundtrip()
assertEquals(XML, mapper.writerFor(Unwrapping.class).writeValueAsString(wrapper));
}
+ @Test
public void testUnwrappingWithAttribute()
throws Exception
{
@@ -116,6 +123,7 @@ public void testUnwrappingWithAttribute()
assertEquals(XML, mapper.writerFor(UnwrappingWithAttributes.class).writeValueAsString(wrapper));
}
+ @Test
public void testUnwrappingSubWithAttribute()
throws Exception
{
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/XmlTextTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/XmlTextTest.java
index ee7d66009..a1abfdff3 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/XmlTextTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/misc/XmlTextTest.java
@@ -1,15 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.misc;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
-import org.junit.Assert;
-public class XmlTextTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class XmlTextTest extends XmlTestUtil
{
@JsonPropertyOrder({"first","second"})
static class Data{
@@ -61,6 +65,7 @@ static class RawValue {
private final XmlMapper MAPPER = xmlMapper(true);
+ @Test
public void testXmlTextWithSuppressedValue() throws Exception
{
final XmlMapper mapper = new XmlMapper();
@@ -71,6 +76,7 @@ public void testXmlTextWithSuppressedValue() throws Exception
}
// for [dataformat-xml#196]
+ @Test
public void testMixedContent() throws Exception
{
WindSpeed result = MAPPER.readValue(" 27 20 ",
@@ -81,6 +87,7 @@ public void testMixedContent() throws Exception
}
// for [dataformat-xml#198]
+ @Test
public void testSimple198() throws Exception
{
String xml = MAPPER.writeValueAsString(new Phone());
@@ -89,9 +96,10 @@ public void testSimple198() throws Exception
}
// for [dataformat-xml#3581]
+ @Test
public void testRawValue() throws Exception
{
String xml = MAPPER.writeValueAsString(new RawValue());
- Assert.assertEquals("b ", xml);
+ assertEquals("b ", xml);
}
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeBasicDeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeBasicDeserTest.java
index dfb373f28..88fb91ae3 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeBasicDeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeBasicDeserTest.java
@@ -1,17 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.node;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectWriter;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class JsonNodeBasicDeserTest extends XmlTestBase
+public class JsonNodeBasicDeserTest extends XmlTestUtil
{
final private ObjectMapper XML_MAPPER = newMapper();
+ @Test
public void testSimpleNode() throws Exception
{
JsonNode root = XML_MAPPER.readTree(" ");
@@ -21,6 +24,7 @@ public void testSimpleNode() throws Exception
}
// [dataformat-xml#403]: Allow sequences
+ @Test
public void testRepeated() throws Exception
{
JsonNode root = XML_MAPPER.readTree("a b ");
@@ -34,6 +38,7 @@ public void testRepeated() throws Exception
}
// [dataformat-xml#405]: support mixed content
+ @Test
public void testMixedContent() throws Exception
{
JsonNode fromXml = XML_MAPPER.readTree("first123 secondabc last ");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeMixedContent403Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeMixedContent403Test.java
index 6923d3b49..9c36bf50a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeMixedContent403Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeMixedContent403Test.java
@@ -1,16 +1,21 @@
package com.fasterxml.jackson.dataformat.xml.node;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class JsonNodeMixedContent403Test extends XmlTestBase
+public class JsonNodeMixedContent403Test extends XmlTestUtil
{
final private ObjectMapper XML_MAPPER = newMapper();
final private ObjectMapper JSON_MAPPER = new JsonMapper();
+ @Test
public void testMixedContentBefore() throws Exception
{
// First, before elements:
@@ -18,6 +23,7 @@ public void testMixedContentBefore() throws Exception
XML_MAPPER.readTree("before1 2 "));
}
+ @Test
public void testMixedContentBetween() throws Exception
{
// Second, between
@@ -25,6 +31,7 @@ public void testMixedContentBetween() throws Exception
XML_MAPPER.readTree("1 between2 "));
}
+ @Test
public void testMixedContentAfter() throws Exception
{
// and then after
@@ -32,6 +39,7 @@ public void testMixedContentAfter() throws Exception
XML_MAPPER.readTree("1 2 after "));
}
+ @Test
public void testMultipleMixedContent() throws Exception
{
// and then after
@@ -41,6 +49,7 @@ public void testMultipleMixedContent() throws Exception
}
// [dataformat-xml#226]
+ @Test
public void testMixed226() throws Exception
{
final String XML = "\n"
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeSerUnwrapped441Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeSerUnwrapped441Test.java
index 3728bd05e..c08e14ce8 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeSerUnwrapped441Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/node/JsonNodeSerUnwrapped441Test.java
@@ -1,16 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.node;
-import com.fasterxml.jackson.annotation.JsonUnwrapped;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.JsonUnwrapped;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
-public class JsonNodeSerUnwrapped441Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class JsonNodeSerUnwrapped441Test extends XmlTestUtil
{
// [dataformat-xml#441]
static class Stuff441 {
@@ -28,6 +30,7 @@ static class Stuff441 {
.with(ToXmlGenerator.Feature.UNWRAP_ROOT_OBJECT_NODE);
// [dataformat-xml#441]: before changes, work-around should be fine
+ @Test
public void testOlderWorkaround() throws Exception
{
ObjectNode xml = XML_MAPPER.createObjectNode();
@@ -42,6 +45,7 @@ public void testOlderWorkaround() throws Exception
}
// [dataformat-xml#441]
+ @Test
public void testSimpleNode() throws Exception
{
ObjectNode root = XML_MAPPER.createObjectNode();
@@ -58,6 +62,7 @@ public void testSimpleNode() throws Exception
}
// [dataformat-xml#441]
+ @Test
public void testArrayInObjectNode() throws Exception
{
ObjectNode root = XML_MAPPER.createObjectNode();
@@ -79,6 +84,7 @@ public void testArrayInObjectNode() throws Exception
// 03-Jul-2021, tatu: Would be great to further support "unwrapping" of
// properties further down but... for now not very likely to work
// but see [databind#3961] for possible improvements
+ @Test
public void testNodeAsProperty() throws Exception
{
Stuff441 stuff = new Stuff441(XML_MAPPER.createObjectNode());
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/Base64VariantWriteTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/Base64VariantWriteTest.java
index 908448a03..7827831ba 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/Base64VariantWriteTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/Base64VariantWriteTest.java
@@ -1,15 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.Base64Variant;
import com.fasterxml.jackson.core.Base64Variants;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class Base64VariantWriteTest extends XmlTestBase
+public class Base64VariantWriteTest extends XmlTestUtil
{
public static class BinaryValue {
public byte[] value;
@@ -43,6 +46,7 @@ public BinaryValue(byte[] v) {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testBinaryVariantsCompact() throws Exception
{
_testBinaryVariants(Base64Variants.MIME, XML_MIME, false);
@@ -56,6 +60,7 @@ public void testBinaryVariantsCompact() throws Exception
_testBinaryVariants(null, XML_MIME, false);
}
+ @Test
public void testBinaryVariantsPretty() throws Exception
{
_testBinaryVariants(Base64Variants.MIME, XML_MIME, true);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/CustomSerializerTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/CustomSerializerTest.java
index 143a6a60e..f750967b2 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/CustomSerializerTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/CustomSerializerTest.java
@@ -2,14 +2,18 @@
import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class CustomSerializerTest extends XmlTestBase
+public class CustomSerializerTest extends XmlTestUtil
{
@SuppressWarnings("serial")
static class CustomSerializer extends StdScalarSerializer
@@ -24,6 +28,7 @@ public void serialize(String value, JsonGenerator jgen,
}
// for [dataformat-xml#41]
+ @Test
public void testCustomSerializer() throws Exception
{
SimpleModule module = new SimpleModule();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/EmptyPolymorphicTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/EmptyPolymorphicTest.java
index 671c985f1..449ffd309 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/EmptyPolymorphicTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/EmptyPolymorphicTest.java
@@ -1,12 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.ser;
-import com.fasterxml.jackson.annotation.*;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// test(s) for [dataformat-xml#169]
-public class EmptyPolymorphicTest extends XmlTestBase
+public class EmptyPolymorphicTest extends XmlTestUtil
{
static class Data {
public String name;
@@ -35,6 +38,7 @@ static class EmptyProxy implements Proxy { }
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testEmpty() throws Exception
{
String xml = MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(new Data("Foobar"));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/IterationType302Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/IterationType302Test.java
index 914a06701..af3b5a878 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/IterationType302Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/IterationType302Test.java
@@ -3,15 +3,19 @@
import java.util.*;
import java.util.stream.Stream;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// [dataformat-xml#302] : Unable to serialize top-level Java8 Stream
-public class IterationType302Test extends XmlTestBase
+public class IterationType302Test extends XmlTestUtil
{
public static class StreamWrapper329 {
private Stream data;
@@ -85,6 +89,7 @@ public String next() {
private final ObjectMapper OBJECT_MAPPER = new XmlMapper();
+ @Test
public void testCollectionSerialization() throws Exception {
Collection list = new ArrayList<>();
list.add("a");
@@ -94,6 +99,7 @@ public void testCollectionSerialization() throws Exception {
OBJECT_MAPPER.writeValueAsString(list));
}
+ @Test
public void testListSerialization() throws Exception {
List list = new ArrayList<>();
list.add("a");
@@ -102,6 +108,7 @@ public void testListSerialization() throws Exception {
OBJECT_MAPPER.writeValueAsString(list));
}
+ @Test
public void testListIteratorSerialization() throws Exception {
List list = new ArrayList<>();
list.add("a");
@@ -113,12 +120,14 @@ public void testListIteratorSerialization() throws Exception {
}
+ @Test
public void testStreamIteratorSerialization() throws Exception {
assertEquals("- a
- b
",
OBJECT_MAPPER.writeValueAsString(Stream.of("a", "b").iterator()));
}
// [dataformat-xml#329] : Jackson ignores JacksonXmlElementWrapper on Stream
+ @Test
public void testCollectionWrapperSerialization329() throws Exception {
Collection collection = new ArrayList<>();
collection.add("a");
@@ -135,6 +144,7 @@ public void testCollectionWrapperSerialization329() throws Exception {
}
// [dataformat-xml#329] : Jackson ignores JacksonXmlElementWrapper on Stream
+ @Test
public void testIteratorWrapperSerialization329() throws Exception {
Collection collection = new ArrayList<>();
collection.add("a");
@@ -151,6 +161,7 @@ public void testIteratorWrapperSerialization329() throws Exception {
}
// [dataformat-xml#148]
+ @Test
public void testIteratorSerialization() throws Exception {
assertEquals("- 2
- 1
- 0
",
OBJECT_MAPPER.writeValueAsString(new Bean148()).trim());
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/JsonAppend578Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/JsonAppend578Test.java
index 7543faaea..bf60b9e2b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/JsonAppend578Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/JsonAppend578Test.java
@@ -1,7 +1,10 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.introspect.AnnotatedClass;
@@ -9,9 +12,11 @@
import com.fasterxml.jackson.databind.ser.VirtualBeanPropertyWriter;
import com.fasterxml.jackson.databind.util.Annotations;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class JsonAppend578Test extends XmlTestBase
+public class JsonAppend578Test extends XmlTestUtil
{
// [dataformat-xml#578]: Duplication of virtual properties
@JsonAppend(props = @JsonAppend.Prop(name = "virtual", value = MyVirtualPropertyWriter.class))
@@ -51,6 +56,7 @@ public VirtualBeanPropertyWriter withConfig(MapperConfig> config, AnnotatedCla
private final XmlMapper MAPPER = newMapper();
// [dataformat-xml#578]: Duplication of virtual properties
+ @Test
public void testJsonAppend() throws Exception {
String xml = MAPPER.writeValueAsString(new Pojo578("foo"));
assertEquals("foo bar ",xml);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/PolymorphicSerialization389Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/PolymorphicSerialization389Test.java
index be3b8d9b9..c26933a35 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/PolymorphicSerialization389Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/PolymorphicSerialization389Test.java
@@ -1,14 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.ser;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonSubTypes;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class PolymorphicSerialization389Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class PolymorphicSerialization389Test extends XmlTestUtil
{
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@@ -38,6 +39,7 @@ public class ConcreteModel extends AbstractModel {
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#389]
+ @Test
public void testIssue389() throws Exception
{
ConcreteModel concreteModel = new ConcreteModel();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/RawValueSerializationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/RawValueSerializationTest.java
index d7b811efd..a6c4f0cdb 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/RawValueSerializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/RawValueSerializationTest.java
@@ -1,12 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
// [dataformat-xml#269]
-public class RawValueSerializationTest extends XmlTestBase
+public class RawValueSerializationTest extends XmlTestUtil
{
@JsonPropertyOrder({ "id", "raw" })
static class RawWrapper {
@@ -24,6 +28,7 @@ static class RawWrapper {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testRawValueSerialization() throws Exception
{
assertEquals(""
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/SerializationNameMergingTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/SerializationNameMergingTest.java
index 52759a717..546db0159 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/SerializationNameMergingTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/SerializationNameMergingTest.java
@@ -1,12 +1,16 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
// [dataformat-xml#637]
-public class SerializationNameMergingTest extends XmlTestBase
+public class SerializationNameMergingTest extends XmlTestUtil
{
// [dataformat-xml#637]
static class NamesBean {
@@ -21,6 +25,7 @@ static class NamesBean {
// [dataformat-xml#637]
+ @Test
public void testNamespaceMerging637() throws Exception
{
assertEquals(a2q(" "),
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestBinaryStreamToXMLSerialization.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestBinaryStreamToXMLSerialization.java
index 43526ad84..be2f430db 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestBinaryStreamToXMLSerialization.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestBinaryStreamToXMLSerialization.java
@@ -1,42 +1,51 @@
package com.fasterxml.jackson.dataformat.xml.ser;
-import java.nio.*;
+import java.nio.ByteBuffer;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* See issue #270
* for details
*/
-public class TestBinaryStreamToXMLSerialization extends XmlTestBase
+public class TestBinaryStreamToXMLSerialization extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testWith0Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo());
assertEquals(" ", xml);
}
+ @Test
public void testWith1Byte() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A' ));
assertEquals("QQ== ", xml);
}
+ @Test
public void testWith2Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A', 'B' ));
assertEquals("QUI= ", xml);
}
+ @Test
public void testWith3Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A', 'B', 'C' ));
assertEquals("QUJD ", xml);
}
+ @Test
public void testWith4Bytes() throws Exception
{
String xml = MAPPER.writeValueAsString(createPojo( 'A', 'B', 'C', 'D' ));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestJDKSerializability.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestJDKSerializability.java
index 5585eab2d..70b264756 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestJDKSerializability.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestJDKSerializability.java
@@ -1,21 +1,22 @@
package com.fasterxml.jackson.dataformat.xml.ser;
import java.io.*;
-
import javax.xml.namespace.QName;
-import com.fasterxml.jackson.annotation.JsonRootName;
+
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.annotation.JsonRootName;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.dataformat.xml.*;
-import com.fasterxml.jackson.core.*;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.*;
/**
* Unit test related to core [core#31](https://github.com/FasterXML/jackson-core/issues/31)
* as it relates to XmlFactory.
*/
-public class TestJDKSerializability extends XmlTestBase
+public class TestJDKSerializability extends XmlTestUtil
{
@JsonRootName("MyPojo")
@JsonPropertyOrder({ "x", "y" })
@@ -39,6 +40,7 @@ public MyPojo(int x0, int y0) {
/**********************************************************
*/
+ @Test
public void testXmlFactory() throws Exception
{
XmlFactory f = new XmlFactory();
@@ -55,6 +57,7 @@ public void testXmlFactory() throws Exception
assertEquals(origXml, _writeXml(f2, true));
}
+ @Test
public void testMapper() throws IOException
{
XmlMapper mapper = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java
index 90bea4707..91f762dc7 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestNamespaces.java
@@ -1,13 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-public class TestNamespaces extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class TestNamespaces extends XmlTestUtil
{
final static String CHILD_NS = "uri:child";
@@ -65,6 +70,7 @@ static class ChildWithNsJsonProp {
private final XmlMapper MAPPER = newMapper();
// [dataformat-xml#26]: should prefer the "default namespace"
+ @Test
public void testRootNamespaceOlder() throws Exception
{
Person person = new Person();
@@ -73,6 +79,7 @@ public void testRootNamespaceOlder() throws Exception
}
// and a variant with `@JsonRootName`
+ @Test
public void testRootNamespaceNewer() throws Exception
{
PersonWithRootName person = new PersonWithRootName();
@@ -92,6 +99,7 @@ private void _verifyPerson(XmlMapper mapper, Object value) throws Exception
}
// [dataformat-xml#395]: should not bind standard `xml` namespace to anything
+ @Test
public void testXmlNs() throws Exception
{
String xml = MAPPER.writeValueAsString(new Issue395());
@@ -99,11 +107,13 @@ public void testXmlNs() throws Exception
assertEquals("", xml.trim());
}
+ @Test
public void testXmlNamespaceWithXmlProp() throws Exception {
_verifyChild(MAPPER, new ChildWithNsXmlProp());
}
// Jackson 2.12 allows "namespace" with `@JsonProperty` too; verify
+ @Test
public void testXmlNamespaceWithJsonProp() throws Exception {
_verifyChild(MAPPER, new ChildWithNsJsonProp());
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerialization.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerialization.java
index de4b490c4..d437d5358 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerialization.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerialization.java
@@ -1,16 +1,20 @@
package com.fasterxml.jackson.dataformat.xml.ser;
-import java.util.*;
+import java.util.LinkedHashMap;
+import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlCData;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
@SuppressWarnings("serial")
-public class TestSerialization extends XmlTestBase
+public class TestSerialization extends XmlTestUtil
{
static class StringBean2
{
@@ -97,6 +101,7 @@ static class CustomMap extends LinkedHashMap { }
private final XmlMapper _xmlMapper = new XmlMapper();
+ @Test
public void testSimpleAttribute() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new AttributeBean());
@@ -104,6 +109,7 @@ public void testSimpleAttribute() throws Exception
assertEquals("", xml);
}
+ @Test
public void testSimpleNsElem() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new NsElemBean());
@@ -112,6 +118,7 @@ public void testSimpleNsElem() throws Exception
assertEquals("blah ", xml);
}
+ @Test
public void testSimpleNsElemWithJsonProp() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new NsElemBean2());
@@ -120,6 +127,7 @@ public void testSimpleNsElemWithJsonProp() throws Exception
assertEquals("blah ", xml);
}
+ @Test
public void testSimpleAttrAndElem() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new AttrAndElem());
@@ -127,6 +135,7 @@ public void testSimpleAttrAndElem() throws Exception
assertEquals("whatever ", xml);
}
+ @Test
public void testMap() throws Exception
{
// First, map in a general wrapper
@@ -152,6 +161,7 @@ public void testMap() throws Exception
xml);
}
+ @Test
public void testNakedMap() throws Exception
{
CustomMap input = new CustomMap();
@@ -168,6 +178,7 @@ public void testNakedMap() throws Exception
assertEquals(Integer.valueOf(456), result.get("b"));
}
+ @Test
public void testCDataString() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new CDataStringBean());
@@ -175,6 +186,7 @@ public void testCDataString() throws Exception
assertEquals(" ", xml);
}
+ @Test
public void testCDataStringArray() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new CDataStringArrayBean());
@@ -184,6 +196,7 @@ public void testCDataStringArray() throws Exception
// manual 'test' to see "what would JAXB do?"
/*
+ @Test
public void testJAXB() throws Exception
{
StringWriter sw = new StringWriter();
@@ -192,6 +205,7 @@ public void testJAXB() throws Exception
}
*/
+ @Test
public void testFloatInfinity() throws Exception
{
Floats infinite = new Floats();
@@ -221,6 +235,7 @@ private void checkFloatInfinity(Floats original, boolean xmlSchemaConforming, St
assertEquals(original.elem, deserialized.elem);
}
+ @Test
public void testDoubleInfinity() throws Exception
{
Doubles infinite = new Doubles();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationAttr.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationAttr.java
index b653fa562..8b6c10b5c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationAttr.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationAttr.java
@@ -2,13 +2,16 @@
import java.util.*;
-import com.fasterxml.jackson.annotation.*;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class TestSerializationAttr extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TestSerializationAttr extends XmlTestUtil
{
static class NsAttrBean
{
@@ -60,6 +63,7 @@ public Map getProperties() {
private final XmlMapper XML_MAPPER = newMapper();
+ @Test
public void testSimpleNsAttr() throws Exception
{
String xml = XML_MAPPER.writeValueAsString(new NsAttrBean());
@@ -68,6 +72,7 @@ public void testSimpleNsAttr() throws Exception
assertEquals("", xml);
}
+ @Test
public void testIssue19() throws Exception
{
String xml = XML_MAPPER.writeValueAsString(new Issue19Bean());
@@ -79,12 +84,14 @@ public void testIssue19() throws Exception
xml);
}
+ @Test
public void testIssue6() throws Exception
{
assertEquals("",
XML_MAPPER.writeValueAsString(new Jurisdiction()));
}
+ @Test
public void testIssue117AnySetterAttrs() throws Exception
{
Map values = new HashMap();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationManual.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationManual.java
index d088e25f8..73b269725 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationManual.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationManual.java
@@ -2,13 +2,17 @@
import java.io.StringWriter;
import java.util.ArrayList;
-
import javax.xml.namespace.QName;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class TestSerializationManual extends XmlTestBase
+public class TestSerializationManual extends XmlTestUtil
{
public static class Value {
public int num;
@@ -22,6 +26,7 @@ public static class Value {
/**********************************************************
*/
+ @Test
public void testIssue54() throws Exception
{
XmlMapper xmlMapper = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationOrdering.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationOrdering.java
index b3d9712fb..c9efd7ba6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationOrdering.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationOrdering.java
@@ -1,11 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.ser;
-import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-public class TestSerializationOrdering extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class TestSerializationOrdering extends XmlTestUtil
{
@JsonPropertyOrder({"a", "c" })
static class Bean91 {
@@ -23,6 +27,7 @@ public Bean91(String a, String b, String c) {
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testOrdering() throws Exception
{
String xml = MAPPER.writeValueAsString(new Bean91("1", "2", "3"));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationWithFilter.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationWithFilter.java
index bfe3864d0..87bcc527a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationWithFilter.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationWithFilter.java
@@ -1,23 +1,27 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonFilter;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.FilterProvider;
-import com.fasterxml.jackson.databind.ser.PropertyFilter;
-import com.fasterxml.jackson.databind.ser.PropertyWriter;
+import com.fasterxml.jackson.databind.ser.*;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Unit test for [PullRequest#616], problems with filtered serialization.
*/
-public class TestSerializationWithFilter extends XmlTestBase
+public class TestSerializationWithFilter extends XmlTestUtil
{
@JsonFilter("filter")
+ @JsonPropertyOrder({ "b", "c" })
static class Item
{
@JacksonXmlText
@@ -26,6 +30,7 @@ static class Item
public int c;
}
+ @Test
public void testPullRequest616() throws Exception
{
Item bean = new Item();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializerCustom.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializerCustom.java
index 655f6122d..bc9a3c050 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializerCustom.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializerCustom.java
@@ -2,6 +2,8 @@
import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
@@ -9,13 +11,16 @@
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Unit test(s) for [Issue#42], problems with custom (de)serializer.
*/
@SuppressWarnings("serial")
-public class TestSerializerCustom extends XmlTestBase
+public class TestSerializerCustom extends XmlTestUtil
{
@JsonPropertyOrder({ "name", "obj" })
static class Item {
@@ -73,6 +78,7 @@ public void serialize(Item value, JsonGenerator jgen, SerializerProvider provide
/**********************************************************
*/
+ @Test
public void testIssue42() throws Exception
{
XmlMapper xmlMapper = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestXmlDeclaration.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestXmlDeclaration.java
index 5edc85625..39993066e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestXmlDeclaration.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestXmlDeclaration.java
@@ -1,9 +1,13 @@
package com.fasterxml.jackson.dataformat.xml.ser;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class TestXmlDeclaration extends XmlTestBase
+public class TestXmlDeclaration extends XmlTestUtil
{
/*
/**********************************************************
@@ -11,6 +15,7 @@ public class TestXmlDeclaration extends XmlTestBase
/**********************************************************
*/
+ @Test
public void testXml10Declaration() throws Exception
{
XmlMapper mapper = new XmlMapper();
@@ -19,6 +24,7 @@ public void testXml10Declaration() throws Exception
assertEquals(xml, "123 ");
}
+ @Test
public void testXml11Declaration() throws Exception
{
XmlMapper mapper = new XmlMapper();
@@ -26,5 +32,26 @@ public void testXml11Declaration() throws Exception
String xml = mapper.writeValueAsString(new StringBean("abcd"));
assertEquals(xml, "abcd ");
}
+
+ @Test
+ public void testXml11DeclarationWithStandalone() throws Exception
+ {
+ XmlMapper mapper = new XmlMapper();
+ mapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
+ mapper.configure(ToXmlGenerator.Feature.WRITE_XML_1_1, true);
+ mapper.configure(ToXmlGenerator.Feature.WRITE_STANDALONE_YES_TO_XML_DECLARATION, true);
+ String xml = mapper.writeValueAsString(new StringBean("abcd"));
+ assertEquals("abcd ", xml);
+ }
+
+ @Test
+ public void testXml10DeclarationWithStandalone() throws Exception
+ {
+ XmlMapper mapper = new XmlMapper();
+ mapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
+ mapper.configure(ToXmlGenerator.Feature.WRITE_STANDALONE_YES_TO_XML_DECLARATION, true);
+ String xml = mapper.writeValueAsString(new StringBean("abcd"));
+ assertEquals("abcd ", xml);
+ }
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XmlPrettyPrinterTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XmlPrettyPrinterTest.java
index 991c563c6..fef3ce669 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XmlPrettyPrinterTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XmlPrettyPrinterTest.java
@@ -2,17 +2,22 @@
import java.util.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.PrettyPrinter;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.util.DefaultXmlPrettyPrinter;
-public class XmlPrettyPrinterTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class XmlPrettyPrinterTest extends XmlTestUtil
{
static class StringWrapperBean {
public StringWrapper string;
@@ -84,9 +89,8 @@ static enum EmployeeType {
protected XmlMapper _xmlMapper;
// let's actually reuse XmlMapper to make things bit faster
- @Override
+ @BeforeEach
public void setUp() throws Exception {
- super.setUp();
_xmlMapper = new XmlMapper();
_xmlMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
}
@@ -98,6 +102,7 @@ public void setUp() throws Exception {
*/
// Verify [dataformat-xml#1]
+ @Test
public void testSimpleStringBean() throws Exception
{
StringWrapperBean input = new StringWrapperBean("abc");
@@ -122,6 +127,7 @@ public void testSimpleStringBean() throws Exception
assertEquals("abc", result.string.str);
}
+ @Test
public void testSimpleIntBean() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new IntWrapperBean(42));
@@ -135,6 +141,7 @@ public void testSimpleIntBean() throws Exception
assertEquals(42, result.wrapped.i);
}
+ @Test
public void testSimpleMap() throws Exception
{
Map map = new HashMap();
@@ -154,6 +161,7 @@ public void testSimpleMap() throws Exception
}
// [dataformat-xml#45]: Use of attributes should not force linefeed for empty elements
+ @Test
public void testWithAttr() throws Exception
{
String xml = _xmlMapper.writeValueAsString(new AttrBean());
@@ -166,6 +174,7 @@ public void testWithAttr() throws Exception
xml2);
}
+ @Test
public void testEmptyElem() throws Exception
{
PojoFor123 simple = new PojoFor123("foobar");
@@ -174,6 +183,7 @@ public void testEmptyElem() throws Exception
xml);
}
+ @Test
public void testMultiLevel172() throws Exception
{
Company root = new Company();
@@ -196,6 +206,7 @@ public void testMultiLevel172() throws Exception
xml);
}
+ @Test
public void testNewLine_withCustomNewLine() throws Exception {
String customNewLine = "\n\rLF\n\r";
PrettyPrinter customXmlPrettyPrinter = new DefaultXmlPrettyPrinter().withCustomNewLine(customNewLine);
@@ -223,6 +234,7 @@ public void testNewLine_withCustomNewLine() throws Exception {
xml);
}
+ @Test
public void testNewLine_systemDefault() throws Exception {
Company root = new Company();
root.employee.add(new Employee("abc"));
@@ -247,6 +259,7 @@ public void testNewLine_systemDefault() throws Exception {
xml);
}
+ @Test
public void testNewLine_UseSystemDefaultLineSeperatorOnNullCustomNewLine() throws Exception {
Company root = new Company();
root.employee.add(new Employee("abc"));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiNilSerializationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiNilSerializationTest.java
index 59f3c2a2c..f6a5690ee 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiNilSerializationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiNilSerializationTest.java
@@ -2,11 +2,15 @@
import java.io.IOException;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
// [dataformat-xml#360]
-public class XsiNilSerializationTest extends XmlTestBase
+public class XsiNilSerializationTest extends XmlTestUtil
{
static class WrapperBean
{
@@ -21,6 +25,7 @@ public WrapperBean() { }
.build();
// [dataformat-xml#360]
+ @Test
public void testNilPropertyNoIndent() throws IOException
{
assertEquals(" ",
@@ -28,6 +33,7 @@ public void testNilPropertyNoIndent() throws IOException
}
// [dataformat-xml#360]
+ @Test
public void testNilPropertyRoot() throws IOException
{
// Not sure root element name defined but... "" is what it is :)
@@ -36,6 +42,7 @@ public void testNilPropertyRoot() throws IOException
}
// [dataformat-xml#432]
+ @Test
public void testNilPropertyWithIndent() throws IOException
{
final String xml = MAPPER.writerWithDefaultPrettyPrinter()
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiTypeWriteTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiTypeWriteTest.java
index 49c613bd5..c76be43dd 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiTypeWriteTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/XsiTypeWriteTest.java
@@ -1,15 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.ser;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonRootName;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
// [dataformat-xml#324]
-public class XsiTypeWriteTest extends XmlTestBase
+public class XsiTypeWriteTest extends XmlTestUtil
{
@JsonRootName("Typed")
static class TypeBean {
@@ -31,12 +33,14 @@ static class PolyBean {
.configure(ToXmlGenerator.Feature.AUTO_DETECT_XSI_TYPE, true)
.build();
+ @Test
public void testExplicitXsiTypeWriteDisabled() throws Exception
{
assertEquals("abc ",
NO_XSI_MAPPER.writeValueAsString(new TypeBean()));
}
+ @Test
public void testExplicitXsiTypeWriteEnabled() throws Exception
{
assertEquals(
@@ -44,6 +48,7 @@ public void testExplicitXsiTypeWriteEnabled() throws Exception
a2q(XSI_ENABLED_MAPPER.writeValueAsString(new TypeBean())));
}
+ @Test
public void testXsiTypeAsTypeIdWriteDisabled() throws Exception
{
// not legal XML but with explicitly specified name is what caller wants
@@ -53,6 +58,7 @@ public void testXsiTypeAsTypeIdWriteDisabled() throws Exception
a2q(NO_XSI_MAPPER.writeValueAsString(new PolyBean())));
}
+ @Test
public void testXsiTypeAsTypeIdWriteEnabled() throws Exception
{
assertEquals(
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/dos/CyclicXMLDataSerTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/dos/CyclicXMLDataSerTest.java
index d640e8e29..58f05c8a6 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/dos/CyclicXMLDataSerTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/ser/dos/CyclicXMLDataSerTest.java
@@ -3,21 +3,25 @@
import java.util.ArrayList;
import java.util.List;
-import com.fasterxml.jackson.core.StreamWriteConstraints;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.core.StreamWriteConstraints;
import com.fasterxml.jackson.databind.DatabindException;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Simple unit tests to verify that we fail gracefully if you attempt to serialize
* data that is cyclic (eg a list that contains itself).
*/
-public class CyclicXMLDataSerTest extends XmlTestBase
+public class CyclicXMLDataSerTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testListWithSelfReference() throws Exception {
// Avoid direct loop as serializer might be able to catch
List list1 = new ArrayList<>();
@@ -30,8 +34,8 @@ public void testListWithSelfReference() throws Exception {
} catch (DatabindException e) {
String exceptionPrefix = String.format("Document nesting depth (%d) exceeds the maximum allowed",
StreamWriteConstraints.DEFAULT_MAX_DEPTH + 1);
- assertTrue("Exception message is as expected?",
- e.getMessage().startsWith(exceptionPrefix));
+ assertTrue(e.getMessage().startsWith(exceptionPrefix),
+ "Exception message is as expected?");
}
}
}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/FormatDetectionTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/FormatDetectionTest.java
index bcbb85ab7..948f0a6a7 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/FormatDetectionTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/FormatDetectionTest.java
@@ -1,18 +1,22 @@
package com.fasterxml.jackson.dataformat.xml.stream;
import java.io.ByteArrayInputStream;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
-import com.fasterxml.jackson.core.*;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.format.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-public class FormatDetectionTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class FormatDetectionTest extends XmlTestUtil
{
static class POJO {
public int x, y;
@@ -37,6 +41,7 @@ static class ListPOJO {
private final XmlFactory XML_F = new XmlFactory();
+ @Test
public void testSimpleValidXmlDecl() throws Exception
{
DataFormatDetector detector = new DataFormatDetector(XML_F);
@@ -54,6 +59,7 @@ public void testSimpleValidXmlDecl() throws Exception
}
}
+ @Test
public void testSimpleValidRoot() throws Exception
{
DataFormatDetector detector = new DataFormatDetector(XML_F);
@@ -72,6 +78,7 @@ public void testSimpleValidRoot() throws Exception
}
}
+ @Test
public void testSimpleValidDoctype() throws Exception
{
DataFormatDetector detector = new DataFormatDetector(XML_F);
@@ -89,6 +96,7 @@ public void testSimpleValidDoctype() throws Exception
}
}
+ @Test
public void testSimpleValidComment() throws Exception
{
DataFormatDetector detector = new DataFormatDetector(XML_F);
@@ -104,6 +112,7 @@ public void testSimpleValidComment() throws Exception
}
}
+ @Test
public void testSimpleValidPI() throws Exception
{
DataFormatDetector detector = new DataFormatDetector(XML_F);
@@ -119,6 +128,7 @@ public void testSimpleValidPI() throws Exception
}
}
+ @Test
public void testSimpleViaObjectReader() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
@@ -133,6 +143,7 @@ public void testSimpleViaObjectReader() throws Exception
assertEquals(3, pojo.y);
}
+ @Test
public void testListViaObjectReader() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
@@ -156,6 +167,7 @@ public void testListViaObjectReader() throws Exception
/**********************************************************
*/
+ @Test
public void testSimpleInvalid() throws Exception
{
DataFormatDetector detector = new DataFormatDetector(XML_F);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/StreamCapabilitiesTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/StreamCapabilitiesTest.java
index f152ca6ff..59eb57be0 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/StreamCapabilitiesTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/StreamCapabilitiesTest.java
@@ -1,15 +1,19 @@
package com.fasterxml.jackson.dataformat.xml.stream;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.StreamReadCapability;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
-public class StreamCapabilitiesTest extends XmlTestBase
+public class StreamCapabilitiesTest extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
+ @Test
public void testReadCapabilities() throws Exception
{
try (JsonParser p = MAPPER.createParser(" ")) {
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlGeneratorTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlGeneratorTest.java
index 9852322c8..afe55b8b3 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlGeneratorTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlGeneratorTest.java
@@ -1,19 +1,22 @@
package com.fasterxml.jackson.dataformat.xml.stream;
-import java.io.*;
-
+import java.io.File;
+import java.io.StringWriter;
import javax.xml.namespace.QName;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
-public class XmlGeneratorTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class XmlGeneratorTest extends XmlTestUtil
{
private final XmlFactory XML_F = new XmlFactory();
+ @Test
public void testSimpleElement() throws Exception
{
StringWriter out = new StringWriter();
@@ -31,6 +34,7 @@ public void testSimpleElement() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testNullValuedElement() throws Exception
{
// First explicitly written
@@ -58,6 +62,7 @@ public void testNullValuedElement() throws Exception
assertEquals(" ", xml);
}
+ @Test
public void testSimpleAttribute() throws Exception
{
StringWriter out = new StringWriter();
@@ -77,6 +82,7 @@ public void testSimpleAttribute() throws Exception
assertEquals("", xml);
}
+ @Test
public void testSecondLevelAttribute() throws Exception
{
StringWriter out = new StringWriter();
@@ -98,6 +104,7 @@ public void testSecondLevelAttribute() throws Exception
assertEquals(" ", xml);
}
+ @Test
public void testAttrAndElem() throws Exception
{
StringWriter out = new StringWriter();
@@ -120,6 +127,7 @@ public void testAttrAndElem() throws Exception
}
// [Issue#6], missing overrides for File-backed generator
+ @Test
public void testWriteToFile() throws Exception
{
ObjectMapper mapper = new XmlMapper();
@@ -132,6 +140,7 @@ public void testWriteToFile() throws Exception
f.delete();
}
+ @Test
public void testRawSimpleValue() throws Exception
{
StringWriter out = new StringWriter();
@@ -149,6 +158,7 @@ public void testRawSimpleValue() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testRawOffsetValue() throws Exception
{
StringWriter out = new StringWriter();
@@ -166,6 +176,7 @@ public void testRawOffsetValue() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testRawCharArrayValue() throws Exception
{
StringWriter out = new StringWriter();
@@ -183,6 +194,7 @@ public void testRawCharArrayValue() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testRawSimpleValueUnwrapped() throws Exception
{
StringWriter out = new StringWriter();
@@ -201,6 +213,7 @@ public void testRawSimpleValueUnwrapped() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testRawOffsetValueUnwrapped() throws Exception
{
StringWriter out = new StringWriter();
@@ -219,6 +232,7 @@ public void testRawOffsetValueUnwrapped() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testRawCharArrayValueUnwrapped() throws Exception
{
StringWriter out = new StringWriter();
@@ -237,6 +251,7 @@ public void testRawCharArrayValueUnwrapped() throws Exception
assertEquals("value ", xml);
}
+ @Test
public void testRawSimpleAttribute() throws Exception
{
StringWriter out = new StringWriter();
@@ -256,6 +271,7 @@ public void testRawSimpleAttribute() throws Exception
assertEquals("", xml);
}
+ @Test
public void testRawOffsetAttribute() throws Exception
{
StringWriter out = new StringWriter();
@@ -275,6 +291,7 @@ public void testRawOffsetAttribute() throws Exception
assertEquals("", xml);
}
+ @Test
public void testRawCharArratAttribute() throws Exception
{
StringWriter out = new StringWriter();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParser442Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParser442Test.java
index 765be4b34..1d55722dc 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParser442Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParser442Test.java
@@ -1,16 +1,21 @@
package com.fasterxml.jackson.dataformat.xml.stream;
-import com.fasterxml.jackson.core.JsonToken;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
-public class XmlParser442Test extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class XmlParser442Test extends XmlTestUtil
{
private final XmlMapper MAPPER = newMapper();
// For [dataformat-xml#442]
+ @Test
public void testMixedContentBeforeElement442() throws Exception
{
final String XML =
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserNextXxxTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserNextXxxTest.java
index ac9b6921f..93ea9e35e 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserNextXxxTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserNextXxxTest.java
@@ -1,22 +1,26 @@
package com.fasterxml.jackson.dataformat.xml.stream;
-import java.io.*;
+import java.io.StringReader;
-import com.fasterxml.jackson.core.*;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
-public class XmlParserNextXxxTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class XmlParserNextXxxTest extends XmlTestUtil
{
protected JsonFactory _jsonFactory;
protected XmlFactory _xmlFactory;
// let's actually reuse XmlMapper to make things bit faster
- @Override
+ @BeforeEach
public void setUp() throws Exception {
- super.setUp();
_xmlFactory = new XmlFactory();
}
@@ -27,6 +31,7 @@ public void setUp() throws Exception {
*/
// [dataformat-xml#204]
+ @Test
public void testXmlAttributesWithNextTextValue() throws Exception
{
final String XML = "";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserTest.java
index 12a8fcb1e..fb5a1007c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlParserTest.java
@@ -2,17 +2,18 @@
import java.io.*;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.JsonParser.NumberType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
-public class XmlParserTest extends XmlTestBase
+import static org.junit.jupiter.api.Assertions.*;
+
+public class XmlParserTest extends XmlTestUtil
{
protected final JsonFactory _jsonFactory = new JsonFactory();
protected final XmlMapper _xmlMapper = newMapper();
@@ -24,6 +25,7 @@ public class XmlParserTest extends XmlTestBase
/**********************************************************************
*/
+ @Test
public void testSimplest() throws Exception
{
final String XML = "abc ";
@@ -35,9 +37,15 @@ public void testSimplest() throws Exception
assertEquals(1, p.getParsingContext().getNestingDepth());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("leaf", p.currentName());
+ assertEquals("leaf", p.getText());
+ assertEquals("leaf", p.getValueAsString());
+ assertEquals("leaf", p.getValueAsString("x"));
assertEquals(1, p.getParsingContext().getNestingDepth());
assertToken(JsonToken.VALUE_STRING, p.nextToken());
assertEquals("abc", p.getText());
+ assertEquals("abc", p.getText());
+ assertEquals("abc", p.getValueAsString());
+ assertEquals("abc", p.getValueAsString("x"));
assertEquals(1, p.getParsingContext().getNestingDepth());
assertToken(JsonToken.END_OBJECT, p.nextToken());
assertEquals(0, p.getParsingContext().getNestingDepth());
@@ -46,6 +54,7 @@ public void testSimplest() throws Exception
}
}
+ @Test
public void testSimpleWithEmpty() throws Exception
{
// 21-Jun-2017, tatu: Depends on setting actually...
@@ -82,6 +91,7 @@ public void testSimpleWithEmpty() throws Exception
* Test that verifies coercion of a "simple" cdata segment within root element
* as matching scalar token, similar to how other elements work.
*/
+ @Test
public void testRootScalar() throws Exception
{
// 02-Jul-2020, tatu: Does not work quite yet
@@ -99,6 +109,7 @@ public void testRootScalar() throws Exception
}
}
+ @Test
public void testRootMixed() throws Exception
{
// 02-Jul-2020, tatu: Does not work quite yet
@@ -127,6 +138,7 @@ public void testRootMixed() throws Exception
/**********************************************************************
*/
+ @Test
public void testSimpleNested() throws Exception
{
assertEquals("{\"a\":{\"b\":{\"c\":\"xyz\"}}}",
@@ -138,6 +150,7 @@ public void testSimpleNested() throws Exception
* specification as XML, and read it back in "as JSON", with
* expected transformation.
*/
+ @Test
public void testRoundTripWithSample() throws Exception
{
// First: let's convert from sample JSON doc to default xml output
@@ -225,6 +238,7 @@ public void testRoundTripWithSample() throws Exception
* Test to ensure functionality used to force an element to be reported
* as "JSON" Array, instead of default Object.
*/
+ @Test
public void testForceElementAsArray() throws Exception
{
final String XML = "value 123 1 ";
@@ -263,7 +277,7 @@ public void testForceElementAsArray() throws Exception
assertTrue(xp.getParsingContext().inObject()); // true until we do following:
// must request 'as-array' handling, which will "convert" current token:
- assertTrue("Should 'convert' START_OBJECT to START_ARRAY", xp.isExpectedStartArrayToken());
+ assertTrue(xp.isExpectedStartArrayToken(), "Should 'convert' START_OBJECT to START_ARRAY");
assertToken(JsonToken.START_ARRAY, xp.getCurrentToken()); //
assertTrue(xp.getParsingContext().inArray());
@@ -295,6 +309,7 @@ public void testForceElementAsArray() throws Exception
xp.close();
}
+ @Test
public void testXmlAttributes() throws Exception
{
final String XML = "";
@@ -326,6 +341,7 @@ public void testXmlAttributes() throws Exception
xp.close();
}
+ @Test
public void testMixedContent() throws Exception
{
String exp = a2q("{'':'first','a':'123','':'second','b':'456','':'last'}");
@@ -335,6 +351,7 @@ public void testMixedContent() throws Exception
assertEquals(exp, result);
}
+ @Test
public void testInferredNumbers() throws Exception
{
final String XML = "123456789012 ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlTokenStreamTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlTokenStreamTest.java
index 2936ef061..f97fc6c03 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlTokenStreamTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/XmlTokenStreamTest.java
@@ -1,23 +1,23 @@
package com.fasterxml.jackson.dataformat.xml.stream;
-import java.io.*;
+import java.io.StringReader;
+import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.*;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.io.ContentReference;
-
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlNameProcessors;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser;
import com.fasterxml.jackson.dataformat.xml.deser.XmlTokenStream;
+import static org.junit.jupiter.api.Assertions.assertEquals;
// NOTE: test changed a lot between 2.13 and 2.14:
-public class XmlTokenStreamTest extends XmlTestBase
+public class XmlTokenStreamTest extends XmlTestUtil
{
private final XmlFactory XML_FACTORY = newMapper().getFactory();
+ @Test
public void testSimple() throws Exception
{
XmlTokenStream tokens = _tokensFor("abc ");
@@ -39,6 +39,7 @@ public void testSimple() throws Exception
assertEquals(XmlTokenStream.XML_END, tokens.next());
}
+ @Test
public void testRootAttributes() throws Exception
{
_testRootAttributes(true); // empty tag as null
@@ -69,6 +70,7 @@ public void _testRootAttributes(boolean emptyAsNull) throws Exception
assertEquals(XmlTokenStream.XML_END, tokens.next());
}
+ @Test
public void testEmptyTags() throws Exception
{
_testEmptyTags(true); // empty tag as null
@@ -98,6 +100,7 @@ private void _testEmptyTags(boolean emptyAsNull) throws Exception
assertEquals(XmlTokenStream.XML_END, tokens.next());
}
+ @Test
public void testNested() throws Exception
{
XmlTokenStream tokens = _tokensFor( "abc ");
@@ -119,6 +122,7 @@ public void testNested() throws Exception
}
// For [dataformat-xml#402]
+ @Test
public void testMixedContentBetween() throws Exception
{
XmlTokenStream tokens = _tokensFor("first123 and second abc \n ");
@@ -149,6 +153,7 @@ public void testMixedContentBetween() throws Exception
}
// For [dataformat-xml#402]
+ @Test
public void testMixedContentAfter() throws Exception
{
XmlTokenStream tokens = _tokensFor("first123 last & final ");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java
index 4b3593f5d..dcda01ebf 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/DeepNestingParserTest.java
@@ -1,13 +1,18 @@
package com.fasterxml.jackson.dataformat.xml.stream.dos;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.exc.StreamReadException;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
-public class DeepNestingParserTest extends XmlTestBase {
+public class DeepNestingParserTest extends XmlTestUtil {
+ @Test
public void testDeepDoc() throws Exception
{
final XmlMapper xmlMapper = newMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/TokenCountTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/TokenCountTest.java
index cb74eae99..3116c7733 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/TokenCountTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/stream/dos/TokenCountTest.java
@@ -1,13 +1,15 @@
package com.fasterxml.jackson.dataformat.xml.stream.dos;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.core.exc.StreamConstraintsException;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.*;
+
+import static org.junit.jupiter.api.Assertions.*;
-public class TokenCountTest extends XmlTestBase
+public class TokenCountTest extends XmlTestUtil
{
final XmlMapper XML_MAPPER;
{
@@ -20,6 +22,7 @@ public class TokenCountTest extends XmlTestBase
XML_MAPPER = mapperBuilder(factory).build();
}
+ @Test
public void testTokenCount10() throws Exception
{
final String XML = createDeepNestedDoc(10);
@@ -29,6 +32,7 @@ public void testTokenCount10() throws Exception
}
}
+ @Test
public void testTokenCount100() throws Exception
{
final String XML = createDeepNestedDoc(100);
@@ -38,6 +42,7 @@ public void testTokenCount100() throws Exception
}
}
+ @Test
public void testDeepDoc() throws Exception
{
final String XML = createDeepNestedDoc(1000);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/NoCheckSubTypeValidator.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/NoCheckSubTypeValidator.java
index ff66a424c..283464a23 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/NoCheckSubTypeValidator.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/NoCheckSubTypeValidator.java
@@ -1,6 +1,6 @@
package com.fasterxml.jackson.dataformat.xml.testutil;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.cfg.MapperConfig;
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixInputDecorator.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixInputDecorator.java
index 1f7d0a84a..9620296a2 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixInputDecorator.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixInputDecorator.java
@@ -1,11 +1,6 @@
package com.fasterxml.jackson.dataformat.xml.testutil;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.SequenceInputStream;
-import java.io.StringReader;
+import java.io.*;
import java.nio.charset.StandardCharsets;
import com.fasterxml.jackson.core.io.IOContext;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixOutputDecorator.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixOutputDecorator.java
index f0966af0a..c791ba55a 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixOutputDecorator.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/PrefixOutputDecorator.java
@@ -1,9 +1,6 @@
package com.fasterxml.jackson.dataformat.xml.testutil;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
+import java.io.*;
import com.fasterxml.jackson.core.io.IOContext;
import com.fasterxml.jackson.core.io.OutputDecorator;
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestFailureExpected.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestFailureExpected.java
new file mode 100644
index 000000000..4c08bd727
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestFailureExpected.java
@@ -0,0 +1,38 @@
+package com.fasterxml.jackson.dataformat.xml.testutil.failure;
+
+import java.lang.annotation.*;
+
+import org.junit.jupiter.api.extension.ExtendWith;
+
+/**
+ *
+ * Annotation used to indicate that a JUnit-5 based tests method is expected to fail.
+ *
+ *
+ * When a test method is annotated with {@code @JacksonTestFailureExpected}, the
+ * {@link JacksonTestFailureExpectedInterceptor} will intercept the test execution.
+ * If the test passes, which is an unexpected behavior, the interceptor will throw an exception to fail the test,
+ * indicating that the test was expected to fail but didn't.
+ *
+ *
+ * Usage Example:
+ *
+ *
+ *
+ * @Test
+ * @JacksonTestFailureExpected
+ * @Test
+ public void testFeatureNotYetImplemented() {
+ * // Test code that is expected to fail
+ * }
+ * }
+ *
+ *
+ *
+ *
+ * @since 2.19
+ */
+@Target({ElementType.METHOD})
+@Retention(RetentionPolicy.RUNTIME)
+@ExtendWith(JacksonTestFailureExpectedInterceptor.class)
+public @interface JacksonTestFailureExpected { }
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestFailureExpectedInterceptor.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestFailureExpectedInterceptor.java
new file mode 100644
index 000000000..e46d981c5
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestFailureExpectedInterceptor.java
@@ -0,0 +1,43 @@
+package com.fasterxml.jackson.dataformat.xml.testutil.failure;
+
+import java.lang.reflect.Method;
+
+import org.junit.jupiter.api.extension.*;
+
+/**
+ * Custom {@link InvocationInterceptor} that intercepts test method invocation.
+ * To pass the test ***only if*** test fails with an exception, and fail the test otherwise.
+ *
+ * @since 2.19
+ */
+public class JacksonTestFailureExpectedInterceptor
+ implements InvocationInterceptor
+{
+ @Override
+ public void interceptTestMethod(Invocation invocation,
+ ReflectiveInvocationContext invocationContext, ExtensionContext extensionContext)
+ throws Throwable
+ {
+ try {
+ invocation.proceed();
+ } catch (Throwable t) {
+ // do-nothing, we do expect an exception
+ return;
+ }
+ handleUnexpectePassingTest(invocationContext);
+ }
+
+ private void handleUnexpectePassingTest(ReflectiveInvocationContext invocationContext) {
+ // Collect information we need
+ Object targetClass = invocationContext.getTargetClass();
+ Object testMethod = invocationContext.getExecutable().getName();
+ //List arguments = invocationContext.getArguments();
+
+ // Create message
+ String message = String.format("Test method %s.%s() passed, but should have failed", targetClass, testMethod);
+
+ // throw exception
+ throw new JacksonTestShouldFailException(message);
+ }
+
+}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestShouldFailException.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestShouldFailException.java
new file mode 100644
index 000000000..1436001f3
--- /dev/null
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/testutil/failure/JacksonTestShouldFailException.java
@@ -0,0 +1,18 @@
+package com.fasterxml.jackson.dataformat.xml.testutil.failure;
+
+/**
+ * Exception used to alert that a test is passing, but should be failing.
+ *
+ * WARNING : This only for test code, and should never be thrown from production code.
+ *
+ * @since 2.19
+ */
+public class JacksonTestShouldFailException
+ extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public JacksonTestShouldFailException(String msg) {
+ super(msg);
+ }
+}
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ConflictingGetters27Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/ConflictingGetters27Test.java
similarity index 82%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ConflictingGetters27Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/ConflictingGetters27Test.java
index 035252168..2aa3ea648 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ConflictingGetters27Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/ConflictingGetters27Test.java
@@ -1,13 +1,19 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonRootName;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// For [dataformat-xml#27]
-public class ConflictingGetters27Test extends XmlTestBase
+public class ConflictingGetters27Test extends XmlTestUtil
{
// [dataformat-xml#27]
@JsonRootName("output")
@@ -49,6 +55,8 @@ public BeanInfo() { }
*/
// [dataformat-xml#27]
+ @JacksonTestFailureExpected
+ @Test
public void testIssue27() throws Exception
{
XmlMapper mapper = new XmlMapper();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ElementWrapperViaCreator149Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/ElementWrapperViaCreator149Test.java
similarity index 80%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ElementWrapperViaCreator149Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/ElementWrapperViaCreator149Test.java
index 7477515b0..c4b501ef7 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/ElementWrapperViaCreator149Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/ElementWrapperViaCreator149Test.java
@@ -1,20 +1,26 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.util.Arrays;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// 13-Nov-2020, tatu: Not quite sure how to configure test to pass;
// seems like it should work but does not. Leaving for future generations
// to figure out...
-public class ElementWrapperViaCreator149Test extends XmlTestBase
+public class ElementWrapperViaCreator149Test extends XmlTestUtil
{
@JsonRootName("body")
static class Body149 {
@@ -44,6 +50,8 @@ public Body149(@JacksonXmlProperty(localName="type")
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#149]
+ @JacksonTestFailureExpected
+ @Test
public void testElementWrapper149() throws Exception
{
final String XML = "\n" +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/EnumIssue9Test.java
similarity index 78%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/EnumIssue9Test.java
index c7988819c..9c350550c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/EnumIssue9Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/EnumIssue9Test.java
@@ -1,12 +1,16 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import org.junit.jupiter.api.Test;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.*;
// related to [dataformat-xml#9] (and possibly others)
-public class EnumIssue9Test extends XmlTestBase
+public class EnumIssue9Test extends XmlTestUtil
{
static enum TestEnum { A, B, C; }
@@ -29,6 +33,8 @@ public UntypedEnumBean() { }
private final XmlMapper MAPPER = newMapper();
+ @JacksonTestFailureExpected
+ @Test
public void testUntypedEnum() throws Exception
{
String xml = MAPPER.writeValueAsString(new UntypedEnumBean(TestEnum.B));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/Issue37AdapterTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/Issue37AdapterTest.java
similarity index 86%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/Issue37AdapterTest.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/Issue37AdapterTest.java
index 64ee7f673..0322ce3d4 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/Issue37AdapterTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/Issue37AdapterTest.java
@@ -1,20 +1,28 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.io.UnsupportedEncodingException;
-import java.net.*;
-import java.util.*;
-
-import jakarta.xml.bind.annotation.*;
-import jakarta.xml.bind.annotation.adapters.*;
-
-import com.fasterxml.jackson.databind.*;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
+import jakarta.xml.bind.annotation.XmlRootElement;
+import jakarta.xml.bind.annotation.adapters.XmlAdapter;
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.databind.AnnotationIntrospector;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.dataformat.xml.*;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
// 30-Jun-2020, tatu: This is deferred and possibly won't be fixed
// at all. But leaving failing test here just in case future brings
// alternate approach to do something.
-public class Issue37AdapterTest extends XmlTestBase
+public class Issue37AdapterTest extends XmlTestUtil
{
@XmlJavaTypeAdapter(URLEncoderMapDataAdapter.class)
public static class MapData
@@ -100,10 +108,9 @@ private Map singletonMap(String a, String b) {
protected XmlMapper _nonJaxbMapper;
- @Override
+ @BeforeEach
public void setUp() throws Exception
{
- super.setUp();
_jaxbMapper = new XmlMapper();
_nonJaxbMapper = new XmlMapper();
// Use JAXB-then-Jackson annotation introspector
@@ -119,6 +126,8 @@ public void setUp() throws Exception
/**********************************************************************
*/
+ @JacksonTestFailureExpected
+ @Test
public void testSimpleKeyMap() throws Exception
{
DocWithMapData bean = new DocWithMapData();
@@ -128,6 +137,8 @@ public void testSimpleKeyMap() throws Exception
_jaxbMapper.writeValueAsString(bean));
}
+ @JacksonTestFailureExpected
+ @Test
public void testNeedEncodingKeyMap() throws Exception
{
DocWithMapData bean = new DocWithMapData();
@@ -139,6 +150,8 @@ public void testNeedEncodingKeyMap() throws Exception
xml);
}
+ @JacksonTestFailureExpected
+ @Test
public void testSimpleKeyMapSimpleAnnotation() throws Exception
{
DocWithMapDataSimpleAnnotation bean = new DocWithMapDataSimpleAnnotation();
@@ -149,6 +162,8 @@ public void testSimpleKeyMapSimpleAnnotation() throws Exception
_jaxbMapper.writeValueAsString(bean));
}
+ @JacksonTestFailureExpected
+ @Test
public void testNeedEncodingKeyMapSimpleAnnotation() throws Exception
{
DocWithMapDataSimpleAnnotation bean = new DocWithMapDataSimpleAnnotation();
@@ -159,6 +174,8 @@ public void testNeedEncodingKeyMapSimpleAnnotation() throws Exception
_jaxbMapper.writeValueAsString(bean));
}
+ @JacksonTestFailureExpected
+ @Test
public void testNeedEncodingKeyMap_nonJaxb() throws Exception
{
DocWithMapData bean = new DocWithMapData();
@@ -169,6 +186,8 @@ public void testNeedEncodingKeyMap_nonJaxb() throws Exception
_nonJaxbMapper.writeValueAsString(bean));
}
+ @JacksonTestFailureExpected
+ @Test
public void testNeedEncodingKeyMapSimpleAnnotation_nonJaxb() throws Exception
{
DocWithMapDataSimpleAnnotation bean = new DocWithMapDataSimpleAnnotation();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PojoAsAttributeSer128Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PojoAsAttributeSer128Test.java
similarity index 76%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PojoAsAttributeSer128Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PojoAsAttributeSer128Test.java
index 6d1717c61..65a63b8be 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PojoAsAttributeSer128Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PojoAsAttributeSer128Test.java
@@ -1,15 +1,18 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonRootName;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+import static org.junit.jupiter.api.Assertions.assertEquals;
// [dataformat-xml#128]: Should ignore "as-attribute" setting for POJO
-public class PojoAsAttributeSer128Test extends XmlTestBase
+public class PojoAsAttributeSer128Test extends XmlTestUtil
{
static class Bean {
public int value = 42;
@@ -36,6 +39,8 @@ static class Container {
private final XmlMapper MAPPER = newMapper();
+ @JacksonTestFailureExpected
+ @Test
public void testAttributeDeser128() throws Exception
{
final String output = MAPPER.writeValueAsString(new Container()).trim();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicIssue4Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicIssue4Test.java
similarity index 86%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicIssue4Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicIssue4Test.java
index 075ba3acb..145027048 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicIssue4Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicIssue4Test.java
@@ -1,15 +1,20 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// for:
//
// [dataformat-xml#4]
// [dataformat-xml#9] (enums)
-
-public class PolymorphicIssue4Test extends XmlTestBase
+public class PolymorphicIssue4Test extends XmlTestUtil
{
/*
/**********************************************************
@@ -72,6 +77,8 @@ public ClassArrayWrapper() { }
*/
// Does not work since array wrapping is not explicitly forced (unlike with collection
// property of a bean
+ @JacksonTestFailureExpected
+ @Test
public void testAsClassArray() throws Exception
{
String xml = MAPPER.writeValueAsString(new SubTypeWithClassArray("Foobar"));
@@ -83,6 +90,8 @@ public void testAsClassArray() throws Exception
// Hmmh. Does not yet quite work either, since we do not properly force
// array context when writing...
+ @JacksonTestFailureExpected
+ @Test
public void testAsWrappedClassArray() throws Exception
{
String xml = MAPPER.writeValueAsString(new ClassArrayWrapper("Foobar"));
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicList426Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicList426Test.java
similarity index 87%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicList426Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicList426Test.java
index 41306aefa..e765bd42b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicList426Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicList426Test.java
@@ -1,19 +1,25 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.io.IOException;
import java.util.List;
-import com.fasterxml.jackson.annotation.*;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class PolymorphicList426Test extends XmlTestBase
+public class PolymorphicList426Test extends XmlTestUtil
{
static class Auto {
@JacksonXmlProperty(localName = "Object")
@@ -84,6 +90,8 @@ public JsonTypeInfo.Id getMechanism() {
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#426]
+ @JacksonTestFailureExpected
+ @Test
public void testPolymorphicList426() throws Exception
{
String xml = "" +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicList576Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicList576Test.java
similarity index 84%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicList576Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicList576Test.java
index f3f2cca0b..40715b658 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/PolymorphicList576Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/PolymorphicList576Test.java
@@ -1,18 +1,20 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
-import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
-public class PolymorphicList576Test extends XmlTestBase
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.annotation.*;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class PolymorphicList576Test extends XmlTestUtil
{
@JacksonXmlRootElement(localName = "wrapper")
static class Wrapper extends Base {
@@ -91,6 +93,8 @@ static class Base {
private final ObjectMapper XML_MAPPER = newMapper();
+ @JacksonTestFailureExpected
+ @Test
public void test_3itemsInXml_expect_3itemsInDeserializedObject() throws Exception {
String xmlString =
"\n"
@@ -104,6 +108,8 @@ public void test_3itemsInXml_expect_3itemsInDeserializedObject() throws Exceptio
assertEquals(3, ((Wrapper)base).getItems().size());
}
+ @JacksonTestFailureExpected
+ @Test
public void test_2itemsInObject_expect_2itemsInObjectAfterRoundTripDeserializationToBaseClass() throws Exception {
Wrapper wrapper = new Wrapper();
Item item1 = new Item("1");
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TypeInfoOrder525Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/TypeInfoOrder525Test.java
similarity index 82%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TypeInfoOrder525Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/TypeInfoOrder525Test.java
index b0bc306f8..a4580580f 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/TypeInfoOrder525Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/TypeInfoOrder525Test.java
@@ -1,18 +1,19 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.util.List;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonSubTypes;
-import com.fasterxml.jackson.annotation.JsonTypeInfo;
-import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.junit.jupiter.api.Test;
+
+import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import static org.junit.jupiter.api.Assertions.assertEquals;
// Tests for [dataformat-xml#525], related to relative order of "type"
// property (as attribute) compared to other properties
-public class TypeInfoOrder525Test extends XmlTestBase
+public class TypeInfoOrder525Test extends XmlTestUtil
{
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@@ -46,6 +47,8 @@ static class BindingInfo525 {
.defaultUseWrapper(false)
.build();
+ @JacksonTestFailureExpected
+ @Test
public void testTypeAfterOtherProperties() throws Exception {
String xml =
" \n" +
@@ -59,6 +62,7 @@ public void testTypeAfterOtherProperties() throws Exception {
assertEquals("Test", ((ClassInfo525)m).element.get(0).binding.description);
}
+ @Test
public void testTypeBeforeOtherProperties() throws Exception {
String xml =
" \n" +
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UntypedListSerialization8Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/UntypedListSerialization8Test.java
similarity index 77%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UntypedListSerialization8Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/UntypedListSerialization8Test.java
index f0d1863b7..566580d54 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UntypedListSerialization8Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/UntypedListSerialization8Test.java
@@ -1,14 +1,19 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class UntypedListSerialization8Test extends XmlTestBase
+public class UntypedListSerialization8Test extends XmlTestUtil
{
@JsonRootName("L")
static class UntypedListBean
@@ -48,6 +53,8 @@ public TypedListBean() {
* For [dataformat-xml#8] -- Will not use wrapping, if type is not statically known
* to be a Collection
*/
+ @JacksonTestFailureExpected
+ @Test
public void testListAsObject() throws IOException
{
String xmlForUntyped = MAPPER.writeValueAsString(new UntypedListBean());
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UnwrappedAndList299DeserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/UnwrappedAndList299DeserTest.java
similarity index 79%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UnwrappedAndList299DeserTest.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/UnwrappedAndList299DeserTest.java
index 7304db20d..22cda9e1f 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/UnwrappedAndList299DeserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/UnwrappedAndList299DeserTest.java
@@ -1,14 +1,20 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
-import com.fasterxml.jackson.databind.*;
+import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class UnwrappedAndList299DeserTest extends XmlTestBase
+public class UnwrappedAndList299DeserTest extends XmlTestUtil
{
static class Request {
@JsonUnwrapped
@@ -29,6 +35,8 @@ static class Header {
private final ObjectMapper MAPPER = newMapper();
+ @JacksonTestFailureExpected
+ @Test
public void testXmlMarshallingAndUnmarshalling() throws Exception {
final Request request = new Request();
request.composite.messageId = "ABC";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/VerifyRootLocalName247Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/VerifyRootLocalName247Test.java
similarity index 72%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/VerifyRootLocalName247Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/VerifyRootLocalName247Test.java
index e9f4d2308..2800be88d 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/VerifyRootLocalName247Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/VerifyRootLocalName247Test.java
@@ -1,10 +1,17 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
+
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
-public class VerifyRootLocalName247Test extends XmlTestBase
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+
+public class VerifyRootLocalName247Test extends XmlTestUtil
{
// [dataformat-xml#247]
static class Root {
@@ -20,6 +27,8 @@ static class Root {
private final ObjectMapper MAPPER = newMapper();
// [dataformat-xml#247]
+ @JacksonTestFailureExpected
+ @Test
public void testRootNameValidation247() throws Exception
{
Root root = MAPPER
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextViaCreator306Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XmlTextViaCreator306Test.java
similarity index 86%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextViaCreator306Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XmlTextViaCreator306Test.java
index e5d9b60bf..c85d5c108 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextViaCreator306Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XmlTextViaCreator306Test.java
@@ -1,18 +1,25 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.beans.ConstructorProperties;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonRootName;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
// [dataformat-xml#306]: Problem is that `@XmlText` has no nominal property name
// of empty String (""), and that is not properly bound. Worse, empty String has
// special meaning so that annotation CANNOT specify it, either.
-public class XmlTextViaCreator306Test extends XmlTestBase
+public class XmlTextViaCreator306Test extends XmlTestUtil
{
// [dataformat-xml#306]
@JsonRootName("ROOT")
@@ -90,6 +97,8 @@ public Sample423(@JacksonXmlText String text,
private final XmlMapper MAPPER = newMapper();
// [dataformat-xml#306]
+ @JacksonTestFailureExpected
+ @Test
public void testIssue306WithCtor() throws Exception
{
final String XML = "text ";
@@ -97,6 +106,7 @@ public void testIssue306WithCtor() throws Exception
assertNotNull(root);
}
+ @Test
public void testIssue306NoCtor() throws Exception
{
final String XML = "text ";
@@ -105,6 +115,8 @@ public void testIssue306NoCtor() throws Exception
}
// [dataformat-xml#423]
+ @JacksonTestFailureExpected
+ @Test
public void testXmlTextViaCtor423() throws Exception
{
final String XML = "text value ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextWithEmpty449Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XmlTextWithEmpty449Test.java
similarity index 77%
rename from src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextWithEmpty449Test.java
rename to src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XmlTextWithEmpty449Test.java
index 1a55fabf3..51426208b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/failing/XmlTextWithEmpty449Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/tofix/XmlTextWithEmpty449Test.java
@@ -1,15 +1,22 @@
-package com.fasterxml.jackson.dataformat.xml.failing;
+package com.fasterxml.jackson.dataformat.xml.tofix;
import java.util.List;
+import org.junit.jupiter.api.Test;
+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.ObjectReader;
+
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
+import com.fasterxml.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-public class XmlTextWithEmpty449Test extends XmlTestBase
+public class XmlTextWithEmpty449Test extends XmlTestUtil
{
static class Project449 {
public Text449 text;
@@ -29,6 +36,8 @@ static class Text449 {
private final XmlMapper MAPPER = newMapper();
// [dataformat-xml#449]
+ @JacksonTestFailureExpected
+ @Test
public void testXmlText449ItemWithAttr() throws Exception
{
final ObjectReader r = MAPPER.readerFor(Project449.class);
@@ -46,6 +55,8 @@ public void testXmlText449ItemWithAttr() throws Exception
}
// [dataformat-xml#449]
+ @JacksonTestFailureExpected
+ @Test
public void testXmlText449ItemWithList() throws Exception
{
final ObjectReader r = MAPPER.readerFor(Project449WithList.class);
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/DTDValidationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/DTDValidationTest.java
index 1ac87704c..4e11c35b4 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/DTDValidationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/DTDValidationTest.java
@@ -1,11 +1,13 @@
package com.fasterxml.jackson.dataformat.xml.vld;
+import javax.xml.stream.XMLStreamException;
+
import org.codehaus.stax2.XMLStreamReader2;
import org.codehaus.stax2.validation.XMLValidationSchema;
+import org.junit.jupiter.api.Test;
-import static javax.xml.stream.XMLStreamConstants.*;
-
-import javax.xml.stream.XMLStreamException;
+import static javax.xml.stream.XMLStreamConstants.END_DOCUMENT;
+import static org.junit.jupiter.api.Assertions.fail;
// Should test validation failure too but...
public class DTDValidationTest extends ValidationTestBase
@@ -16,6 +18,7 @@ public class DTDValidationTest extends ValidationTestBase
+"\n"
;
+ @Test
public void testFullValidationOk() throws Exception
{
String XML = " ";
@@ -26,6 +29,7 @@ public void testFullValidationOk() throws Exception
sr.close();
}
+ @Test
public void testValidationFail() throws Exception
{
String XML = " ";
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/RelaxNGValidationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/RelaxNGValidationTest.java
index 7d561fe2a..2f8ca5266 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/RelaxNGValidationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/RelaxNGValidationTest.java
@@ -6,6 +6,10 @@
import org.codehaus.stax2.XMLStreamReader2;
import org.codehaus.stax2.validation.XMLValidationException;
import org.codehaus.stax2.validation.XMLValidationSchema;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
public class RelaxNGValidationTest extends ValidationTestBase
{
@@ -25,6 +29,7 @@ public class RelaxNGValidationTest extends ValidationTestBase
+""
;
+ @Test
public void testValidWithNamespace() throws Exception
{
String XML = "\n"
@@ -51,6 +56,7 @@ public void testValidWithNamespace() throws Exception
assertTokenType(XMLStreamConstants.END_DOCUMENT, sr.getEventType());
}
+ @Test
public void testInvalidWithNamespace()
throws Exception
{
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/ValidationTestBase.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/ValidationTestBase.java
index ab90bcf5d..ac026270c 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/ValidationTestBase.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/ValidationTestBase.java
@@ -2,20 +2,18 @@
import java.io.StringReader;
import java.util.HashMap;
-
import javax.xml.stream.XMLStreamException;
import org.codehaus.stax2.XMLStreamReader2;
-import org.codehaus.stax2.validation.XMLValidationException;
-import org.codehaus.stax2.validation.XMLValidationSchema;
-import org.codehaus.stax2.validation.XMLValidationSchemaFactory;
+import org.codehaus.stax2.validation.*;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
import static javax.xml.stream.XMLStreamConstants.*;
+import static org.junit.jupiter.api.Assertions.fail;
-abstract class ValidationTestBase extends XmlTestBase
+abstract class ValidationTestBase extends XmlTestUtil
{
final static HashMap mTokenTypes = new HashMap();
static {
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/W3CSchemaValidationTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/W3CSchemaValidationTest.java
index c9439d1e1..9e169ef2b 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/W3CSchemaValidationTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/vld/W3CSchemaValidationTest.java
@@ -3,12 +3,15 @@
import org.codehaus.stax2.XMLStreamReader2;
import org.codehaus.stax2.validation.XMLValidationException;
import org.codehaus.stax2.validation.XMLValidationSchema;
+import org.junit.jupiter.api.Test;
import static javax.xml.stream.XMLStreamConstants.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
-// Basic verification that W3C Schema validation is available
public class W3CSchemaValidationTest extends ValidationTestBase
{
+ @Test
public void testSimpleDataTypes() throws Exception
{
// Another sample schema, from
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java
index f7ca7edfa..4a0e62be1 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/DeepNestingWoodstoxParserTest.java
@@ -1,16 +1,17 @@
package com.fasterxml.jackson.dataformat.xml.woodstox;
import com.ctc.wstx.stax.WstxInputFactory;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.JsonParser;
-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.dataformat.xml.XmlTestUtil;
-public class DeepNestingWoodstoxParserTest extends XmlTestBase
+public class DeepNestingWoodstoxParserTest extends XmlTestUtil
{
// Try using Woodstox-specific settings above and beyond
// what Jackson-core would provide
+ @Test
public void testDeepDocWithWoodstoxLimits() throws Exception
{
final WstxInputFactory wstxInputFactory = new WstxInputFactory();
diff --git a/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java
index 2ec01868b..751fc8713 100644
--- a/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java
+++ b/src/test/java/com/fasterxml/jackson/dataformat/xml/woodstox/NonNamespaceAwareDeser422Test.java
@@ -1,21 +1,21 @@
package com.fasterxml.jackson.dataformat.xml.woodstox;
import java.util.List;
-
import javax.xml.stream.XMLInputFactory;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import org.junit.jupiter.api.Test;
-import com.fasterxml.jackson.dataformat.xml.XmlFactory;
-import com.fasterxml.jackson.dataformat.xml.XmlMapper;
-import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.dataformat.xml.*;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
+import static org.junit.jupiter.api.Assertions.*;
+
// [dataformat-xml#422]: while setting itself is NOT Woodstox-specific,
// many/most Stax implementations do not offer non-namespace-aware mode
// so let's separate this into Woodstox-specific section
-public class NonNamespaceAwareDeser422Test extends XmlTestBase
+public class NonNamespaceAwareDeser422Test extends XmlTestUtil
{
// [dataformat-xml#422]
@JsonIgnoreProperties(ignoreUnknown = true) // to skip `xmlns`
@@ -53,6 +53,7 @@ static class RssItem {
public String content;
}
+ @Test
public void testBigDocIssue422() throws Exception
{
final XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();