aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/musichub/util/XMLHandlerTest.java
blob: 7b5a7913880eccb620e5344c61d2d8e9170bf67f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package musichub.util;


import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;

public class XMLHandlerTest {

    final String DIR = System.getProperty("user.dir");
    final String JUNIT_FILE_PATH = DIR + "/files/JUnit.xml";

    @Test
    void testCreateXML() {
        XMLHandler xmlHandler = new XMLHandler(); //XML class
        Document document = xmlHandler.createXMLDocument(); //XMLDocument method
        xmlHandler.createXMLFile(document, JUNIT_FILE_PATH); //XMLFile method
    }

    @Test
    void testParseXMLFile() {
        final String PARSE_DIR = System.getProperty("user.dir");
        final String PARSE_FILE_PATH = PARSE_DIR + "/files/parse_JUnit.xml";
        XMLHandler xmlHandler = new XMLHandler();
        //wrong content of file resulting in an exception, will print it during test but it's normal
        NodeList junitNodes = xmlHandler.parseXMLFile(JUNIT_FILE_PATH);
        //right content of file
        NodeList parseNodes = xmlHandler.parseXMLFile(PARSE_FILE_PATH);
    }
}