Skip to content

Commit a65f104

Browse files
author
Aritz Bastida
committed
Add test case for issue FasterXML#3160 (JsonStreamContext "currentValue" wrongly references to @JsonTypeInfo annotated object)
1 parent 87bd61a commit a65f104

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/test/java/com/fasterxml/jackson/databind/ser/TestCustomSerializers.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import org.w3c.dom.Element;
1010

1111
import com.fasterxml.jackson.annotation.*;
12-
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
1312
import com.fasterxml.jackson.core.*;
1413
import com.fasterxml.jackson.core.io.CharacterEscapes;
1514
import com.fasterxml.jackson.databind.*;
@@ -191,7 +190,8 @@ public String getId() {
191190
}
192191
}
193192

194-
@JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, include = As.PROPERTY, property = "@class")
193+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
194+
@JsonSubTypes({ @JsonSubTypes.Type(name = "Foo", value = Foo.class) })
195195
interface Strategy { }
196196

197197
static class Foo implements Strategy {
@@ -310,24 +310,18 @@ public void testWithCustomElements() throws Exception
310310
}
311311

312312
// [databind#2475]
313-
public void testIssue2475Filter() throws Exception {
313+
public void testIssue2475() throws Exception {
314314
SimpleFilterProvider provider = new SimpleFilterProvider().addFilter("myFilter", new MyFilter2475());
315315
ObjectWriter writer = MAPPER.writer(provider);
316316

317-
writer.writeValueAsString(new Item2475(new ArrayList<String>(), "ID-1"));
318-
}
319-
320-
// [databind#2475]
321-
public void testIssue2475Contents() throws Exception {
322-
SimpleFilterProvider provider = new SimpleFilterProvider().addFilter("myFilter", new SimpleBeanPropertyFilter() {});
323-
ObjectWriter writer = MAPPER.writer(provider);
324-
325-
assertEquals(aposToQuotes("{'id':'ID-1','strategy':{'foo':42},'set':[]}"),
317+
// contents don't really matter that much as verification within filter but... let's
318+
// check anyway
319+
assertEquals(aposToQuotes("{'id':'ID-1','strategy':{'type':'Foo','foo':42},'set':[]}"),
326320
writer.writeValueAsString(new Item2475(new ArrayList<String>(), "ID-1")));
327321

328-
assertEquals(aposToQuotes("{'id':'ID-2','strategy':{'foo':42},'set':[]}"),
322+
assertEquals(aposToQuotes("{'id':'ID-2','strategy':{'type':'Foo','foo':42},'set':[]}"),
329323
writer.writeValueAsString(new Item2475(new HashSet<String>(), "ID-2")));
330-
}
331-
324+
325+
}
332326

333327
}

0 commit comments

Comments
 (0)