diff --git a/jackson/src/test/java/com/baeldung/jackson/xml/TestXMLSerializeDeserialize.java b/jackson/src/test/java/com/baeldung/jackson/xml/TestXMLSerializeDeserialize.java
index cd2c422184..92d0bd13d4 100644
--- a/jackson/src/test/java/com/baeldung/jackson/xml/TestXMLSerializeDeserialize.java
+++ b/jackson/src/test/java/com/baeldung/jackson/xml/TestXMLSerializeDeserialize.java
@@ -17,64 +17,70 @@ import com.fasterxml.jackson.dataformat.xml.XmlMapper;
public class TestXMLSerializeDeserialize {
- @Test
- public void whenJavaSerializedToXmlStr_thenCorrect() throws JsonProcessingException{
- XmlMapper xmlMapper = new XmlMapper();
- String xml = xmlMapper.writeValueAsString(new SimpleBean());
- assertNotNull(xml);
- }
- @Test
- public void whenJavaSerializedToXmlFile_thenCorrect() throws IOException{
- XmlMapper xmlMapper = new XmlMapper();
- xmlMapper.writeValue(new File("simple_bean.xml"), new SimpleBean());
- File file=new File("simple_bean.xml");
- assertNotNull(file);
- }
- @Test
- public void whenJavaGotFromXmlStr_thenCorrect() throws IOException {
- XmlMapper xmlMapper = new XmlMapper();
- SimpleBean value = xmlMapper.readValue(
- "12", SimpleBean.class);
- assertTrue(value.getX() == 1 && value.getY() == 2);
- }
- @Test
- public void whenJavaGotFromXmlFile_thenCorrect() throws IOException {
- File file = new File("simple_bean.xml");
- XmlMapper xmlMapper = new XmlMapper();
- String xml = inputStreamToString(new FileInputStream(file));
- SimpleBean value = xmlMapper.readValue(xml,SimpleBean.class);
- assertTrue(value.getX() == 1 && value.getY() == 2);
- }
+ @Test
+ public void whenJavaSerializedToXmlStr_thenCorrect() throws JsonProcessingException {
+ XmlMapper xmlMapper = new XmlMapper();
+ String xml = xmlMapper.writeValueAsString(new SimpleBean());
+ assertNotNull(xml);
+ }
- public static String inputStreamToString(InputStream is) throws IOException {
- BufferedReader br = null;
- StringBuilder sb = new StringBuilder();
+ @Test
+ public void whenJavaSerializedToXmlFile_thenCorrect() throws IOException {
+ XmlMapper xmlMapper = new XmlMapper();
+ xmlMapper.writeValue(new File("target/simple_bean.xml"), new SimpleBean());
+ File file = new File("target/simple_bean.xml");
+ assertNotNull(file);
+ }
- String line;
- br = new BufferedReader(new InputStreamReader(is));
- while ((line = br.readLine()) != null) {
- sb.append(line);
- }
- br.close();
- return sb.toString();
+ @Test
+ public void whenJavaGotFromXmlStr_thenCorrect() throws IOException {
+ XmlMapper xmlMapper = new XmlMapper();
+ SimpleBean value = xmlMapper.readValue(
+ "12", SimpleBean.class);
+ assertTrue(value.getX() == 1 && value.getY() == 2);
+ }
- }
+ @Test
+ 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);
+ assertTrue(value.getX() == 1 && value.getY() == 2);
+ }
+
+ 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 {
- private int x = 1;
- private int y = 2;
- public int getX() {
- return x;
- }
- public void setX(int x) {
- this.x = x;
- }
- public int getY() {
- return y;
- }
- public void setY(int y) {
- this.y = y;
- }
-
+ private int x = 1;
+ private int y = 2;
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ this.x = x;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public void setY(int y) {
+ this.y = y;
+ }
+
}