Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 5, 2024
2 parents cd9ebbc + a751f9c commit 4ca2e18
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 2 deletions.
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ static class ContainerForBase
// @XmlElement(type=BaseImpl.class, name="baseImpl"),
public Base[] stuff;
}

/*
/**********************************************************
/* Test methods
/**********************************************************
*/

private final ObjectMapper MAPPER = getJaxbMapper();

//First a simple test with non-collection field

@SuppressWarnings("unchecked")
Expand Down
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());
}
}

0 comments on commit 4ca2e18

Please sign in to comment.