@@ -18,26 +18,41 @@ public void setName(String name) {
18
18
this .name = name ;
19
19
}
20
20
}
21
-
21
+
22
+ static class Issue395 {
23
+ @ JacksonXmlProperty (isAttribute = true , namespace = "http://www.w3.org/XML/1998/namespace" ,
24
+ localName = "lang" )
25
+ public String lang = "en-US" ;
26
+ }
27
+
22
28
/*
23
29
/**********************************************************
24
30
/* Unit tests
25
31
/**********************************************************
26
32
*/
27
-
28
- // [Issue-26]: should prefer the "default namespace"
33
+
34
+ private final XmlMapper MAPPER = newMapper ();
35
+
36
+ // [dataformat-xml#26]: should prefer the "default namespace"
29
37
public void testRootNamespace () throws Exception
30
38
{
31
39
Person person = new Person ();
32
40
person .setName ( "hello" );
33
41
34
- XmlMapper xmlMapper = new XmlMapper ();
35
- String xml = xmlMapper .writeValueAsString (person );
42
+ String xml = MAPPER .writeValueAsString (person );
36
43
37
44
// should use "the default namespace"...
38
45
final String PREFIX = "<person xmlns=" ;
39
46
if (!xml .startsWith (PREFIX )) {
40
47
fail ("Expected XML to begin with '" +PREFIX +"', instead got: " +xml );
41
48
}
42
49
}
50
+
51
+ // [dataformat-xml#395]: should not bind standard `xml` namespace to anything
52
+ public void testXmlNs () throws Exception
53
+ {
54
+ String xml = MAPPER .writeValueAsString (new Issue395 ());
55
+ // System.err.println("XML: "+xml);
56
+ assertEquals ("<Issue395 xml:lang=\" en-US\" />" , xml .trim ());
57
+ }
43
58
}
0 commit comments