Skip to content

Commit ea3b7bc

Browse files
committed
Add passing #274 test
1 parent d54cb95 commit ea3b7bc

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.fasterxml.jackson.dataformat.xml.deser;
2+
3+
import com.fasterxml.jackson.databind.*;
4+
5+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
6+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
7+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
8+
9+
// [dataformat-xml#274]: Actually passes... can not reproduce failure
10+
public class Issue274PropertyNameTest extends XmlTestBase
11+
{
12+
private static final String XML =
13+
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
14+
"<dataroot xmlns:od=\"urn:schemas-microsoft-com:officedata\" generated=\"2017-06-07T10:11:20\">\n" +
15+
" <Event>\n" +
16+
" <EventId>34906566143035</EventId>\n" +
17+
" </Event>\n" +
18+
"</dataroot>";
19+
20+
static class Event {
21+
@JacksonXmlProperty(localName = "EventId")
22+
private String EventId;
23+
24+
public String getEventId() {
25+
return EventId;
26+
}
27+
28+
public void setEventId(String eventId) {
29+
this.EventId = eventId;
30+
}
31+
}
32+
33+
@JacksonXmlRootElement(localName = "dataroot")
34+
static class RootObject {
35+
@JacksonXmlProperty(localName = "Event")
36+
Event event;
37+
38+
@JacksonXmlProperty(localName = "generated")
39+
String generated;
40+
}
41+
42+
/*
43+
/********************************************************
44+
/* Test methods
45+
/********************************************************
46+
*/
47+
48+
// [dataformat-xml#274]
49+
public void testIssue274() throws Exception
50+
{
51+
final ObjectMapper xm = newMapper();
52+
53+
// serialization features
54+
// xm.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
55+
// xm.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
56+
// deserialization features
57+
xm.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT);
58+
//this is for deserialization only and means we don't need to camelCase xml property names
59+
xm.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);
60+
61+
RootObject obj = xm.readValue(XML, RootObject.class);
62+
assertNotNull(obj);
63+
}
64+
}

0 commit comments

Comments
 (0)