Skip to content

Commit 563646b

Browse files
committed
test improvements
1 parent b257358 commit 563646b

File tree

1 file changed

+2
-23
lines changed

1 file changed

+2
-23
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/NullConversionsGenericTest.java renamed to src/test/java/com/fasterxml/jackson/dataformat/xml/deser/CoerceFromEmptyStringTest.java

+2-23
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,24 @@
33
import java.util.List;
44
import java.util.Map;
55

6-
import com.fasterxml.jackson.annotation.JsonSetter;
7-
import com.fasterxml.jackson.annotation.Nulls;
86
import com.fasterxml.jackson.core.type.TypeReference;
97

10-
import com.fasterxml.jackson.databind.*;
118
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
129
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
1310

14-
// Copied from `com.fasterxml.jackson.databind.deser.filter.` in `jackson-databind`
15-
public class NullConversionsGenericTest extends XmlTestBase
11+
// Note: copied from coercion tests of `jackson-databind`
12+
public class CoerceFromEmptyStringTest extends XmlTestBase
1613
{
1714
static class PointWrapper {
18-
@JsonSetter(nulls=Nulls.AS_EMPTY)
1915
public Point p;
2016
}
2117

2218
static class GeneralEmpty<T> {
23-
// 09-Feb-2017, tatu: Should only need annotation either for field OR setter, not both:
24-
// @JsonSetter(nulls=Nulls.AS_EMPTY)
2519
T value;
2620

2721
protected GeneralEmpty() { }
2822
public GeneralEmpty(T v) { value = v; }
2923

30-
@JsonSetter(nulls=Nulls.AS_EMPTY)
3124
public void setValue(T v) {
3225
value = v;
3326
}
@@ -36,7 +29,6 @@ public void setValue(T v) {
3629
}
3730

3831
static class NoCtorWrapper {
39-
@JsonSetter(nulls=Nulls.AS_EMPTY)
4032
public NoCtorPOJO value;
4133
}
4234

@@ -73,19 +65,8 @@ public void testNullsToGenericPojo() throws Exception
7365
Point p = result.value;
7466
assertEquals(0, p.x);
7567
assertEquals(0, p.y);
76-
77-
// and then also failing case with no suitable creator:
78-
try {
79-
/* NoCtorWrapper nogo =*/ MAPPER.readValue(EMPTY_XML,
80-
NoCtorWrapper.class);
81-
fail("Should not pass");
82-
} catch (JsonMappingException e) {
83-
verifyException(e, "Cannot create empty instance");
84-
}
8568
}
8669

87-
// 04-May-2018, tatu: In theory could be supportable, but wrapping (or not)
88-
// of Collections, other requirements, make it... not that easy.
8970
public void testNullsToEmptyCollection() throws Exception
9071
{
9172
GeneralEmpty<List<String>> result = MAPPER.readValue(EMPTY_XML,
@@ -100,7 +81,6 @@ public void testNullsToEmptyCollection() throws Exception
10081
assertEquals(0, result2.value.size());
10182
}
10283

103-
// 04-May-2018, tatu: Maps and XML do not mix well, alas:
10484
public void testNullsToEmptyMap() throws Exception
10585
{
10686
GeneralEmpty<Map<String,String>> result = MAPPER.readValue(EMPTY_XML,
@@ -127,7 +107,6 @@ public void testNullsToEmptyArrays() throws Exception
127107
new TypeReference<GeneralEmpty<int[]>>() { });
128108
assertNotNull(result3.value);
129109
assertEquals(0, result3.value.length);
130-
131110
GeneralEmpty<double[]> result4 = MAPPER.readValue(doc,
132111
new TypeReference<GeneralEmpty<double[]>>() { });
133112
assertNotNull(result4.value);

0 commit comments

Comments
 (0)