File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
xml-modules/xml-3/src/test/java/com/baeldung/xml Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -79,23 +79,23 @@ public void givenXmlFile_whenConvertToOneLineString_thenSuccess() throws IOExcep
79
79
}
80
80
String xmlString = xmlContentBuilder .toString ();
81
81
// Remove tabs
82
- String oneLineXml = xmlString .replaceAll ("\\ t" , "" );
82
+ xmlString = xmlString .replaceAll ("\\ t" , "" );
83
83
84
84
// Replace multiple spaces with a single space
85
- oneLineXml = oneLineXml .replaceAll (" +" , " " );
85
+ xmlString = xmlString .replaceAll (" +" , " " );
86
86
87
87
// Remove spaces before/after tags (e.g., "> <" becomes "><")
88
88
// This is important to ensure truly minimal whitespace
89
- oneLineXml = oneLineXml .replaceAll (">\\ s+<" , "><" );
89
+ xmlString = xmlString .replaceAll (">\\ s+<" , "><" );
90
90
91
91
// Trim leading/trailing whitespace from the entire string
92
- String actualXml = oneLineXml .trim ();
92
+ String oneLineXml = xmlString .trim ();
93
93
94
94
String expectedXml = """
95
95
<?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
96
""" ;
97
97
98
- assertThat (actualXml ).and (expectedXml ).areIdentical ();
98
+ assertThat (oneLineXml ).and (expectedXml ).areIdentical ();
99
99
}
100
100
101
101
@ Test
You can’t perform that action at this time.
0 commit comments