Delete netconf
[controller.git] / opendaylight / netconf / netconf-api / src / test / java / org / opendaylight / controller / netconf / api / NetconfDocumentedExceptionTest.java
diff --git a/opendaylight/netconf/netconf-api/src/test/java/org/opendaylight/controller/netconf/api/NetconfDocumentedExceptionTest.java b/opendaylight/netconf/netconf-api/src/test/java/org/opendaylight/controller/netconf/api/NetconfDocumentedExceptionTest.java
deleted file mode 100644 (file)
index 3621f83..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-
-package org.opendaylight.controller.netconf.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
-import java.util.Iterator;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-import org.junit.Before;
-import org.junit.Test;
-import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.netconf.api.xml.XmlNetconfConstants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-
-/**
- * Unit tests for NetconfDocumentedException.
- *
- * @author Thomas Pantelis
- */
-public class NetconfDocumentedExceptionTest {
-
-    private XPath xpath;
-
-    @Before
-    public void setUp() throws Exception {
-        XPathFactory xPathfactory = XPathFactory.newInstance();
-        xpath = xPathfactory.newXPath();
-        xpath.setNamespaceContext( new NamespaceContext() {
-            @Override
-            public Iterator<?> getPrefixes( String namespaceURI ) {
-                return Collections.singletonList( "netconf" ).iterator();
-            }
-
-            @Override
-            public String getPrefix( String namespaceURI ) {
-                return "netconf";
-            }
-
-            @Override
-            public String getNamespaceURI( String prefix ) {
-                return XmlNetconfConstants.URN_IETF_PARAMS_XML_NS_NETCONF_BASE_1_0;
-            }
-        } );
-    }
-
-    @Test
-    public void testToAndFromXMLDocument() throws XPathExpressionException {
-        String errorMessage = "mock error message";
-        DocumentedException ex = new NetconfDocumentedException( errorMessage, null,
-                                                                        DocumentedException.ErrorType.protocol,
-                                                                        DocumentedException.ErrorTag.data_exists,
-                                                                        DocumentedException.ErrorSeverity.warning,
-                                                                        ImmutableMap.of( "foo", "bar" ) );
-
-        Document doc = ex.toXMLDocument();
-        assertNotNull( "Document is null", doc );
-
-        Node rootNode = doc.getDocumentElement();
-
-        assertEquals( "getNamespaceURI", "urn:ietf:params:xml:ns:netconf:base:1.0", rootNode.getNamespaceURI() );
-        assertEquals( "getLocalName", "rpc-reply", rootNode.getLocalName() );
-
-        Node rpcErrorNode = getNode( "/netconf:rpc-reply/netconf:rpc-error", rootNode );
-        assertNotNull( "rpc-error not found", rpcErrorNode );
-
-        Node errorTypeNode = getNode( "netconf:error-type", rpcErrorNode );
-        assertNotNull( "error-type not found", errorTypeNode );
-        assertEquals( "error-type", DocumentedException.ErrorType.protocol.getTagValue(),
-                      errorTypeNode.getTextContent() );
-
-        Node errorTagNode = getNode( "netconf:error-tag", rpcErrorNode );
-        assertNotNull( "error-tag not found", errorTagNode );
-        assertEquals( "error-tag", DocumentedException.ErrorTag.data_exists.getTagValue(),
-                      errorTagNode.getTextContent() );
-
-        Node errorSeverityNode = getNode( "netconf:error-severity", rpcErrorNode );
-        assertNotNull( "error-severity not found", errorSeverityNode );
-        assertEquals( "error-severity", DocumentedException.ErrorSeverity.warning.getTagValue(),
-                      errorSeverityNode.getTextContent() );
-
-        Node errorInfoNode = getNode( "netconf:error-info/netconf:foo", rpcErrorNode );
-        assertNotNull( "foo not found", errorInfoNode );
-        assertEquals( "foo", "bar", errorInfoNode.getTextContent() );
-
-        Node errorMsgNode = getNode( "netconf:error-message", rpcErrorNode );
-        assertNotNull( "error-message not found", errorMsgNode );
-        assertEquals( "error-message", errorMessage, errorMsgNode.getTextContent() );
-
-        // Test fromXMLDocument
-
-        ex = DocumentedException.fromXMLDocument( doc );
-
-        assertNotNull( "NetconfDocumentedException is null", ex );
-        assertEquals( "getErrorSeverity", DocumentedException.ErrorSeverity.warning, ex.getErrorSeverity() );
-        assertEquals( "getErrorTag", DocumentedException.ErrorTag.data_exists, ex.getErrorTag() );
-        assertEquals( "getErrorType", DocumentedException.ErrorType.protocol, ex.getErrorType() );
-        assertEquals( "getLocalizedMessage", errorMessage, ex.getLocalizedMessage() );
-        assertEquals( "getErrorInfo", ImmutableMap.of( "foo", "bar" ), ex.getErrorInfo() );
-    }
-
-    @SuppressWarnings("unchecked")
-    <T> T getNode( String xpathExp, Node node ) throws XPathExpressionException {
-        return (T)xpath.compile( xpathExp ).evaluate( node, XPathConstants.NODE );
-    }
-}
-