Skip to content

Commit 94d5797

Browse files
committed
Fix one test
1 parent 96bc6d3 commit 94d5797

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/main/java/tools/jackson/dataformat/xml/annotation/JacksonXmlRootElement.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
* {@link com.fasterxml.jackson.annotation.JsonRootName} instead.
2222
* About the only expected usage may be to have different root name for XML
2323
* content than other formats.
24+
*
25+
* @deprecated Since 2.4 use {@link com.fasterxml.jackson.annotation.JsonRootName} instead
2426
*/
2527
@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE})
2628
@Retention(RetentionPolicy.RUNTIME)
29+
@Deprecated
2730
public @interface JacksonXmlRootElement
2831
{
2932
String namespace() default "";

src/test/java/tools/jackson/dataformat/xml/misc/RootNameTest.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package tools.jackson.dataformat.xml.misc;
22

3-
import java.io.IOException;
43
import java.util.ArrayList;
54
import java.util.Arrays;
65

@@ -10,15 +9,17 @@
109
import tools.jackson.databind.PropertyName;
1110

1211
import tools.jackson.dataformat.xml.XmlTestUtil;
12+
import tools.jackson.dataformat.xml.XmlWriteFeature;
1313
import tools.jackson.dataformat.xml.XmlMapper;
1414
import tools.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
1515

1616
import static org.junit.jupiter.api.Assertions.assertEquals;
1717
import static org.junit.jupiter.api.Assertions.fail;
1818

1919
// NOTE: even tho `@JacksonXmlRootElement` will be deprecated in near
20-
// future (possibly in 2.13) -- to be replaced by `@JsonRootName` -- this
20+
// future -- to be replaced by `@JsonRootName` -- this
2121
// test will use it to ensure we handle both annotations as expected
22+
@SuppressWarnings({ "serial" })
2223
public class RootNameTest extends XmlTestUtil
2324
{
2425
static class RootBeanBase
@@ -31,19 +32,21 @@ public RootBeanBase(String v) {
3132
}
3233
}
3334

35+
@SuppressWarnings("deprecation")
3436
@JacksonXmlRootElement(localName="root")
3537
static class RootBean extends RootBeanBase
3638
{
3739
protected RootBean() { super(); }
3840
}
3941

42+
@SuppressWarnings("deprecation")
4043
@JacksonXmlRootElement(localName="nsRoot", namespace="http://foo")
4144
static class NsRootBean
4245
{
4346
public String value = "abc";
4447
}
4548

46-
@SuppressWarnings("serial")
49+
@SuppressWarnings("deprecation")
4750
@JacksonXmlRootElement(localName="TheStrings")
4851
static class StringList extends ArrayList<String> {
4952
public StringList(String...strings) {
@@ -57,11 +60,13 @@ public StringList(String...strings) {
5760
/**********************************************************
5861
*/
5962

60-
protected XmlMapper _xmlMapper = new XmlMapper();
63+
protected XmlMapper _xmlMapper = mapperBuilder()
64+
.disable(XmlWriteFeature.WRITE_NULLS_AS_XSI_NIL)
65+
.build();
6166

6267
// Unit test to verify that root name is properly set
6368
@Test
64-
public void testRootNameAnnotation() throws IOException
69+
public void testRootNameAnnotation()
6570
{
6671
String xml = _xmlMapper.writeValueAsString(new StringBean());
6772

@@ -87,7 +92,7 @@ public void testRootNameAnnotation() throws IOException
8792
}
8893

8994
@Test
90-
public void testDynamicRootName() throws IOException
95+
public void testDynamicRootName()
9196
{
9297
String xml;
9398

@@ -105,7 +110,7 @@ public void testDynamicRootName() throws IOException
105110
}
106111

107112
@Test
108-
public void testDynamicRootNameForList() throws IOException
113+
public void testDynamicRootNameForList()
109114
{
110115
String xml;
111116

0 commit comments

Comments
 (0)