Move unit tests to netconf.ssh package 15/104315/4
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Feb 2023 16:44:34 +0000 (17:44 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 8 Feb 2023 18:00:00 +0000 (19:00 +0100)
UTs should be co-located with the classes they are testing, clean that
up.

Change-Id: I59babf5ad47427a2bdb3e9145c2f0284d59a976c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoClient.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoClient.java with 95% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoClientHandler.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoClientHandler.java with 81% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServer.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoServer.java with 98% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServerHandler.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoServerHandler.java with 87% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyClientHandler.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyClientHandler.java with 97% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServer.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyServer.java with 98% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServerHandler.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyServerHandler.java with 79% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHServerTest.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/authentication/SSHServerTest.java with 95% similarity]
netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHTest.java [moved from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/SSHTest.java with 95% similarity]

similarity index 95%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoClient.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoClient.java
index 359f9dfbdc48543f858fdfcff0531a8822c43146..25d855ae5e54e18b0eaea850d5c61b01b4dd6c4e 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.netty;
+package org.opendaylight.netconf.ssh;
 
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.ChannelFuture;
@@ -32,7 +32,7 @@ public class EchoClient extends Thread {
     public EchoClient(final ChannelHandler clientHandler) {
         channelInitializer = new ChannelInitializer<>() {
             @Override
-            public void initChannel(final LocalChannel ch) throws Exception {
+            public void initChannel(final LocalChannel ch) {
                 ch.pipeline().addLast(clientHandler);
             }
         };
similarity index 81%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoClientHandler.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoClientHandler.java
index 8f990380a331abdb24a58d9b7d55774745392cb4..b9ce2e52bab90759840c904da68918e016386230 100644 (file)
@@ -5,8 +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.netty;
+package org.opendaylight.netconf.ssh;
 
 import static com.google.common.base.Preconditions.checkState;
 import static java.nio.charset.StandardCharsets.UTF_8;
@@ -26,20 +25,18 @@ import org.slf4j.LoggerFactory;
  * the server.
  */
 public class EchoClientHandler extends ChannelInboundHandlerAdapter implements ChannelFutureListener {
-    private static final Logger LOG = LoggerFactory.getLogger(EchoClientHandler.class);
-
-    private ChannelHandlerContext context;
-    private final StringBuilder fromServer = new StringBuilder();
-
     public enum State {
         CONNECTING, CONNECTED, FAILED_TO_CONNECT, CONNECTION_CLOSED
     }
 
+    private static final Logger LOG = LoggerFactory.getLogger(EchoClientHandler.class);
 
+    private final StringBuilder fromServer = new StringBuilder();
+    private ChannelHandlerContext context;
     private State state = State.CONNECTING;
 
     @Override
-    public synchronized void channelActive(ChannelHandlerContext ctx) {
+    public synchronized void channelActive(final ChannelHandlerContext ctx) {
         checkState(context == null);
         LOG.info("channelActive");
         context = ctx;
@@ -47,12 +44,12 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
     }
 
     @Override
-    public synchronized void channelInactive(ChannelHandlerContext ctx) throws Exception {
+    public synchronized void channelInactive(final ChannelHandlerContext ctx) throws Exception {
         state = State.CONNECTION_CLOSED;
     }
 
     @Override
-    public synchronized void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+    public synchronized void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
         ByteBuf bb = (ByteBuf) msg;
         String string = bb.toString(UTF_8);
         fromServer.append(string);
@@ -61,7 +58,7 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
     }
 
     @Override
-    public synchronized void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+    public synchronized void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
         // Close the connection when an exception is raised.
         LOG.warn("Unexpected exception from downstream.", cause);
         checkState(context.equals(ctx));
@@ -69,7 +66,7 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
         context = null;
     }
 
-    public synchronized void write(String message) {
+    public synchronized void write(final String message) {
         ByteBuf byteBuf = Unpooled.copiedBuffer(message.getBytes());
         context.writeAndFlush(byteBuf);
     }
@@ -83,7 +80,7 @@ public class EchoClientHandler extends ChannelInboundHandlerAdapter implements C
     }
 
     @Override
-    public synchronized void operationComplete(ChannelFuture future) throws Exception {
+    public synchronized void operationComplete(final ChannelFuture future) throws Exception {
         checkState(state == State.CONNECTING);
         if (future.isSuccess()) {
             LOG.trace("Successfully connected, state will be switched in channelActive");
similarity index 98%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoServer.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServer.java
index 18b83b51936f4a5dd589e232dad274545641a9e6..6013f77ec46a2e752467781b42d74907fd9a75e9 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.netty;
+package org.opendaylight.netconf.ssh;
 
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.ChannelFuture;
@@ -44,7 +44,7 @@ public class EchoServer implements Runnable {
                     .handler(new LoggingHandler(LogLevel.INFO))
                     .childHandler(new ChannelInitializer<LocalChannel>() {
                         @Override
-                        public void initChannel(final LocalChannel ch) throws Exception {
+                        public void initChannel(final LocalChannel ch) {
                             ch.pipeline().addLast(new EchoServerHandler());
                         }
                     });
similarity index 87%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/EchoServerHandler.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/EchoServerHandler.java
index 632d207ea7e76a61438027089432be8503a90cb6..c5240e494341ec34ca2db4da5525b992377c5245 100644 (file)
@@ -5,8 +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.netty;
+package org.opendaylight.netconf.ssh;
 
 import com.google.common.base.Splitter;
 import io.netty.buffer.ByteBuf;
@@ -28,14 +27,14 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
     private final Splitter splitter = Splitter.onPattern("\r?\n");
 
     @Override
-    public void channelActive(ChannelHandlerContext ctx) throws Exception {
+    public void channelActive(final ChannelHandlerContext ctx) throws Exception {
         LOG.debug("sleep start");
         Thread.sleep(1000);
         LOG.debug("sleep done");
     }
 
     @Override
-    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
+    public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
         ByteBuf byteBuf = (ByteBuf) msg;
         String message = byteBuf.toString(StandardCharsets.UTF_8);
         LOG.info("writing back '{}'", message);
@@ -55,7 +54,7 @@ public class EchoServerHandler extends ChannelInboundHandlerAdapter {
     }
 
     @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
+    public void channelReadComplete(final ChannelHandlerContext ctx) {
         LOG.debug("flushing");
         ctx.flush();
     }
similarity index 97%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyClientHandler.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyClientHandler.java
index dd1daedaa66c328a6db922f0a6a54423ffdde88e..abfa7b89858964a14515d3536aee58a23632a431 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.netty;
+package org.opendaylight.netconf.ssh;
 
 import io.netty.buffer.ByteBuf;
 import io.netty.channel.ChannelHandlerContext;
similarity index 98%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyServer.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServer.java
index 01a1261849b09299db03d68d7f3c278f552b48f2..50bb8b29ee7b5ce110b3f019d7bd18b12244bb67 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.netty;
+package org.opendaylight.netconf.ssh;
 
 import io.netty.bootstrap.ServerBootstrap;
 import io.netty.channel.ChannelFuture;
similarity index 79%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/ProxyServerHandler.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/ProxyServerHandler.java
index c70efcdb34eea40e787f9d3e9e5b5c19776aeed2..1b8995d54fa9c1f36204fe689bc35ff5b353fe00 100644 (file)
@@ -5,8 +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.netty;
+package org.opendaylight.netconf.ssh;
 
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.Unpooled;
@@ -29,18 +28,18 @@ public class ProxyServerHandler extends ChannelInboundHandlerAdapter {
 
     private Channel clientChannel;
 
-    public ProxyServerHandler(EventLoopGroup bossGroup, LocalAddress localAddress) {
+    public ProxyServerHandler(final EventLoopGroup bossGroup, final LocalAddress localAddress) {
         clientBootstrap = new Bootstrap();
         clientBootstrap.group(bossGroup).channel(LocalChannel.class);
         this.localAddress = localAddress;
     }
 
     @Override
-    public void channelActive(ChannelHandlerContext remoteCtx) {
+    public void channelActive(final ChannelHandlerContext remoteCtx) {
         final ProxyClientHandler clientHandler = new ProxyClientHandler(remoteCtx);
         clientBootstrap.handler(new ChannelInitializer<LocalChannel>() {
             @Override
-            public void initChannel(LocalChannel ch) throws Exception {
+            public void initChannel(final LocalChannel ch) {
                 ch.pipeline().addLast(clientHandler);
             }
         });
@@ -50,25 +49,25 @@ public class ProxyServerHandler extends ChannelInboundHandlerAdapter {
     }
 
     @Override
-    public void channelInactive(ChannelHandlerContext ctx) {
+    public void channelInactive(final ChannelHandlerContext ctx) {
         LOG.info("channelInactive - closing client connection");
         clientChannel.close();
     }
 
     @Override
-    public void channelRead(ChannelHandlerContext ctx, final Object msg) {
+    public void channelRead(final ChannelHandlerContext ctx, final Object msg) {
         LOG.debug("Writing to client {}", msg);
         clientChannel.write(msg);
     }
 
     @Override
-    public void channelReadComplete(ChannelHandlerContext ctx) {
+    public void channelReadComplete(final ChannelHandlerContext ctx) {
         LOG.debug("flushing");
         clientChannel.flush();
     }
 
     @Override
-    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+    public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) {
         // Close the connection when an exception is raised.
         LOG.warn("Unexpected exception from downstream.", cause);
         ctx.close();
similarity index 95%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/authentication/SSHServerTest.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHServerTest.java
index e040304b32a9853f0fc2c415c18eeb05d789664b..ff085de5c519b8030ed471c3ee66218480db0bbf 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.ssh.authentication;
+package org.opendaylight.netconf.ssh;
 
 import io.netty.channel.EventLoopGroup;
 import io.netty.channel.nio.NioEventLoopGroup;
@@ -23,8 +23,6 @@ import org.opendaylight.netconf.shaded.sshd.client.future.AuthFuture;
 import org.opendaylight.netconf.shaded.sshd.client.future.ConnectFuture;
 import org.opendaylight.netconf.shaded.sshd.client.session.ClientSession;
 import org.opendaylight.netconf.shaded.sshd.common.util.security.SecurityUtils;
-import org.opendaylight.netconf.ssh.SshProxyServer;
-import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
 import org.opendaylight.netconf.util.NetconfConfiguration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
similarity index 95%
rename from netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/netty/SSHTest.java
rename to netconf/mdsal-netconf-ssh/src/test/java/org/opendaylight/netconf/ssh/SSHTest.java
index eb757eb01e5b8dd9e9eb0dc099c0181102f39180..5673c592db6b78e72ba664572e21fb66061388cd 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.netty;
+package org.opendaylight.netconf.ssh;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
@@ -28,12 +28,10 @@ import java.util.concurrent.TimeUnit;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
-import org.opendaylight.netconf.netty.EchoClientHandler.State;
 import org.opendaylight.netconf.nettyutil.handler.ssh.authentication.LoginPasswordHandler;
 import org.opendaylight.netconf.nettyutil.handler.ssh.client.AsyncSshHandler;
 import org.opendaylight.netconf.shaded.sshd.common.util.security.SecurityUtils;
-import org.opendaylight.netconf.ssh.SshProxyServer;
-import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder;
+import org.opendaylight.netconf.ssh.EchoClientHandler.State;
 import org.opendaylight.netconf.util.NetconfConfiguration;
 
 public class SSHTest {