use of io.servicecomb.foundation.common.config.impl.IdXmlLoader in project java-chassis by ServiceComb.
the class TestConfig method testIdXml.
@Test
public void testIdXml() throws Exception {
List<String> locationPatternList = new ArrayList<>();
locationPatternList.add("classpath*:config/config.test.inc.xml");
ConfigLoader loader = new IdXmlLoader(locationPatternList, ".inc.xml");
Document doc = loader.load();
Element root = doc.getDocumentElement();
Assert.assertEquals("configs", root.getNodeName());
NodeList propList = root.getElementsByTagName("properties");
Assert.assertEquals(1, propList.getLength());
Element prop = (Element) propList.item(0);
Assert.assertEquals("pTest", prop.getAttributes().getNamedItem("id").getNodeValue());
NodeList pathListProp = prop.getElementsByTagName("path");
Assert.assertEquals(TEST_PROP_LIST_SIZE, pathListProp.getLength());
Assert.assertEquals("classpath*:config/test.properties", pathListProp.item(0).getTextContent());
Assert.assertEquals("classpath*:config/test.ext.properties", pathListProp.item(1).getTextContent());
NodeList xmlList = root.getElementsByTagName("xml");
Assert.assertEquals(1, xmlList.getLength());
Element xml = (Element) xmlList.item(0);
Assert.assertEquals("xTest", xml.getAttributes().getNamedItem("id").getNodeValue());
NodeList pathListXml = xml.getElementsByTagName("path");
Assert.assertEquals(TEST_PROP_LIST_SIZE, pathListXml.getLength());
Assert.assertEquals("classpath*:config/test.xml", pathListXml.item(0).getTextContent());
Assert.assertEquals("classpath*:config/test.ext.xml", pathListXml.item(1).getTextContent());
}