forked from FasterXML/jackson-dataformat-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test for issue FasterXML#84.
- 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.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
src/test/java/com/fasterxml/jackson/dataformat/xml/unwrapped/TestXmlText.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,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); | ||
} | ||
} |