* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-package org.opendaylight.controller.netconf.util.xml;
+package org.opendaylight.controller.config.util.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.base.Optional;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
+import java.io.ByteArrayInputStream;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Test;
public void testLoadSchema() throws Exception {
XmlUtil.loadSchema();
try {
- XmlUtil.loadSchema(getClass().getResourceAsStream("/netconfMessages/commit.xml"));
+ XmlUtil.loadSchema(new ByteArrayInputStream(xml.getBytes()));
fail("Input stream does not contain xsd");
} catch (final IllegalStateException e) {
assertTrue(e.getCause() instanceof SAXParseException);
" </hello>]]>]]>");
}
- @Test
- public void testXPath() throws Exception {
- final XPathExpression correctXPath = XMLNetconfUtil.compileXPath("/top/innerText");
- try {
- XMLNetconfUtil.compileXPath("!@(*&$!");
- fail("Incorrect xpath should fail");
- } catch (IllegalStateException e) {}
- final Object value = XmlUtil.evaluateXPath(correctXPath, XmlUtil.readXmlToDocument("<top><innerText>value</innerText></top>"), XPathConstants.NODE);
- assertEquals("value", ((Element) value).getTextContent());
- }
}
\ No newline at end of file