Debian Codegraph @

src/test/java/com/fasterxml/jackson/module/jaxb/introspect/TestAnnotationPriority.java

raw
1 package com.fasterxml.jackson.module.jaxb.introspect;
2
3 import javax.xml.bind.annotation.XmlElement;
4
5 import com.fasterxml.jackson.databind.ObjectMapper;
6 import com.fasterxml.jackson.module.jaxb.BaseJaxbTest;
7
8 /**
9 * Unit test(s) to verify that annotations from super classes and
10 * interfaces are properly used (for example, wrt [JACKSON-450])
11 */
12 public class TestAnnotationPriority extends BaseJaxbTest
13 {
14 /*
15 /**********************************************************
16 /* Helper beans
17 /**********************************************************
18 */
19
20 public interface Identifiable {
21 public String getId();
22 public void setId(String i);
23 }
24
25 static abstract class IdBase
26 {
27 protected String id;
28
29 protected IdBase(String id) { this.id = id; }
30
31 @XmlElement(name="name")
32 public String getId() {
33 return id;
34 }
35
36 public void setId(String id) {
37 this.id = id;
38 }
39 }
40
41 static class IdBean extends IdBase implements Identifiable {
42 public IdBean(String id) { super(id); }
43 }
44
45 /*
46 /**********************************************************
47 /* Unit tests
48 /**********************************************************
49 */
50
51 public void testInterfacesAndClasses() throws Exception
52 {
53 ObjectMapper mapper = getJaxbMapper();
54 String json = mapper.writeValueAsString(new IdBean("foo"));
55 assertEquals("{\"name\":\"foo\"}", json);
56 }
57 }