Skip to content

Commit

Permalink
Failing unit test for issue FasterXML#242
Browse files Browse the repository at this point in the history
  • Loading branch information
khovanskiy committed Jun 12, 2017
1 parent d197744 commit fb1c246
Showing 1 changed file with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.fasterxml.jackson.dataformat.xml.failing;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;

/**
* Issue #242
*/
public class TestTypeAttributeOrder {
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type", defaultImpl = B.class)
@JsonSubTypes({
@JsonSubTypes.Type(value = B.class, name = "B")
})
static abstract class A {
@JacksonXmlProperty(isAttribute = true)
public Integer id;
}

static class Attr {
@JacksonXmlElementWrapper(useWrapping = false)
public List<Param> param;
}

static class Param {
public String name;
}

static class B extends A {
public Attr attr;
}

/*
/**********************************************************
/* Unit tests
/**********************************************************
*/
private final XmlMapper MAPPER = new XmlMapper();

@Test
public void testAttributeOrder() throws Exception {
String content1 = "<A type=\"B\" id=\"1\"><attr><param name=\"1\"/><param name=\"2\"/></attr></A>";
B b1 = (B) MAPPER.readValue(content1, A.class);
assertEquals(2, b1.attr.param.size());
String content2 = "<A id=\"1\" type=\"B\"><attr><param name=\"1\"/><param name=\"2\"/></attr></A>";
B b2 = (B) MAPPER.readValue(content2, A.class);
assertEquals(2, b2.attr.param.size());
}
}

0 comments on commit fb1c246

Please sign in to comment.