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%2FNetconfXMLToHelloMessageDecoderTest.java;fp=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2FNetconfXMLToHelloMessageDecoderTest.java;h=0000000000000000000000000000000000000000;hb=9ba2b4eca79bcc0e78099b133296801c8d45a6c4;hp=43f31e69d702341cc26d0962fef0663e8f761247;hpb=b2e81149739c87f0ecc2ce7f06448d7a5d3162b8;p=controller.git diff --git a/opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoderTest.java b/opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoderTest.java deleted file mode 100644 index 43f31e69d7..0000000000 --- a/opendaylight/netconf/netconf-netty-util/src/test/java/org/opendaylight/controller/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoderTest.java +++ /dev/null @@ -1,78 +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.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import java.util.List; -import org.hamcrest.CoreMatchers; -import org.junit.Test; -import org.opendaylight.controller.config.util.xml.XmlUtil; -import org.opendaylight.controller.netconf.util.messages.NetconfHelloMessage; - -public class NetconfXMLToHelloMessageDecoderTest { - - @Test - public void testDecodeWithHeader() throws Exception { - final ByteBuf src = Unpooled.wrappedBuffer(String.format("%s\n%s", - "[tomas;10.0.0.0:10000;tcp;client;]", "").getBytes()); - final List out = Lists.newArrayList(); - new NetconfXMLToHelloMessageDecoder().decode(null, src, out); - - assertEquals(1, out.size()); - assertThat(out.get(0), CoreMatchers.instanceOf(NetconfHelloMessage.class)); - final NetconfHelloMessage hello = (NetconfHelloMessage) out.get(0); - assertTrue(hello.getAdditionalHeader().isPresent()); - assertEquals("[tomas;10.0.0.0:10000;tcp;client;]" + System.lineSeparator(), hello.getAdditionalHeader().get().toFormattedString()); - assertThat(XmlUtil.toString(hello.getDocument()), CoreMatchers.containsString("".getBytes()); - final List out = Lists.newArrayList(); - new NetconfXMLToHelloMessageDecoder().decode(null, src, out); - - assertEquals(1, out.size()); - assertThat(out.get(0), CoreMatchers.instanceOf(NetconfHelloMessage.class)); - final NetconfHelloMessage hello = (NetconfHelloMessage) out.get(0); - assertFalse(hello.getAdditionalHeader().isPresent()); - } - - @Test - public void testDecodeCaching() throws Exception { - final ByteBuf msg1 = Unpooled.wrappedBuffer("".getBytes()); - final ByteBuf msg2 = Unpooled.wrappedBuffer("".getBytes()); - final ByteBuf src = Unpooled.wrappedBuffer("".getBytes()); - final List out = Lists.newArrayList(); - final NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder(); - decoder.decode(null, src, out); - decoder.decode(null, msg1, out); - decoder.decode(null, msg2, out); - - assertEquals(1, out.size()); - - assertEquals(2, Iterables.size(decoder.getPostHelloNetconfMessages())); - } - - @Test(expected = IllegalStateException.class) - public void testDecodeNotHelloReceived() throws Exception { - final ByteBuf msg1 = Unpooled.wrappedBuffer("".getBytes()); - final List out = Lists.newArrayList(); - NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder(); - decoder.decode(null, msg1, out); - } -} \ No newline at end of file