From d4c6fe18ca94ed0880720d7ff135b82920d764b4 Mon Sep 17 00:00:00 2001 From: Clyhtsuriva Date: Sun, 27 Jun 2021 11:16:21 +0200 Subject: XMLHandler tests covered at 91% --- .../site/jacoco/musichub.util/XMLHandler.java.html | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'target/site/jacoco/musichub.util/XMLHandler.java.html') diff --git a/target/site/jacoco/musichub.util/XMLHandler.java.html b/target/site/jacoco/musichub.util/XMLHandler.java.html index b8ee27a..7d6e751 100644 --- a/target/site/jacoco/musichub.util/XMLHandler.java.html +++ b/target/site/jacoco/musichub.util/XMLHandler.java.html @@ -23,51 +23,51 @@ public class XMLHandler { DocumentBuilderFactory documentFactory; DocumentBuilder documentBuilder; - public XMLHandler() { + public XMLHandler() { try { - transformerFactory = TransformerFactory.newInstance(); - transformer = transformerFactory.newTransformer(); - documentFactory = DocumentBuilderFactory.newInstance(); - documentBuilder = documentFactory.newDocumentBuilder(); + transformerFactory = TransformerFactory.newInstance(); + transformer = transformerFactory.newTransformer(); + documentFactory = DocumentBuilderFactory.newInstance(); + documentBuilder = documentFactory.newDocumentBuilder(); } catch (TransformerException | ParserConfigurationException tfe) { tfe.printStackTrace(); - } - } + } + } public void createXMLFile(Document document, String filePath) { try { // create the xml file //transform the DOM Object to an XML File - DOMSource domSource = new DOMSource(document); - StreamResult streamResult = new StreamResult(new File(filePath)); + DOMSource domSource = new DOMSource(document); + StreamResult streamResult = new StreamResult(new File(filePath)); // If you use // StreamResult result = new StreamResult(System.out); // the output will be pushed to the standard output ... // You can use that for debugging - transformer.transform(domSource, streamResult); + transformer.transform(domSource, streamResult); } catch (TransformerException tfe) { tfe.printStackTrace(); - } - } + } + } public Document createXMLDocument() { - return documentBuilder.newDocument(); + return documentBuilder.newDocument(); } public NodeList parseXMLFile(String filePath) { - NodeList elementNodes = null; + NodeList elementNodes = null; try { - Document document = documentBuilder.parse(new File(filePath)); - Element root = document.getDocumentElement(); + Document document = documentBuilder.parse(new File(filePath)); + Element root = document.getDocumentElement(); - elementNodes = root.getChildNodes(); - } catch (SAXException | IOException e) { - e.printStackTrace(); - } - return elementNodes; + elementNodes = root.getChildNodes(); + } catch (SAXException | IOException e) { + e.printStackTrace(); + } + return elementNodes; } -- cgit v1.2.3