2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.netconf.util.messages;
10 import static org.junit.Assert.assertFalse;
11 import static org.junit.Assert.assertTrue;
13 import java.util.Collection;
14 import org.junit.Test;
15 import org.opendaylight.netconf.api.NetconfMessage;
16 import org.opendaylight.netconf.util.test.XmlFileLoader;
18 public class NetconfMessageUtilTest {
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));
26 final NetconfMessage errorMessage = new NetconfMessage(XmlFileLoader.xmlFileToDocument(
27 "netconfMessages/communicationError/testClientSendsRpcReply_expectedResponse.xml"));
28 assertTrue(NetconfMessageUtil.isErrorMessage(errorMessage));
29 assertFalse(NetconfMessageUtil.isOKMessage(errorMessage));
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"));