Skip to content

Commit fdd8397

Browse files
authored
Merge pull request eugenp#12402 from anuragkumawat/JAVA-12710
JAVA-12710 Look into XML Serialization and Deserialization with Jackson article
2 parents 020862e + 0b0b8ad commit fdd8397

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ public void whenJavaGotFromXmlStr_thenCorrect() throws IOException {
4848
public void whenJavaGotFromXmlFile_thenCorrect() throws IOException {
4949
File file = new File("src/test/resources/simple_bean.xml");
5050
XmlMapper xmlMapper = new XmlMapper();
51-
String xml = inputStreamToString(new FileInputStream(file));
52-
SimpleBean value = xmlMapper.readValue(xml, SimpleBean.class);
51+
SimpleBean value = xmlMapper.readValue(file, SimpleBean.class);
5352
assertTrue(value.getX() == 1 && value.getY() == 2);
5453
}
5554

@@ -122,19 +121,6 @@ public void whenJavaSerializedToXmlFile_thenSuccess() throws IOException {
122121
xmlMapper.writeValue(byteArrayOutputStream, person);
123122
assertEquals(expectedXml, byteArrayOutputStream.toString());
124123
}
125-
126-
private static String inputStreamToString(InputStream is) throws IOException {
127-
BufferedReader br;
128-
StringBuilder sb = new StringBuilder();
129-
130-
String line;
131-
br = new BufferedReader(new InputStreamReader(is));
132-
while ((line = br.readLine()) != null) {
133-
sb.append(line);
134-
}
135-
br.close();
136-
return sb.toString();
137-
}
138124
}
139125

140126
class SimpleBean {

0 commit comments

Comments
 (0)