Skip to content

Commit 077a9d9

Browse files
committed
Minor test clean up
1 parent dfcef81 commit 077a9d9

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationAttr.java

+11-25
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.fasterxml.jackson.dataformat.xml.ser;
22

3-
import java.io.IOException;
43
import java.util.*;
54

65
import com.fasterxml.jackson.annotation.*;
@@ -51,21 +50,6 @@ public DynaBean(Map<String, String> values) {
5150
public Map<String, String> getProperties() {
5251
return _properties;
5352
}
54-
}
55-
56-
/*
57-
/**********************************************************
58-
/* Set up
59-
/**********************************************************
60-
*/
61-
62-
protected XmlMapper _xmlMapper;
63-
64-
// let's actually reuse XmlMapper to make things bit faster
65-
@Override
66-
public void setUp() throws Exception {
67-
super.setUp();
68-
_xmlMapper = new XmlMapper();
6953
}
7054

7155
/*
@@ -74,17 +58,19 @@ public void setUp() throws Exception {
7458
/**********************************************************
7559
*/
7660

77-
public void testSimpleNsAttr() throws IOException
61+
private final XmlMapper XML_MAPPER = newMapper();
62+
63+
public void testSimpleNsAttr() throws Exception
7864
{
79-
String xml = _xmlMapper.writeValueAsString(new NsAttrBean());
65+
String xml = XML_MAPPER.writeValueAsString(new NsAttrBean());
8066
xml = removeSjsxpNamespace(xml);
8167
// here we assume woodstox automatic prefixes, not very robust but:
8268
assertEquals("<NsAttrBean xmlns:wstxns1=\"http://foo\" wstxns1:attr=\"3\"/>", xml);
8369
}
8470

85-
public void testIssue19() throws IOException
71+
public void testIssue19() throws Exception
8672
{
87-
String xml = _xmlMapper.writeValueAsString(new Issue19Bean());
73+
String xml = XML_MAPPER.writeValueAsString(new Issue19Bean());
8874
xml = removeSjsxpNamespace(xml);
8975
xml = xml.replaceAll("\"", "'");
9076
// as with above, assumes exact NS allocation strategy, not optimal:
@@ -93,22 +79,22 @@ public void testIssue19() throws IOException
9379
xml);
9480
}
9581

96-
public void testIssue6() throws IOException
82+
public void testIssue6() throws Exception
9783
{
9884
assertEquals("<Jurisdiction name=\"Foo\" value=\"13\"/>",
99-
_xmlMapper.writeValueAsString(new Jurisdiction()));
85+
XML_MAPPER.writeValueAsString(new Jurisdiction()));
10086
}
10187

102-
public void testIssue117AnySetterAttrs() throws IOException
88+
public void testIssue117AnySetterAttrs() throws Exception
10389
{
10490
Map<String, String> values = new HashMap<String, String>();
10591
values.put("prop1", "val1");
10692

107-
String xml = _xmlMapper.writeValueAsString(new DynaBean(values));
93+
String xml = XML_MAPPER.writeValueAsString(new DynaBean(values));
10894
assertEquals("<dynaBean class=\"TestSerializationAttr$DynaBean\"><prop1>val1</prop1></dynaBean>",
10995
removeSjsxpNamespace(xml));
11096
}
111-
97+
11298
/*
11399
/**********************************************************
114100
/* Helper methods

src/test/java/com/fasterxml/jackson/dataformat/xml/ser/TestSerializationOrdering.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ public class TestSerializationOrdering extends XmlTestBase
99
{
1010
@JsonPropertyOrder({"a", "c" })
1111
static class Bean91 {
12-
public String a;
12+
public String c;
1313
@JacksonXmlProperty(isAttribute = true)
1414
public String b;
15-
public String c;
15+
public String a;
1616

1717
public Bean91(String a, String b, String c) {
1818
this.a = a;
@@ -21,10 +21,11 @@ public Bean91(String a, String b, String c) {
2121
}
2222
}
2323

24+
private final XmlMapper MAPPER = newMapper();
25+
2426
public void testOrdering() throws Exception
2527
{
26-
XmlMapper xmlMapper = new XmlMapper();
27-
String xml = xmlMapper.writeValueAsString(new Bean91("1", "2", "3"));
28+
String xml = MAPPER.writeValueAsString(new Bean91("1", "2", "3"));
2829
assertEquals("<Bean91 b=\"2\"><a>1</a><c>3</c></Bean91>", xml);
2930
}
3031
}

0 commit comments

Comments
 (0)