X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2FNetconfEXIHandlersTest.java;fp=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2FNetconfEXIHandlersTest.java;h=0000000000000000000000000000000000000000;hb=9ba2b4eca79bcc0e78099b133296801c8d45a6c4;hp=34f8619a6925bce016e82a81dfbcd35a36935e27;hpb=b2e81149739c87f0ecc2ce7f06448d7a5d3162b8;p=controller.git diff --git a/opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIHandlersTest.java b/opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIHandlersTest.java deleted file mode 100644 index 34f8619a69..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfEXIHandlersTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.nettyutil.handler; - -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; - -import com.google.common.collect.Lists; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.Arrays; -import java.util.List; -import org.custommonkey.xmlunit.XMLUnit; -import org.junit.Before; -import org.junit.Test; -import org.opendaylight.controller.config.util.xml.XmlUtil; -import org.opendaylight.controller.netconf.api.NetconfMessage; -import org.openexi.proc.common.EXIOptions; -import org.openexi.proc.common.EXIOptionsException; -import org.openexi.sax.Transmogrifier; -import org.openexi.sax.TransmogrifierException; -import org.xml.sax.InputSource; - -public class NetconfEXIHandlersTest { - - private final String msgAsString = ""; - private NetconfMessageToEXIEncoder netconfMessageToEXIEncoder; - private NetconfEXIToMessageDecoder netconfEXIToMessageDecoder; - private NetconfMessage msg; - private byte[] msgAsExi; - - @Before - public void setUp() throws Exception { - final NetconfEXICodec codec = new NetconfEXICodec(new EXIOptions()); - netconfMessageToEXIEncoder = NetconfMessageToEXIEncoder.create(codec); - netconfEXIToMessageDecoder = NetconfEXIToMessageDecoder.create(codec); - - msg = new NetconfMessage(XmlUtil.readXmlToDocument(msgAsString)); - this.msgAsExi = msgToExi(msgAsString, codec); - } - - private static byte[] msgToExi(final String msgAsString, final NetconfEXICodec codec) throws EXIOptionsException, TransmogrifierException, IOException { - final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); - final Transmogrifier transmogrifier = codec.getTransmogrifier(); - transmogrifier.setOutputStream(byteArrayOutputStream); - transmogrifier.encode(new InputSource(new ByteArrayInputStream(msgAsString.getBytes()))); - return byteArrayOutputStream.toByteArray(); - } - - @Test - public void testEncodeDecode() throws Exception { - final ByteBuf buffer = Unpooled.buffer(); - netconfMessageToEXIEncoder.encode(null, msg, buffer); - final int exiLength = msgAsExi.length; - // array from buffer is cca 256 n length, compare only subarray - assertArrayEquals(msgAsExi, Arrays.copyOfRange(buffer.array(), 0, exiLength)); - - // assert all other bytes in buffer be 0 - for (int i = exiLength; i < buffer.array().length; i++) { - assertEquals((byte)0, buffer.array()[i]); - } - - final List out = Lists.newArrayList(); - netconfEXIToMessageDecoder.decode(null, buffer, out); - - XMLUnit.compareXML(msg.getDocument(), ((NetconfMessage) out.get(0)).getDocument()); - } -} \ No newline at end of file