From: Robert Varga Date: Fri, 29 Jul 2022 15:56:58 +0000 (+0200) Subject: Deprecate DEFAULT_MAXIMUM_CHUNK_SIZE X-Git-Tag: v4.0.1~5 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F19%2F101919%2F3;p=netconf.git Deprecate DEFAULT_MAXIMUM_CHUNK_SIZE This is an artificial global limit. We provide the ability to specify this limit on a per-instance basis and callers should be taking advantage of that instead. Change-Id: I3abbed74c37b4f9a9e820adf0c38fba160a8dc88 Signed-off-by: Robert Varga --- diff --git a/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java b/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java index 88f4f11337..06b76a213d 100644 --- a/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java +++ b/netconf/netconf-impl/src/test/java/org/opendaylight/netconf/impl/MessageParserTest.java @@ -5,15 +5,12 @@ * 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.netconf.impl; import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -35,7 +32,6 @@ import org.opendaylight.netconf.util.messages.FramingMechanism; import org.opendaylight.netconf.util.test.XmlFileLoader; public class MessageParserTest { - private NetconfMessage msg; @Before @@ -48,13 +44,12 @@ public class MessageParserTest { EmbeddedChannel testChunkChannel = new EmbeddedChannel( FramingMechanismHandlerFactory.createHandler(FramingMechanism.CHUNK), new NetconfMessageToXMLEncoder(), - - new NetconfChunkAggregator(), + new NetconfChunkAggregator(ChunkedFramingMechanismEncoder.MAX_CHUNK_SIZE), new NetconfXMLToMessageDecoder()); testChunkChannel.writeOutbound(msg); Queue messages = testChunkChannel.outboundMessages(); - assertFalse(messages.isEmpty()); + assertEquals(1, messages.size()); final NetconfMessageToXMLEncoder enc = new NetconfMessageToXMLEncoder(); final ByteBuf out = Unpooled.buffer(); @@ -83,7 +78,7 @@ public class MessageParserTest { testChunkChannel.writeInbound(recievedOutbound); } - assertTrue(messages.isEmpty()); + assertEquals(0, messages.size()); NetconfMessage receivedMessage = testChunkChannel.readInbound(); assertNotNull(receivedMessage); diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java index 6ee1c8b57c..3566bf4bb1 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java @@ -194,7 +194,7 @@ public abstract class AbstractNetconfSessionNegotiator" + "\n##\n"; - public static final String EXPECTED_MESSAGE = "\n" + " \n" + ""; private static final String CHUNKED_MESSAGE_ONE = "\n#101\n" + EXPECTED_MESSAGE + "\n##\n"; - private static NetconfChunkAggregator agr; - - @BeforeClass - public static void setUp() throws Exception { - agr = new NetconfChunkAggregator(); - } + private final NetconfChunkAggregator agr = new NetconfChunkAggregator(4096); @Test public void testMultipleChunks() throws Exception { - final List output = new ArrayList<>(); - final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE.getBytes(StandardCharsets.UTF_8)); + final var output = new ArrayList<>(); + final var input = Unpooled.copiedBuffer(CHUNKED_MESSAGE.getBytes(StandardCharsets.UTF_8)); agr.decode(null, input, output); assertEquals(1, output.size()); - final ByteBuf chunk = (ByteBuf) output.get(0); + final var chunk = (ByteBuf) output.get(0); assertEquals(EXPECTED_MESSAGE, chunk.toString(StandardCharsets.UTF_8)); } @Test public void testOneChunks() throws Exception { - final List output = new ArrayList<>(); - final ByteBuf input = Unpooled.copiedBuffer(CHUNKED_MESSAGE_ONE.getBytes(StandardCharsets.UTF_8)); + final var output = new ArrayList<>(); + final var input = Unpooled.copiedBuffer(CHUNKED_MESSAGE_ONE.getBytes(StandardCharsets.UTF_8)); agr.decode(null, input, output); assertEquals(1, output.size());