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
9 package org.opendaylight.controller.netconf.util.messages;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import java.util.Collection;
15 import org.junit.Test;
16 import org.opendaylight.controller.netconf.api.NetconfMessage;
17 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
18 import org.w3c.dom.Document;
20 public class NetconfMessageUtilTest {
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)));
27 Document errorMessage = XmlFileLoader.xmlFileToDocument("netconfMessages/communicationError/testClientSendsRpcReply_expectedResponse.xml");
28 assertTrue(NetconfMessageUtil.isErrorMessage(new NetconfMessage(errorMessage)));
29 assertFalse(NetconfMessageUtil.isOKMessage(new NetconfMessage(errorMessage)));
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"));