Add missing headers to config, netconf subsystems
[controller.git] / opendaylight / netconf / netconf-impl / src / test / java / org / opendaylight / controller / netconf / impl / ExiEncodeDecodeTest.java
1 /*\r
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.controller.netconf.impl;\r
9 \r
10 import static junit.framework.Assert.assertNotNull;\r
11 import io.netty.buffer.ByteBuf;\r
12 import io.netty.buffer.Unpooled;\r
13 \r
14 import java.util.ArrayList;\r
15 import java.util.List;\r
16 \r
17 import org.junit.Test;\r
18 import org.opendaylight.controller.netconf.api.NetconfMessage;\r
19 import org.opendaylight.controller.netconf.util.test.XmlFileLoader;\r
20 import org.opendaylight.controller.netconf.util.xml.ExiParameters;\r
21 import org.opendaylight.controller.netconf.util.xml.ExiUtil;\r
22 import org.opendaylight.controller.netconf.util.xml.XmlElement;\r
23 \r
24 \r
25 \r
26 public class ExiEncodeDecodeTest  {\r
27     @Test\r
28     public void encodeExi() throws Exception{\r
29 \r
30         String startExiString = XmlFileLoader.xmlFileToString("netconfMessages/startExi.xml");\r
31         assertNotNull(startExiString);\r
32 \r
33         NetconfMessage startExiMessage = XmlFileLoader.xmlFileToNetconfMessage(("netconfMessages/startExi.xml"));\r
34         assertNotNull(startExiMessage);\r
35 \r
36         ExiParameters exiParams = new ExiParameters();\r
37         exiParams.setParametersFromXmlElement(XmlElement.fromDomElement(startExiMessage.getDocument().getDocumentElement()));\r
38         assertNotNull(exiParams);\r
39 \r
40         ByteBuf encodedBuf = Unpooled.buffer();\r
41         ByteBuf sourceBuf = Unpooled.copiedBuffer(startExiString.getBytes());\r
42         ExiUtil.encode(sourceBuf, encodedBuf, exiParams);\r
43 \r
44         List<Object> newOut = new ArrayList<Object>();\r
45         ExiUtil.decode(encodedBuf, newOut, exiParams);\r
46 \r
47         ByteBuf decodedBuf = (ByteBuf)newOut.get(0);\r
48         String decodedString = new String(decodedBuf.array(),"UTF-8");\r
49         assertNotNull(decodedString);\r
50     }\r
51 }\r