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