-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...rc/test/java/tools/jackson/module/jakarta/xmlbind/types/XmlSeeAlsoForSubtypes195Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package tools.jackson.module.jakarta.xmlbind.types; | ||
|
||
import jakarta.xml.bind.annotation.XmlSeeAlso; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.As; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | ||
|
||
import tools.jackson.databind.ObjectMapper; | ||
|
||
import tools.jackson.module.jakarta.xmlbind.ModuleTestBase; | ||
|
||
public class XmlSeeAlsoForSubtypes195Test | ||
extends ModuleTestBase | ||
{ | ||
static class Root195 { | ||
public Base195 element; | ||
|
||
protected Root195() { } | ||
public Root195(Base195 e) { | ||
element = e; | ||
} | ||
} | ||
|
||
@JsonTypeInfo(include = As.WRAPPER_ARRAY, use = Id.SIMPLE_NAME) | ||
@XmlSeeAlso({Sub195A.class, Sub195B.class}) | ||
abstract static class Base195 { } | ||
|
||
static class Sub195A extends Base195 { } | ||
static class Sub195B extends Base195 { } | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = getJaxbAndJacksonMapper(); | ||
|
||
// [modules-base#195] | ||
public void testXmlSeeAlso195() throws Exception | ||
{ | ||
String json = MAPPER.writeValueAsString(new Root195(new Sub195B())); | ||
assertEquals("{\"element\":[\"Sub195B\",{}]}", json); | ||
Root195 result = MAPPER.readValue(json, Root195.class); | ||
assertEquals(Sub195B.class, result.element.getClass()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
jaxb/src/test/java/tools/jackson/module/jaxb/types/XmlSeeAlsoForSubtypes195Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package tools.jackson.module.jaxb.types; | ||
|
||
import javax.xml.bind.annotation.XmlSeeAlso; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.As; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | ||
|
||
import tools.jackson.databind.ObjectMapper; | ||
|
||
import tools.jackson.module.jaxb.BaseJaxbTest; | ||
|
||
public class XmlSeeAlsoForSubtypes195Test | ||
extends BaseJaxbTest | ||
{ | ||
static class Root195 { | ||
public Base195 element; | ||
|
||
protected Root195() { } | ||
public Root195(Base195 e) { | ||
element = e; | ||
} | ||
} | ||
|
||
@JsonTypeInfo(include = As.WRAPPER_ARRAY, use = Id.SIMPLE_NAME) | ||
@XmlSeeAlso({Sub195A.class, Sub195B.class}) | ||
abstract static class Base195 { } | ||
|
||
static class Sub195A extends Base195 { } | ||
static class Sub195B extends Base195 { } | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = getJaxbAndJacksonMapper(); | ||
|
||
// [modules-base#195] | ||
public void testXmlSeeAlso195() throws Exception | ||
{ | ||
String json = MAPPER.writeValueAsString(new Root195(new Sub195B())); | ||
assertEquals("{\"element\":[\"Sub195B\",{}]}", json); | ||
Root195 result = MAPPER.readValue(json, Root195.class); | ||
assertEquals(Sub195B.class, result.element.getClass()); | ||
} | ||
} |