Rename NetconfXMLToHelloMessageDecoder 89/112989/7
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 5 Aug 2024 22:53:51 +0000 (00:53 +0200)
committerRobert Varga <nite@hq.sk>
Tue, 6 Aug 2024 15:19:32 +0000 (15:19 +0000)
A better name is HelloXMLMessageDecoder, being shorter overall while
retaining all of 'HelloMessage', 'XML' and 'MessageDecoder' implications.

JIRA: NETCONF-1191
Change-Id: I10eb5ade1fc2ccf7cc58cedc42e174a7198e6359
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/NetconfSessionNegotiator.java
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/HelloXMLMessageDecoder.java [moved from netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoder.java with 97% similarity]
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/HelloXMLMessageDecoderTest.java [moved from netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfXMLToHelloMessageDecoderTest.java with 90% similarity]
netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/handler/NetconfMessageFactoryTest.java
protocol/netconf-client/src/test/java/org/opendaylight/netconf/client/NetconfClientSessionNegotiatorTest.java

index 3b7b4ec4d00a2571ac6686283dd35cda31dbe7d4..896593234801bbe7e8a6e34f5ab47668b2326537 100644 (file)
@@ -16,8 +16,8 @@ import org.opendaylight.netconf.codec.FrameDecoder;
 import org.opendaylight.netconf.codec.FrameEncoder;
 import org.opendaylight.netconf.codec.MessageDecoder;
 import org.opendaylight.netconf.codec.MessageEncoder;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfHelloMessageToXMLEncoder;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 
 public abstract class AbstractChannelInitializer<S extends NetconfSession> {
     public static final String NETCONF_SESSION_NEGOTIATOR = "negotiator";
@@ -40,7 +40,7 @@ public abstract class AbstractChannelInitializer<S extends NetconfSession> {
     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(MessageDecoder.HANDLER_NAME, new NetconfXMLToHelloMessageDecoder());
+        ch.pipeline().addLast(MessageDecoder.HANDLER_NAME, new HelloXMLMessageDecoder());
     }
 
     /**
index 6efbf7160ecf7134e37c349706c3d841e6113286..da9d60f3f2084865c688ebedd030e7e4423c4545 100644 (file)
@@ -41,8 +41,8 @@ import org.opendaylight.netconf.codec.MessageDecoder;
 import org.opendaylight.netconf.codec.MessageEncoder;
 import org.opendaylight.netconf.codec.XMLMessageDecoder;
 import org.opendaylight.netconf.common.NetconfTimer;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfMessageToXMLEncoder;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -287,7 +287,7 @@ public abstract class NetconfSessionNegotiator<S extends AbstractNetconfSession<
     protected final void replaceHelloMessageInboundHandler(final S session) {
         final var helloMessageHandler = replaceChannelHandler(channel, MessageDecoder.HANDLER_NAME,
             new XMLMessageDecoder());
-        if (!(helloMessageHandler instanceof NetconfXMLToHelloMessageDecoder helloDecorder)) {
+        if (!(helloMessageHandler instanceof HelloXMLMessageDecoder helloDecorder)) {
             throw new IllegalStateException(
                 "Pipeline handlers misplaced on session: " + session + ", pipeline: " + channel.pipeline());
         }
@@ -38,8 +38,8 @@ import org.xml.sax.SAXException;
  * Netconf messages after hello should be processed once the negotiation succeeded.
  *
  */
-public final class NetconfXMLToHelloMessageDecoder extends MessageDecoder {
-    private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToHelloMessageDecoder.class);
+public final class HelloXMLMessageDecoder extends MessageDecoder {
+    private static final Logger LOG = LoggerFactory.getLogger(HelloXMLMessageDecoder.class);
 
     private static final List<byte[]> POSSIBLE_ENDS = List.of(
             new byte[] { ']', '\n' },
index 573ed798d75dba6de5a231ca3c9a7fadf1b370fd..136670cfec58ad1bcba16893a1d518a2e2d7d18e 100644 (file)
@@ -55,7 +55,7 @@ import org.opendaylight.netconf.codec.FrameEncoder;
 import org.opendaylight.netconf.codec.MessageDecoder;
 import org.opendaylight.netconf.codec.MessageEncoder;
 import org.opendaylight.netconf.common.NetconfTimer;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
 
 @ExtendWith(MockitoExtension.class)
 class AbstractNetconfSessionNegotiatorTest {
@@ -74,7 +74,7 @@ class AbstractNetconfSessionNegotiatorTest {
     private final HelloMessage hello = HelloMessage.createClientHello(Set.of(), Optional.empty());
     private final HelloMessage helloBase11 =
         HelloMessage.createClientHello(Set.of(CapabilityURN.BASE_1_1), Optional.empty());
-    private final NetconfXMLToHelloMessageDecoder xmlToHello  = new NetconfXMLToHelloMessageDecoder();
+    private final HelloXMLMessageDecoder xmlToHello  = new HelloXMLMessageDecoder();
     private final EmbeddedChannel channel = new EmbeddedChannel();
 
     @BeforeEach
index f9b5020a5ddf5c2479381e06aa3efb35c9322f3e..19ac8525a3443e2b6a693c6b76ac1eab26e19565 100644 (file)
@@ -32,7 +32,7 @@ import org.opendaylight.netconf.codec.FrameEncoder;
 import org.opendaylight.netconf.codec.MessageDecoder;
 import org.opendaylight.netconf.codec.MessageEncoder;
 import org.opendaylight.netconf.common.impl.DefaultNetconfTimer;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
 import org.opendaylight.netconf.test.util.XmlFileLoader;
 
 @ExtendWith(MockitoExtension.class)
@@ -49,7 +49,7 @@ class Netconf539Test {
     void setUp() {
         channel.pipeline()
             .addLast(MessageEncoder.HANDLER_NAME, new ChannelInboundHandlerAdapter())
-            .addLast(MessageDecoder.HANDLER_NAME, new NetconfXMLToHelloMessageDecoder())
+            .addLast(MessageDecoder.HANDLER_NAME, new HelloXMLMessageDecoder())
             .addLast(FrameEncoder.HANDLER_NAME, new EOMFrameEncoder())
             .addLast(FrameDecoder.HANDLER_NAME, new EOMFrameDecoder());
         negotiator = new TestSessionNegotiator(
@@ -24,15 +24,14 @@ import org.junit.jupiter.api.Test;
 import org.opendaylight.netconf.api.messages.HelloMessage;
 import org.opendaylight.netconf.api.xml.XmlUtil;
 
-class NetconfXMLToHelloMessageDecoderTest {
-
+class HelloXMLMessageDecoderTest {
     @Test
     void testDecodeWithHeader() throws Exception {
         final ByteBuf src = Unpooled.wrappedBuffer(String.format("%s\n%s",
                 "[tomas;10.0.0.0:10000;tcp;client;]",
                 "<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>").getBytes());
         final List<Object> out = new ArrayList<>();
-        new NetconfXMLToHelloMessageDecoder().decode(null, src, out);
+        new HelloXMLMessageDecoder().decode(null, src, out);
 
         assertEquals(1, out.size());
         final HelloMessage hello = assertInstanceOf(HelloMessage.class, out.get(0));
@@ -48,7 +47,7 @@ class NetconfXMLToHelloMessageDecoderTest {
         final ByteBuf src =
                 Unpooled.wrappedBuffer("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
         final List<Object> out = new ArrayList<>();
-        new NetconfXMLToHelloMessageDecoder().decode(null, src, out);
+        new HelloXMLMessageDecoder().decode(null, src, out);
 
         assertEquals(1, out.size());
         final HelloMessage hello = assertInstanceOf(HelloMessage.class, out.get(0));
@@ -64,7 +63,7 @@ class NetconfXMLToHelloMessageDecoderTest {
         final ByteBuf src =
                 Unpooled.wrappedBuffer("<hello xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
         final List<Object> out = new ArrayList<>();
-        final NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
+        final HelloXMLMessageDecoder decoder = new HelloXMLMessageDecoder();
         decoder.decode(null, src, out);
         decoder.decode(null, msg1, out);
         decoder.decode(null, msg2, out);
@@ -79,7 +78,7 @@ class NetconfXMLToHelloMessageDecoderTest {
         final ByteBuf msg1 =
                 Unpooled.wrappedBuffer("<rpc-reply xmlns=\"urn:ietf:params:xml:ns:netconf:base:1.0\"/>".getBytes());
         final List<Object> out = new ArrayList<>();
-        NetconfXMLToHelloMessageDecoder decoder = new NetconfXMLToHelloMessageDecoder();
+        HelloXMLMessageDecoder decoder = new HelloXMLMessageDecoder();
         assertThrows(IllegalStateException.class, () -> decoder.decode(null, msg1, out));
     }
 }
index 4e28b4da0a6a972b1134c0ad8dd6bd2264aa2fa8..984fe7e2a8364df0e6a9a608ffd87f5031039fc6 100644 (file)
@@ -19,7 +19,7 @@ import org.junit.jupiter.api.Test;
 class NetconfMessageFactoryTest {
     @Test
     void testAuth() throws Exception {
-        NetconfXMLToHelloMessageDecoder parser = new NetconfXMLToHelloMessageDecoder();
+        HelloXMLMessageDecoder parser = new HelloXMLMessageDecoder();
         File authHelloFile = new File(getClass().getResource("/netconfMessages/client_hello_with_auth.xml").getFile());
 
         final List<Object> out = new ArrayList<>();
index 49028bf731aea12d0e5afc931b14184d988c7935..d03f3ad9a2ffa41534602f358d50be0dc9b96d1f 100644 (file)
@@ -43,8 +43,8 @@ import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.codec.ChunkedFrameEncoder;
 import org.opendaylight.netconf.codec.XMLMessageDecoder;
 import org.opendaylight.netconf.common.impl.DefaultNetconfTimer;
+import org.opendaylight.netconf.nettyutil.handler.HelloXMLMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.NetconfEXIToMessageDecoder;
-import org.opendaylight.netconf.nettyutil.handler.NetconfXMLToHelloMessageDecoder;
 import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
 import org.opendaylight.netconf.nettyutil.handler.exi.NetconfStartExiMessageProvider;
 import org.opendaylight.netconf.test.util.XmlFileLoader;
@@ -103,7 +103,7 @@ class NetconfClientSessionNegotiatorTest {
         doReturn(pipeline).when(pipeline).addLast(anyString(), any(ChannelHandler.class));
         doReturn(handler).when(pipeline).replace(anyString(), anyString(), any(ChunkedFrameEncoder.class));
 
-        NetconfXMLToHelloMessageDecoder messageDecoder = new NetconfXMLToHelloMessageDecoder();
+        HelloXMLMessageDecoder messageDecoder = new HelloXMLMessageDecoder();
         doReturn(messageDecoder).when(pipeline).replace(anyString(), anyString(), any(XMLMessageDecoder.class));
         doReturn(pipeline).when(pipeline).replace(any(ChannelHandler.class), anyString(),
             any(NetconfClientSession.class));