-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
jaxb/src/test/java/com/fasterxml/jackson/module/jaxb/failing/TestEnums256.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,51 @@ | ||
package com.fasterxml.jackson.module.jaxb.failing; | ||
|
||
import javax.xml.bind.annotation.*; | ||
import javax.xml.bind.annotation.adapters.*; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; | ||
|
||
public class TestEnums256 extends BaseJaxbTest | ||
{ | ||
// [modules-base#256] | ||
@XmlRootElement(name = "document") | ||
@XmlAccessorType(XmlAccessType.FIELD) | ||
public static class Document256 { | ||
|
||
@XmlElement(name = "code") | ||
private final Code _code; | ||
|
||
public Document256(Code code) { _code = code; } | ||
|
||
public Code getCode() { | ||
return _code; | ||
} | ||
} | ||
|
||
@XmlEnum | ||
@XmlType(name = "CodeType") | ||
@XmlJavaTypeAdapter(CollapsedStringAdapter.class) | ||
public enum Code { | ||
@XmlEnumValue("RED") | ||
RED; | ||
} | ||
|
||
/* | ||
/********************************************************** | ||
/* Test methods | ||
/********************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = getJaxbMapper(); | ||
|
||
// [modules-base#256] | ||
public void testEnumSerialize256() throws Exception | ||
{ | ||
final Document256 document = new Document256(Code.RED); | ||
|
||
String json = MAPPER.writeValueAsString(document); | ||
|
||
assertEquals(a2q("{'code':'RED'}"), json); | ||
} | ||
} |
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