Move NetconfMessage into netconf.api.messages
[netconf.git] / protocol / netconf-client / src / test / java / org / opendaylight / netconf / client / 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 package org.opendaylight.netconf.client;
9
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertTrue;
12
13 import java.util.Collection;
14 import org.junit.Test;
15 import org.opendaylight.netconf.api.messages.NetconfMessage;
16 import org.opendaylight.netconf.test.util.XmlFileLoader;
17
18 public class NetconfMessageUtilTest {
19     @Test
20     public void testNetconfMessageUtil() throws Exception {
21         final NetconfMessage okMessage = new NetconfMessage(XmlFileLoader.xmlFileToDocument(
22             "netconfMessages/rpc-reply_ok.xml"));
23         assertTrue(NetconfMessageUtil.isOKMessage(okMessage));
24         assertFalse(NetconfMessageUtil.isErrorMessage(okMessage));
25
26         final NetconfMessage errorMessage = new NetconfMessage(XmlFileLoader.xmlFileToDocument(
27             "netconfMessages/communicationError/testClientSendsRpcReply_expectedResponse.xml"));
28         assertTrue(NetconfMessageUtil.isErrorMessage(errorMessage));
29         assertFalse(NetconfMessageUtil.isOKMessage(errorMessage));
30
31         final Collection<String> caps = NetconfMessageUtil.extractCapabilitiesFromHello(
32             XmlFileLoader.xmlFileToDocument("netconfMessages/client_hello.xml"));
33         assertTrue(caps.contains("urn:ietf:params:netconf:base:1.0"));
34         assertTrue(caps.contains("urn:ietf:params:netconf:base:1.1"));
35     }
36 }