Skip to content

Commit

Permalink
Added unit test for issue FasterXML#84.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Gélinas committed Dec 10, 2013
1 parent 568bc72 commit 37828fc
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.fasterxml.jackson.dataformat.xml.unwrapped;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;

public class TestXmlText extends XmlTestBase{
@JsonPropertyOrder({"first","second"})
class Data{
@JacksonXmlText
public String first;
public String second;
public Data(String first, String second) {
this.first = first;
this.second = second;
}
}

private final XmlMapper MAPPER = new XmlMapper();
{ // easier for eye, uncomment for testing
// MAPPER.enable(SerializationFeature.INDENT_OUTPUT);
}

public void testXmlTextWithSuppressedValue() throws Exception {
MAPPER.setSerializationInclusion(Include.NON_EMPTY);
String xml = MAPPER.writeValueAsString(new Data("","second"));
String expectedXml = "<Data><second>second</second></Data>";
assertEquals(expectedXml, xml);
}
}

0 comments on commit 37828fc

Please sign in to comment.