-
-
Notifications
You must be signed in to change notification settings - Fork 220
/
XsiNilForStringsTest.java
42 lines (34 loc) · 1.33 KB
/
XsiNilForStringsTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.fasterxml.jackson.dataformat.xml.deser;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
public class XsiNilForStringsTest extends XmlTestBase
{
private final static String XSI_NS_DECL = "xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'";
protected static class StringPair {
public String first, second;
}
private final XmlMapper MAPPER = newMapper();
// [dataformat-xml#378]
public void testWithStringAsNull() throws Exception
{
StringPair bean;
bean = MAPPER.readValue(
"<StringPair "+XSI_NS_DECL+"><first>not null</first><second xsi:nil='true' /></StringPair>",
StringPair.class);
assertNotNull(bean);
assertEquals("not null", bean.first);
assertNull(bean.second);
}
// [dataformat-xml#378]
public void testWithStringAsNull2() throws Exception
{
StringPair bean;
bean = MAPPER.readValue(
"<StringPair "+XSI_NS_DECL+"><first xsi:nil='true' /><second>not null</second></StringPair>",
//"<StringPair "+XSI_NS_DECL+"><first xsi:nil='true'></first><second>not null</second></StringPair>",
StringPair.class);
assertNotNull(bean);
assertNull(bean.first);
assertEquals("not null", bean.second);
}
}