|
4 | 4 | Public Domain. |
5 | 5 | */ |
6 | 6 |
|
7 | | -import static org.junit.Assert.assertEquals; |
8 | | -import static org.junit.Assert.assertNotEquals; |
9 | | -import static org.junit.Assert.assertTrue; |
10 | | -import static org.junit.Assert.fail; |
11 | | - |
12 | 7 | import java.io.File; |
13 | 8 | import java.io.FileReader; |
14 | 9 | import java.io.FileWriter; |
|
27 | 22 | import org.junit.Test; |
28 | 23 | import org.junit.rules.TemporaryFolder; |
29 | 24 |
|
| 25 | +import static org.junit.Assert.*; |
| 26 | + |
30 | 27 |
|
31 | 28 | /** |
32 | 29 | * Tests for JSON-Java XML.java with XMLParserConfiguration.java |
@@ -564,8 +561,28 @@ public void shouldHandleEmptyNodeValue() |
564 | 561 | inputJSON.put("Emptyness", ""); |
565 | 562 | String expectedXmlWithoutExplicitEndTag = "<Emptyness/>"; |
566 | 563 | String expectedXmlWithExplicitEndTag = "<Emptyness></Emptyness>"; |
567 | | - assertEquals(expectedXmlWithoutExplicitEndTag, XML.toString(inputJSON, null, new XMLParserConfiguration().withCloseEmptyTag(false))); |
568 | | - assertEquals(expectedXmlWithExplicitEndTag, XML.toString(inputJSON, null, new XMLParserConfiguration().withCloseEmptyTag(true))); |
| 564 | + assertEquals(expectedXmlWithoutExplicitEndTag, XML.toString(inputJSON, null, |
| 565 | + new XMLParserConfiguration().withCloseEmptyTag(false))); |
| 566 | + assertEquals(expectedXmlWithExplicitEndTag, XML.toString(inputJSON, null, |
| 567 | + new XMLParserConfiguration().withCloseEmptyTag(true))); |
| 568 | + } |
| 569 | + |
| 570 | + @Test |
| 571 | + public void shouldKeepConfigurationIntactAndUpdateCloseEmptyTagChoice() |
| 572 | + { |
| 573 | + XMLParserConfiguration keepStrings = XMLParserConfiguration.KEEP_STRINGS; |
| 574 | + XMLParserConfiguration keepStringsAndCloseEmptyTag = keepStrings.withCloseEmptyTag(true); |
| 575 | + XMLParserConfiguration keepDigits = keepStringsAndCloseEmptyTag.withKeepStrings(false); |
| 576 | + XMLParserConfiguration keepDigitsAndNoCloseEmptyTag = keepDigits.withCloseEmptyTag(false); |
| 577 | + assertTrue(keepStrings.isKeepStrings()); |
| 578 | + assertFalse(keepStrings.isCloseEmptyTag()); |
| 579 | + assertTrue(keepStringsAndCloseEmptyTag.isKeepStrings()); |
| 580 | + assertTrue(keepStringsAndCloseEmptyTag.isCloseEmptyTag()); |
| 581 | + assertFalse(keepDigits.isKeepStrings()); |
| 582 | + assertTrue(keepDigits.isCloseEmptyTag()); |
| 583 | + assertFalse(keepDigitsAndNoCloseEmptyTag.isKeepStrings()); |
| 584 | + assertFalse(keepDigitsAndNoCloseEmptyTag.isCloseEmptyTag()); |
| 585 | + |
569 | 586 | } |
570 | 587 |
|
571 | 588 | /** |
|
0 commit comments