Debian Codegraph @

jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/DupFieldNameInTree51Test.java

raw
1 package com.fasterxml.jackson.jr.stree.failing;
2
3 import com.fasterxml.jackson.jr.ob.JSON;
4 import com.fasterxml.jackson.jr.ob.JSONObjectException;
5 import com.fasterxml.jackson.jr.stree.JacksonJrTreeTestBase;
6
7 /**
8 * Tests for reading content using {@link JSON} with proper
9 * codec registration
10 */
11 public class DupFieldNameInTree51Test extends JacksonJrTreeTestBase
12 {
13 private final JSON treeJSON = jsonWithTreeCodec();
14
15 // [jackson-jr#51]: test dup keys for trees too
16 public void testFailOnDupMapKeys() throws Exception
17 {
18 JSON j = JSON.builder()
19 .enable(JSON.Feature.FAIL_ON_DUPLICATE_MAP_KEYS)
20 .build();
21 assertTrue(j.isEnabled(JSON.Feature.FAIL_ON_DUPLICATE_MAP_KEYS));
22 final String json = "{\"a\":1,\"b\":2,\"b\":3,\"c\":4}";
23 try {
24 /*TreeNode node =*/ treeJSON.treeFrom(json);
25 fail("Should not pass");
26 } catch (JSONObjectException e) {
27 verifyException(e, "Duplicate key");
28 }
29 }
30 }