File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
xml-modules/xml-3/src/test/java/com/baeldung/xml Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 20
20
import java .nio .charset .StandardCharsets ;
21
21
22
22
import static org .junit .jupiter .api .Assertions .*;
23
+ import static org .xmlunit .assertj .XmlAssert .assertThat ;
23
24
24
25
public class XmlDocumentUnitTest {
25
26
@@ -89,14 +90,13 @@ public void givenXmlFile_whenConvertToOneLineString_thenSuccess() throws IOExcep
89
90
oneLineXml = oneLineXml .replaceAll (">\\ s+<" , "><" );
90
91
91
92
// Trim leading/trailing whitespace from the entire string
92
- oneLineXml = oneLineXml .trim ();
93
+ String actualXml = oneLineXml .trim ();
93
94
94
95
String expectedXml = """
95
96
<?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>
96
97
""" ;
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);
100
100
}
101
101
102
102
@ Test
You can’t perform that action at this time.
0 commit comments