You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
48 lines
1.5 KiB
package de.superx.util; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import java.io.File; |
|
|
|
import org.jdom2.Element; |
|
import org.jdom2.Namespace; |
|
import org.junit.Ignore; |
|
import org.junit.Test; |
|
|
|
/** |
|
* Class for testing {@link de.superx.util.XmlUtil} |
|
* |
|
* @author hiber |
|
*/ |
|
public class XmlUtilTest { |
|
|
|
private static final File TEST_FILE = new File("test/resources/xmlunittest/kdsf_testfile_2018.xml"); |
|
|
|
@SuppressWarnings("static-method") |
|
@Test |
|
public void testGetRootElement() throws Exception { |
|
final String EXPECTED_ROOT_NAME = "kdsf"; |
|
Element root = XmlUtil.getRootElement(TEST_FILE); |
|
String rootName = root.getName(); |
|
assertEquals("Name of root element as expected", EXPECTED_ROOT_NAME, rootName); |
|
|
|
} |
|
|
|
@SuppressWarnings("static-method") |
|
@Test |
|
public void testTraverseWithNamespace() throws Exception { |
|
final String EXPECTED_ELEMENT_NAME = "Aggregationsniveau"; |
|
Namespace namespace = Namespace.getNamespace("http://kerndatensatz-forschung.de/version1/technisches_datenmodell/xsd/kdsf.xsd"); |
|
Element root = XmlUtil.getRootElement(TEST_FILE); |
|
Element aggregationsniveau = XmlUtil.traverse(root, namespace, "Beschaeftigte", "AnzahlPersonenKopfzahlen", "Aggregationsniveau"); |
|
String elementName = aggregationsniveau.getName(); |
|
assertEquals("Name of element as expected", EXPECTED_ELEMENT_NAME, elementName); |
|
} |
|
|
|
@Ignore |
|
@Test |
|
public void testTraverseWithoutNamespace() { |
|
// TODO: test.xml without namespace into resource folder |
|
} |
|
|
|
}
|
|
|