Skip to content

Commit 0a7cf7b

Browse files
committed
Merge test classes
1 parent 7e35baa commit 0a7cf7b

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeser682Test.java

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

src/test/java/com/fasterxml/jackson/dataformat/xml/deser/EnumDeserTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package com.fasterxml.jackson.dataformat.xml.deser;
22

3+
import com.fasterxml.jackson.annotation.JsonCreator;
4+
import com.fasterxml.jackson.annotation.JsonValue;
5+
36
import com.fasterxml.jackson.dataformat.xml.*;
47

58
public class EnumDeserTest extends XmlTestBase
@@ -14,6 +17,29 @@ public EnumBean() { }
1417
public EnumBean(TestEnum v) { value = v; }
1518
}
1619

20+
// [dataformat-xml#682]
21+
static enum Country682 {
22+
ITALY("Italy"),
23+
NETHERLANDS("Netherlands");
24+
25+
@JsonValue
26+
final String value;
27+
28+
Country682(String value) {
29+
this.value = value;
30+
}
31+
32+
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
33+
public static Country682 fromValue(String value) {
34+
for (Country682 b : Country682.values()) {
35+
if (b.value.equals(value)) {
36+
return b;
37+
}
38+
}
39+
throw new IllegalArgumentException("Unexpected value '" + value + "'");
40+
}
41+
}
42+
1743
/*
1844
/**********************************************************
1945
/* Unit tests
@@ -38,4 +64,12 @@ public void testRootEnum() throws Exception
3864
assertNotNull(result);
3965
assertEquals(TestEnum.B, result);
4066
}
67+
68+
// [dataformat-xml#682]
69+
public void testEnumDeser682() throws Exception {
70+
String xml = MAPPER.writeValueAsString(Country682.ITALY);
71+
assertEquals("<Country682>Italy</Country682>", xml);
72+
73+
assertEquals(Country682.ITALY, MAPPER.readValue(xml, Country682.class));
74+
}
4175
}

0 commit comments

Comments
 (0)