Remove netconf from commons/opendaylight pom
[controller.git] / opendaylight / netconf / netconf-util / src / test / java / org / opendaylight / controller / netconf / util / xml / XMLNetconfUtilTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.netconf.util.xml;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.fail;
13
14 import javax.xml.xpath.XPathConstants;
15 import javax.xml.xpath.XPathExpression;
16 import org.junit.Test;
17 import org.opendaylight.controller.config.util.xml.XmlUtil;
18 import org.w3c.dom.Element;
19
20 public class XMLNetconfUtilTest {
21
22     @Test
23     public void testXPath() throws Exception {
24         final XPathExpression correctXPath = XMLNetconfUtil.compileXPath("/top/innerText");
25         try {
26             XMLNetconfUtil.compileXPath("!@(*&$!");
27             fail("Incorrect xpath should fail");
28         } catch (IllegalStateException e) {}
29         final Object value = XmlUtil.evaluateXPath(correctXPath, XmlUtil.readXmlToDocument("<top><innerText>value</innerText></top>"), XPathConstants.NODE);
30         assertEquals("value", ((Element) value).getTextContent());
31     }
32
33 }