Skip to content

Commit f1f90b3

Browse files
authored
Update XmlDocumentUnitTest.java
1 parent b5e0e7d commit f1f90b3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

xml-modules/xml-3/src/test/java/com/baeldung/xml/XmlDocumentUnitTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,23 @@ public void givenXmlFile_whenConvertToOneLineString_thenSuccess() throws IOExcep
7979
}
8080
String xmlString = xmlContentBuilder.toString();
8181
// Remove tabs
82-
String oneLineXml = xmlString.replaceAll("\\t", "");
82+
xmlString = xmlString.replaceAll("\\t", "");
8383

8484
// Replace multiple spaces with a single space
85-
oneLineXml = oneLineXml.replaceAll(" +", " ");
85+
xmlString = xmlString.replaceAll(" +", " ");
8686

8787
// Remove spaces before/after tags (e.g., "> <" becomes "><")
8888
// This is important to ensure truly minimal whitespace
89-
oneLineXml = oneLineXml.replaceAll(">\\s+<", "><");
89+
xmlString = xmlString.replaceAll(">\\s+<", "><");
9090

9191
// Trim leading/trailing whitespace from the entire string
92-
String actualXml = oneLineXml.trim();
92+
String oneLineXml = xmlString.trim();
9393

9494
String expectedXml = """
9595
<?xml version="1.0" encoding="UTF-8"?><posts><post postId="1"><title>Parsing XML as a String in Java</title><author>John Doe</author></post></posts>
9696
""";
9797

98-
assertThat(actualXml).and(expectedXml).areIdentical();
98+
assertThat(oneLineXml).and(expectedXml).areIdentical();
9999
}
100100

101101
@Test

0 commit comments

Comments
 (0)