diff --git a/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java b/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java index 734e7a93cb..7408e41b92 100644 --- a/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/DefaultParserTest.java @@ -1,20 +1,22 @@ package com.baeldung.xml; -import static org.junit.Assert.*; - -import java.io.File; - import org.junit.Test; import org.w3c.dom.Node; import org.w3c.dom.NodeList; +import java.io.File; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class DefaultParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - final String fileNameSpace = "src/test/resources/example_namespace.xml"; + private final String fileNameSpace = "src/test/resources/example_namespace.xml"; - DefaultParser parser; + private DefaultParser parser; @Test public void getFirstLevelNodeListTest() { @@ -30,7 +32,7 @@ public class DefaultParserTest { parser = new DefaultParser(new File(fileName)); NodeList list = parser.getNodeListByTitle("XML"); - for (int i = 0; null != list && i < list.getLength(); i++) { + for (int i = 0; i < list.getLength(); i++) { Node nod = list.item(i); assertEquals("java", nod.getAttributes().getNamedItem("type").getTextContent()); assertEquals("02", nod.getAttributes().getNamedItem("tutId").getTextContent()); @@ -56,7 +58,7 @@ public class DefaultParserTest { public void getNodeListByDateTest(){ parser = new DefaultParser(new File(fileName)); NodeList list = parser.getNodeListByTitle("04022016"); - for (int i = 0; null != list && i < list.getLength(); i++) { + for (int i = 0; i < list.getLength(); i++) { Node nod = list.item(i); assertEquals("java", nod.getAttributes().getNamedItem("type").getTextContent()); assertEquals("04", nod.getAttributes().getNamedItem("tutId").getTextContent()); diff --git a/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java b/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java index 277eca8355..77e5fcdcda 100644 --- a/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/Dom4JParserTest.java @@ -1,25 +1,25 @@ package com.baeldung.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import java.io.File; -import java.util.List; - import org.dom4j.Element; import org.dom4j.Node; import org.junit.Test; +import java.io.File; +import java.util.List; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + public class Dom4JParserTest { - final String fileName = "src/test/resources/example.xml"; + private static final String FILE_NAME = "src/test/resources/example.xml"; - Dom4JParser parser; + private Dom4JParser parser; @Test public void getRootElementTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); Element root = parser.getRootElement(); assertNotNull(root); @@ -28,7 +28,7 @@ public class Dom4JParserTest { @Test public void getFirstElementListTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); List firstList = parser.getFirstElementList(); assertNotNull(firstList); @@ -38,7 +38,7 @@ public class Dom4JParserTest { @Test public void getElementByIdTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); Node element = parser.getNodeById("03"); String type = element.valueOf("@type"); @@ -47,7 +47,7 @@ public class Dom4JParserTest { @Test public void getElementsListByTitleTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); Node element = parser.getElementsListByTitle("XML"); assertEquals("java", element.valueOf("@type")); @@ -58,7 +58,7 @@ public class Dom4JParserTest { @Test public void generateModifiedDocumentTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); parser.generateModifiedDocument(); File generatedFile = new File("src/test/resources/example_updated.xml"); @@ -73,7 +73,7 @@ public class Dom4JParserTest { @Test public void generateNewDocumentTest() { - parser = new Dom4JParser(new File(fileName)); + parser = new Dom4JParser(new File(FILE_NAME)); parser.generateNewDocument(); File newFile = new File("src/test/resources/example_new.xml"); diff --git a/xml/src/test/java/com/baeldung/xml/JDomParserTest.java b/xml/src/test/java/com/baeldung/xml/JDomParserTest.java index 981458469f..e4034c48f0 100644 --- a/xml/src/test/java/com/baeldung/xml/JDomParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/JDomParserTest.java @@ -1,20 +1,20 @@ package com.baeldung.xml; +import org.jdom2.Element; +import org.junit.Test; + +import java.io.File; +import java.util.List; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import java.io.File; -import java.util.List; - -import org.jdom2.Element; -import org.junit.Test; - public class JDomParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - JDomParser parser; + private JDomParser parser; @Test public void getFirstElementListTest() { diff --git a/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java b/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java index 4d6ddf5f65..6e1a201b59 100644 --- a/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/JaxbParserTest.java @@ -1,22 +1,19 @@ package com.baeldung.xml; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import com.baeldung.xml.binding.Tutorials; +import org.junit.Test; import java.io.File; -import org.dom4j.Node; -import org.junit.Test; - -import com.baeldung.xml.binding.Tutorials; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class JaxbParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - JaxbParser parser; + private JaxbParser parser; @Test public void getFullDocumentTest(){ diff --git a/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java b/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java index 2521fcaf8a..8a88484f11 100644 --- a/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java +++ b/xml/src/test/java/com/baeldung/xml/JaxenDemoTest.java @@ -1,18 +1,18 @@ package com.baeldung.xml; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.junit.Test; import java.io.File; import java.util.List; -import org.junit.Test; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class JaxenDemoTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - JaxenDemo jaxenDemo; + private JaxenDemo jaxenDemo; @Test public void getFirstLevelNodeListTest() { diff --git a/xml/src/test/java/com/baeldung/xml/StaxParserTest.java b/xml/src/test/java/com/baeldung/xml/StaxParserTest.java index 3188777a79..d1080c88ac 100644 --- a/xml/src/test/java/com/baeldung/xml/StaxParserTest.java +++ b/xml/src/test/java/com/baeldung/xml/StaxParserTest.java @@ -1,20 +1,19 @@ package com.baeldung.xml; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import com.baeldung.xml.model.Tutorial; +import org.junit.Test; import java.io.File; import java.util.List; -import org.junit.Test; - -import com.baeldung.xml.model.Tutorial; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; public class StaxParserTest { - final String fileName = "src/test/resources/example.xml"; + private final String fileName = "src/test/resources/example.xml"; - StaxParser parser; + private StaxParser parser; @Test public void getAllTutorialsTest(){