From cf932245aa5cf60e9d8a255e5c662de7090232d3 Mon Sep 17 00:00:00 2001 From: anuragkumawat Date: Thu, 23 Jun 2022 21:06:31 +0530 Subject: [PATCH] JAVA-12710 Look into XML Serialization and Deserialization with Jackson article --- .../xml/XMLSerializeDeserializeUnitTest.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java index 74ba28d996..6d0a5df627 100644 --- a/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java +++ b/jackson-modules/jackson-conversions/src/test/java/com/baeldung/jackson/xml/XMLSerializeDeserializeUnitTest.java @@ -48,8 +48,7 @@ public class XMLSerializeDeserializeUnitTest { public void whenJavaGotFromXmlFile_thenCorrect() throws IOException { File file = new File("src/test/resources/simple_bean.xml"); XmlMapper xmlMapper = new XmlMapper(); - String xml = inputStreamToString(new FileInputStream(file)); - SimpleBean value = xmlMapper.readValue(xml, SimpleBean.class); + SimpleBean value = xmlMapper.readValue(file, SimpleBean.class); assertTrue(value.getX() == 1 && value.getY() == 2); } @@ -122,19 +121,6 @@ public class XMLSerializeDeserializeUnitTest { xmlMapper.writeValue(byteArrayOutputStream, person); assertEquals(expectedXml, byteArrayOutputStream.toString()); } - - private static String inputStreamToString(InputStream is) throws IOException { - BufferedReader br; - StringBuilder sb = new StringBuilder(); - - String line; - br = new BufferedReader(new InputStreamReader(is)); - while ((line = br.readLine()) != null) { - sb.append(line); - } - br.close(); - return sb.toString(); - } } class SimpleBean {