Skip to content

Commit f4cbedd

Browse files
committed
Add (failing) test case for #247
1 parent 3003088 commit f4cbedd

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.fasterxml.jackson.dataformat.xml.failing;
2+
3+
import com.fasterxml.jackson.core.JsonProcessingException;
4+
import com.fasterxml.jackson.databind.ObjectMapper;
5+
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
6+
7+
public class VerifyRootLocalName247Test extends XmlTestBase
8+
{
9+
static class Root {
10+
public int value;
11+
}
12+
13+
/*
14+
/**********************************************************************
15+
/* Test methods
16+
/**********************************************************************
17+
*/
18+
19+
private final ObjectMapper MAPPER = newMapper();
20+
21+
public void testRootNameValidation247() throws Exception
22+
{
23+
Root root = MAPPER.readValue("<Root><value>42</value></Root>", Root.class);
24+
assertEquals(42, root.value);
25+
26+
// so far so good. But why no validation for root local name?
27+
try {
28+
MAPPER.readValue("<Boot><value>42</value></Boot>", Root.class);
29+
fail("Should not allow wrong local name!");
30+
} catch (JsonProcessingException e) {
31+
verifyException(e, "Foobar");
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)