mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-02 19:15:27 -04:00
add missing fields when cloning
This commit is contained in:
parent
391c86931b
commit
4bbbe77446
@ -27,7 +27,9 @@ public class JSONParserConfiguration extends ParserConfiguration {
|
|||||||
protected JSONParserConfiguration clone() {
|
protected JSONParserConfiguration clone() {
|
||||||
JSONParserConfiguration clone = new JSONParserConfiguration();
|
JSONParserConfiguration clone = new JSONParserConfiguration();
|
||||||
clone.overwriteDuplicateKey = overwriteDuplicateKey;
|
clone.overwriteDuplicateKey = overwriteDuplicateKey;
|
||||||
|
clone.strictMode = strictMode;
|
||||||
clone.maxNestingDepth = maxNestingDepth;
|
clone.maxNestingDepth = maxNestingDepth;
|
||||||
|
clone.keepStrings = keepStrings;
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,10 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
public class JSONParserConfigurationTest {
|
public class JSONParserConfigurationTest {
|
||||||
private static final String TEST_SOURCE = "{\"key\": \"value1\", \"key\": \"value2\"}";
|
private static final String TEST_SOURCE = "{\"key\": \"value1\", \"key\": \"value2\"}";
|
||||||
@ -32,6 +35,24 @@ public class JSONParserConfigurationTest {
|
|||||||
assertEquals("duplicate key should be overwritten", "value2", jsonObject.getString("key"));
|
assertEquals("duplicate key should be overwritten", "value2", jsonObject.getString("key"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void strictModeIsCloned(){
|
||||||
|
JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration()
|
||||||
|
.withStrictMode(true)
|
||||||
|
.withMaxNestingDepth(12);
|
||||||
|
|
||||||
|
assertTrue(jsonParserConfiguration.isStrictMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void maxNestingDepthIsCloned(){
|
||||||
|
JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration()
|
||||||
|
.<JSONParserConfiguration>withKeepStrings(true)
|
||||||
|
.withStrictMode(true);
|
||||||
|
|
||||||
|
assertTrue(jsonParserConfiguration.isKeepStrings());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void verifyDuplicateKeyThenMaxDepth() {
|
public void verifyDuplicateKeyThenMaxDepth() {
|
||||||
JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration()
|
JSONParserConfiguration jsonParserConfiguration = new JSONParserConfiguration()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user