Skip to content

Commit f87c8a7

Browse files
committed
Merge branch '2.10' into 2.11
2 parents e75f079 + af21e31 commit f87c8a7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
4+
5+
import com.fasterxml.jackson.databind.*;
6+
7+
public class EnumPolymorphic2605Test extends BaseMapTest
8+
{
9+
// for [databind#2605]
10+
static class EnumContaintingClass <ENUM_TYPE extends Enum<ENUM_TYPE>> {
11+
@JsonTypeInfo(
12+
use = JsonTypeInfo.Id.CLASS,
13+
include = JsonTypeInfo.As.PROPERTY,
14+
property = "@class"
15+
)
16+
private ENUM_TYPE selected;
17+
18+
protected EnumContaintingClass() { }
19+
20+
public EnumContaintingClass(ENUM_TYPE selected) {
21+
this.selected = selected;
22+
}
23+
24+
public ENUM_TYPE getSelected() {
25+
return selected;
26+
}
27+
28+
public void setSelected(ENUM_TYPE selected) {
29+
this.selected = selected;
30+
}
31+
}
32+
33+
static enum TestEnum { FIRST, SECOND, THIRD; }
34+
35+
private final ObjectMapper MAPPER = newJsonMapper();
36+
37+
// for [databind#2605]
38+
public void testRoundtrip() throws Exception
39+
{
40+
EnumContaintingClass<TestEnum> gui = new EnumContaintingClass<TestEnum>(TestEnum.SECOND);
41+
String str = MAPPER.writeValueAsString(gui);
42+
Object o = MAPPER.readerFor(EnumContaintingClass.class).readValue(str);
43+
assertNotNull(o);
44+
}
45+
}

0 commit comments

Comments
 (0)