Skip to content

Commit ab1ff2b

Browse files
authored
Update XmlDocumentUnitTest.java
1 parent 53fd363 commit ab1ff2b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.nio.charset.StandardCharsets;
2121

2222
import static org.junit.jupiter.api.Assertions.*;
23+
import static org.xmlunit.assertj.XmlAssert.assertThat;
2324

2425
public class XmlDocumentUnitTest {
2526

@@ -89,14 +90,13 @@ public void givenXmlFile_whenConvertToOneLineString_thenSuccess() throws IOExcep
8990
oneLineXml = oneLineXml.replaceAll(">\\s+<", "><");
9091

9192
// Trim leading/trailing whitespace from the entire string
92-
oneLineXml = oneLineXml.trim();
93+
String actualXml = oneLineXml.trim();
9394

9495
String expectedXml = """
9596
<?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>
9697
""";
97-
// Capture and verify the output
98-
String expectedOutput = expectedXml + System.lineSeparator();
99-
assertEquals(expectedOutput, oneLineXml);
98+
assertThat(actualXml).and(expectedXml).areIdentical();
99+
//assertEquals(expectedOutput, oneLineXml);
100100
}
101101

102102
@Test

0 commit comments

Comments
 (0)