Move FramingMechanism 28/105728/5
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 28 Apr 2023 09:14:56 +0000 (11:14 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 28 Apr 2023 11:00:02 +0000 (13:00 +0200)
This is well-known construct defined in RFC6241 at messages layer.
Move the enumeration into netconf.api.messages.

JIRA: NETCONF-945
Change-Id: Ifab96b8bb7c72307062f31b6ad02c0dfca05c6cf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractChannelInitializer.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiator.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/FramingMechanismHandlerFactory.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/MessageParts.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/Netconf539Test.java
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/FramingMechanismHandlerFactoryTest.java
protocol/netconf-api/src/main/java/org/opendaylight/netconf/api/messages/FramingMechanism.java [moved from protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/FramingMechanism.java with 96% similarity]
protocol/netconf-server/src/test/java/org/opendaylight/netconf/server/MessageParserTest.java

index c967e8f317a03667634f65d3854e2228bea0e882..1a7df7b715824553268a693478277c03f92da3b3 100644 (file)
@@ -5,27 +5,25 @@
  * 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.nettyutil;
 
 import io.netty.channel.Channel;
 import io.netty.util.concurrent.Promise;
 import org.opendaylight.netconf.api.NetconfSession;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfHelloMessageToXMLEncoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
 
 public abstract class AbstractChannelInitializer<S extends NetconfSession> {
-
     public static final String NETCONF_MESSAGE_DECODER = "netconfMessageDecoder";
     public static final String NETCONF_MESSAGE_AGGREGATOR = "aggregator";
     public static final String NETCONF_MESSAGE_ENCODER = "netconfMessageEncoder";
     public static final String NETCONF_MESSAGE_FRAME_ENCODER = "frameEncoder";
     public static final String NETCONF_SESSION_NEGOTIATOR = "negotiator";
 
-    public void initialize(Channel ch, Promise<S> promise) {
+    public void initialize(final Channel ch, final Promise<S> promise) {
         ch.pipeline().addLast(NETCONF_MESSAGE_AGGREGATOR, new NetconfEOMAggregator());
         initializeMessageDecoder(ch);
         ch.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER,
@@ -35,13 +33,13 @@ public abstract class AbstractChannelInitializer<S extends NetconfSession> {
         initializeSessionNegotiator(ch, promise);
     }
 
-    protected void initializeMessageEncoder(Channel ch) {
+    protected void initializeMessageEncoder(final Channel ch) {
         // Special encoding handler for hello message to include additional header if available,
         // it is thrown away after successful negotiation
         ch.pipeline().addLast(NETCONF_MESSAGE_ENCODER, new NetconfHelloMessageToXMLEncoder());
     }
 
-    protected void initializeMessageDecoder(Channel ch) {
+    protected void initializeMessageDecoder(final Channel ch) {
         // Special decoding handler for hello message to parse additional header if available,
         // it is thrown away after successful negotiation
         ch.pipeline().addLast(NETCONF_MESSAGE_DECODER, new NetconfXMLToHelloMessageDecoder());
@@ -52,5 +50,4 @@ public abstract class AbstractChannelInitializer<S extends NetconfSession> {
      * identified by {@link AbstractChannelInitializer#NETCONF_MESSAGE_DECODER}, (or any other custom decoder processor)
      */
     protected abstract void initializeSessionNegotiator(Channel ch, Promise<S> promise);
-
 }
index 72406263d96dec14133c36cf031c5e5f0b4e8cc0..a67f7941ad7ee8633408280cdd81ab436f086441 100644 (file)
@@ -30,6 +30,7 @@ import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.netconf.api.NetconfDocumentedException;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.NetconfSessionListener;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 import org.opendaylight.netconf.api.messages.HelloMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory;
@@ -37,7 +38,6 @@ import org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
index 5e16c00f2360cd9e7dc59202fb0231eab8551f54..9294853d956065a4a1bd307df0cc482c3bfd2e63 100644 (file)
@@ -9,7 +9,7 @@ package org.opendaylight.netconf.nettyutil.handler;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.handler.codec.MessageToByteEncoder;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
index 6802507b2caa1858b5bba7fe32cb2f72a6cd85cf..fc145dc6c3be4a0b8a22d714e8bf7790ee3a95b9 100644 (file)
@@ -12,7 +12,7 @@ import java.nio.charset.CharacterCodingException;
 import java.nio.charset.CharsetEncoder;
 import java.nio.charset.CodingErrorAction;
 import java.nio.charset.StandardCharsets;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 
 /**
  * netconf message part constants as bytes.
index 59898303b0bc28914e27faf8bd449ac7418369d7..2ce28966ef88672b63c7c2c4afc6bbfb6bccf2d3 100644 (file)
@@ -48,6 +48,7 @@ import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.netconf.api.NetconfSessionListener;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 import org.opendaylight.netconf.api.messages.HelloMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.api.xml.XmlUtil;
@@ -57,7 +58,6 @@ import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory
 import org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
 
 @RunWith(MockitoJUnitRunner.StrictStubs.class)
 public class AbstractNetconfSessionNegotiatorTest {
index b2b3e0fbb64b9de63be924a2cea43fc6e17a7829..159bd9aace698ba035175ec5137a3d9af073795c 100644 (file)
@@ -24,6 +24,7 @@ import org.junit.runner.RunWith;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.netconf.api.NetconfSessionListener;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 import org.opendaylight.netconf.api.messages.HelloMessage;
 import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
 import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
@@ -31,7 +32,6 @@ import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory
 import org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
 import org.w3c.dom.Document;
 
index 0655e6f88a384c38738ad42a759aff6fe17bad22..8e88544e275f771f315597d8b60d13c3d7aaca6b 100644 (file)
@@ -5,16 +5,14 @@
  * 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.nettyutil.handler;
 
 import org.hamcrest.CoreMatchers;
 import org.hamcrest.MatcherAssert;
 import org.junit.Test;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 
 public class FramingMechanismHandlerFactoryTest {
-
     @Test
     public void testCreate() throws Exception {
         MatcherAssert.assertThat(FramingMechanismHandlerFactory
similarity index 96%
rename from protocol/netconf-util/src/main/java/org/opendaylight/netconf/util/messages/FramingMechanism.java
rename to protocol/netconf-api/src/main/java/org/opendaylight/netconf/api/messages/FramingMechanism.java
index 3d5680cbda56ddf126c2057bf7bb2dc7262a1d54..2d74c31debd1a8686830a70e88cfc7291cfb6b7a 100644 (file)
@@ -5,7 +5,7 @@
  * 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.util.messages;
+package org.opendaylight.netconf.api.messages;
 
 import org.eclipse.jdt.annotation.NonNullByDefault;
 
index 87f0be168b71e520d734ecfb146dcb44ef1d2974..6aaf1909044aca990894ae2ccbfa4586b999f134 100644 (file)
@@ -22,13 +22,13 @@ import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.netconf.api.NetconfMessage;
+import org.opendaylight.netconf.api.messages.FramingMechanism;
 import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
 import org.opendaylight.netconf.nettyutil.handler.FramingMechanismHandlerFactory;
 import org.opendaylight.netconf.nettyutil.handler.NetconfChunkAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEOMAggregator;
 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToMessageDecoder;
-import org.opendaylight.netconf.util.messages.FramingMechanism;
 import org.opendaylight.netconf.util.test.XmlFileLoader;
 
 public class MessageParserTest {