Skip to content

Commit 3ff282a

Browse files
committed
Minor test consolidation
1 parent ea09459 commit 3ff282a

2 files changed

Lines changed: 35 additions & 57 deletions

File tree

src/test/java/tools/jackson/dataformat/xml/tofix/EnumIssue9Test.java

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/test/java/tools/jackson/dataformat/xml/tofix/PolymorphicIssue4Test.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
import tools.jackson.dataformat.xml.XmlTestUtil;
99
import tools.jackson.dataformat.xml.testutil.failure.JacksonTestFailureExpected;
1010

11-
import static org.junit.jupiter.api.Assertions.assertEquals;
12-
import static org.junit.jupiter.api.Assertions.assertNotNull;
11+
import static org.junit.jupiter.api.Assertions.*;
1312

14-
// for:
13+
14+
// Tests for lack of support for {@code JsonTypeInfo.As.WRAPPER_ARRAY}.
1515
//
1616
// [dataformat-xml#4]
1717
// [dataformat-xml#9] (enums)
@@ -35,6 +35,19 @@ public SubTypeWithClassProperty() { }
3535
}
3636
*/
3737

38+
static enum TestEnum { A, B, C; }
39+
40+
static class UntypedEnumBean
41+
{
42+
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="__type")
43+
// this would actually work:
44+
// @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.WRAPPER_OBJECT)
45+
public Object value;
46+
47+
public UntypedEnumBean() { }
48+
public UntypedEnumBean(TestEnum v) { value = v; }
49+
}
50+
3851
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.WRAPPER_ARRAY)
3952
static class BaseTypeWithClassArray { }
4053

@@ -101,4 +114,23 @@ public void testAsWrappedClassArray() throws Exception
101114
assertEquals(SubTypeWithClassArray.class, result.wrapped.getClass());
102115
assertEquals("Foobar", ((SubTypeWithClassArray) result.wrapped).name);
103116
}
117+
118+
// [dataformat-xml#9]
119+
@JacksonTestFailureExpected
120+
@Test
121+
public void testUntypedEnum() throws Exception
122+
{
123+
String xml = MAPPER.writeValueAsString(new UntypedEnumBean(TestEnum.B));
124+
125+
UntypedEnumBean result = MAPPER.readValue(xml, UntypedEnumBean.class);
126+
assertNotNull(result);
127+
assertNotNull(result.value);
128+
Object ob = result.value;
129+
130+
if (TestEnum.class != ob.getClass()) {
131+
fail("Failed to deserialize TestEnum (got "+ob.getClass().getName()+") from: "+xml);
132+
}
133+
134+
assertEquals(TestEnum.B, result.value);
135+
}
104136
}

0 commit comments

Comments
 (0)