Merge "BUG 1839 - HTTP delete of non existing data"
[controller.git] / opendaylight / netconf / netconf-util / src / test / java / org / opendaylight / controller / netconf / util / messages / NetconfMessageUtilTest.java
1 /*
2  * Copyright (c) 2014 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.messages;
10
11 import java.util.Collection;
12 import org.junit.Test;
13 import org.opendaylight.controller.netconf.api.NetconfMessage;
14 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
15 import org.w3c.dom.Document;
16
17 import static org.junit.Assert.assertFalse;
18 import static org.junit.Assert.assertTrue;
19
20 public class NetconfMessageUtilTest {
21     @Test
22     public void testNetconfMessageUtil() throws Exception {
23         Document okMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/rpc-reply_ok.xml");
24         assertTrue(NetconfMessageUtil.isOKMessage(new NetconfMessage(okMessage)));
25         assertFalse(NetconfMessageUtil.isErrorMessage(new NetconfMessage(okMessage)));
26
27         Document errorMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/communicationError/testClientSendsRpcReply_expectedResponse.xml");
28         assertTrue(NetconfMessageUtil.isErrorMessage(new NetconfMessage(errorMessage)));
29         assertFalse(NetconfMessageUtil.isOKMessage(new NetconfMessage(errorMessage)));
30
31         Document helloMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/client_hello.xml");
32         Collection<String> caps = NetconfMessageUtil.extractCapabilitiesFromHello(new NetconfMessage(helloMessage).getDocument());
33         assertTrue(caps.contains("urn:ietf:params:netconf:base:1.0"));
34         assertTrue(caps.contains("urn:ietf:params:netconf:base:1.1"));
35     }
36 }