1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.xml.jaxb.issue415;
17
18 import javax.xml.bind.JAXBContext;
19 import javax.xml.bind.Marshaller;
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlElement;
23 import javax.xml.bind.annotation.XmlRootElement;
24 import javax.xml.bind.annotation.adapters.XmlAdapter;
25 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
26
27 import org.junit.Assert;
28 import org.junit.Test;
29
30
31
32
33
34
35 @XmlRootElement
36 @XmlAccessorType(XmlAccessType.FIELD)
37 public class JAXBIssue415Test {
38
39 @XmlElement
40 @XmlJavaTypeAdapter(JAXBIssue415TestAdapter.class)
41 private String value = "foo";
42
43 @Test
44 public void testIssue415() throws Exception {
45 String os = System.getProperty("os.name") + ", " + System.getProperty("os.version");
46 String jdk = System.getProperty("java.vm.name") + ", " + System.getProperty("java.runtime.version");
47 try {
48 Marshaller m = JAXBContext.newInstance(JAXBIssue415Test.class).createMarshaller();
49 m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
50 m.marshal(new JAXBIssue415Test(), System.out);
51 } catch (NullPointerException e) {
52 Assert.fail("JAXB issue 415 is still occurring on [" + os + "] [" + jdk + "]");
53 }
54 }
55
56 public static class JAXBIssue415TestAdapter extends XmlAdapter<String, String> {
57
58 @Override
59 public String marshal(String value) {
60 return null;
61 }
62
63 @Override
64 public String unmarshal(String value) {
65 return null;
66 }
67 }
68 }