| 1 |
package com.fasterxml.jackson.module.jaxb.misc; |
| 2 |
|
| 3 |
import javax.xml.bind.annotation.XmlRootElement; |
| 4 |
|
| 5 |
import com.fasterxml.jackson.databind.ObjectMapper; |
| 6 |
import com.fasterxml.jackson.databind.SerializationFeature; |
| 7 |
|
| 8 |
import com.fasterxml.jackson.module.jaxb.BaseJaxbTest; |
| 9 |
|
| 10 |
public class TestRootName extends BaseJaxbTest |
| 11 |
{ |
| 12 |
/* |
| 13 |
/********************************************************** |
| 14 |
/* Helper beans |
| 15 |
/********************************************************** |
| 16 |
*/ |
| 17 |
|
| 18 |
@XmlRootElement(name="rooty") |
| 19 |
static class MyType |
| 20 |
{ |
| 21 |
public int value = 37; |
| 22 |
} |
| 23 |
|
| 24 |
/* |
| 25 |
/********************************************************** |
| 26 |
/* Unit tests |
| 27 |
/********************************************************** |
| 28 |
*/ |
| 29 |
|
| 30 |
public void testRootName() throws Exception |
| 31 |
{ |
| 32 |
ObjectMapper mapper = getJaxbMapper(); |
| 33 |
mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true); |
| 34 |
assertEquals("{\"rooty\":{\"value\":37}}", mapper.writeValueAsString(new MyType())); |
| 35 |
} |
| 36 |
} |