-
-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #287 from rupert654/master
Add failing test for #286
- Loading branch information
Showing
1 changed file
with
69 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
.../java/com/fasterxml/jackson/dataformat/xml/failing/UnwrappedJsonIdentityConflictTest.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,69 @@ | ||
package com.fasterxml.jackson.dataformat.xml.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIdentityInfo; | ||
import com.fasterxml.jackson.annotation.ObjectIdGenerators; | ||
import com.fasterxml.jackson.dataformat.xml.XmlMapper; | ||
import com.fasterxml.jackson.dataformat.xml.XmlTestBase; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; | ||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; | ||
|
||
public class UnwrappedJsonIdentityConflictTest extends XmlTestBase | ||
{ | ||
static class Town | ||
{ | ||
public School[] schools; | ||
public Student[] students; | ||
} | ||
|
||
static class Student | ||
{ | ||
public School school; | ||
@JacksonXmlElementWrapper(useWrapping = false) | ||
@JacksonXmlProperty(localName = "year") | ||
public Year[] years; | ||
} | ||
|
||
static class Year | ||
{ | ||
public String grade; | ||
} | ||
|
||
@JsonIdentityInfo(scope = School.class, generator = ObjectIdGenerators.PropertyGenerator.class, | ||
property = "name") | ||
static class School | ||
{ | ||
@JacksonXmlElementWrapper(useWrapping = false) | ||
@JacksonXmlProperty(localName = "staffMember") | ||
public String[] staffMembers; | ||
public String name; | ||
} | ||
|
||
public void testCaseInsensitiveComplex() throws Exception | ||
{ | ||
|
||
XmlMapper mapper = XmlMapper.builder().build(); | ||
|
||
final String input = | ||
"<town>\n"+ | ||
" <schools>\n"+ | ||
" <school name=\"Springfield Elementary\">\n"+ | ||
" <staffMember>Principal Skinner</staffMember>\n"+ | ||
" <staffMember>Groundskeeper Willie</staffMember>\n"+ | ||
" </school>\n"+ | ||
" </schools>\n"+ | ||
" <students>\n"+ | ||
" <student>\n"+ | ||
" <school>Springfield Elementary</school>\n"+ | ||
" <year>\n"+ | ||
" <grade>3</grade>\n"+ | ||
" </year>\n"+ | ||
" </student>\n"+ | ||
" </students>\n"+ | ||
"</town>"; | ||
Town result = mapper.readValue(input, Town.class); | ||
assertNotNull(result); | ||
assertEquals("Principal Skinner", result.schools[0].staffMembers[0]); | ||
assertEquals("Principal Skinner", result.students[0].school.staffMembers[0]); | ||
assertEquals("3", result.students[0].years[0].grade); | ||
} | ||
} |