-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add failign test for #51, just in case
- Loading branch information
1 parent
b5dcbd8
commit f6e9813
Showing
2 changed files
with
74 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
jr-stree/src/test/java/com/fasterxml/jackson/jr/stree/failing/DupFieldNameInTree51Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.fasterxml.jackson.jr.stree.failing; | ||
|
||
import com.fasterxml.jackson.jr.ob.JSON; | ||
import com.fasterxml.jackson.jr.ob.JSONObjectException; | ||
import com.fasterxml.jackson.jr.stree.TestBase; | ||
|
||
/** | ||
* Tests for reading content using {@link JSON} with proper | ||
* codec registration | ||
*/ | ||
public class DupFieldNameInTree51Test extends TestBase | ||
{ | ||
private final JSON treeJSON = jsonWithTreeCodec(); | ||
|
||
// [jackson-jr#51]: test dup keys for trees too | ||
public void testFailOnDupMapKeys() throws Exception | ||
{ | ||
JSON j = JSON.builder() | ||
.enable(JSON.Feature.FAIL_ON_DUPLICATE_MAP_KEYS) | ||
.build(); | ||
assertTrue(j.isEnabled(JSON.Feature.FAIL_ON_DUPLICATE_MAP_KEYS)); | ||
final String json = "{\"a\":1,\"b\":2,\"b\":3,\"c\":4}"; | ||
try { | ||
/*TreeNode node =*/ treeJSON.treeFrom(json); | ||
fail("Should not pass"); | ||
} catch (JSONObjectException e) { | ||
verifyException(e, "Duplicate key"); | ||
} | ||
} | ||
} |