X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnetty%2FEchoClient.java;h=b768e2b1d1ce08d8cef9585c538837157405bdc6;hp=5d0c71aa62e0e05d57768c320367b690a50395a3;hb=17d82f582a6bc13c78be3b19954ff8c021180e93;hpb=999c87c5aa34530297757b653ffb0dea80bf4ff2 diff --git a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/EchoClient.java b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/EchoClient.java index 5d0c71aa62..b768e2b1d1 100644 --- a/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/EchoClient.java +++ b/opendaylight/netconf/netconf-ssh/src/test/java/org/opendaylight/controller/netconf/netty/EchoClient.java @@ -25,29 +25,36 @@ import org.slf4j.LoggerFactory; * traffic between the echo client and server by sending the first message to * the server. */ -public class EchoClient implements Runnable { +public class EchoClient extends Thread { private static final Logger logger = LoggerFactory.getLogger(EchoClient.class); - private final ChannelHandler clientHandler; + private final ChannelInitializer channelInitializer; - public EchoClient(ChannelHandler clientHandler) { - this.clientHandler = clientHandler; + + public EchoClient(final ChannelHandler clientHandler) { + channelInitializer = new ChannelInitializer() { + @Override + public void initChannel(LocalChannel ch) throws Exception { + ch.pipeline().addLast(clientHandler); + } + }; + } + + public EchoClient(ChannelInitializer channelInitializer) { + this.channelInitializer = channelInitializer; } + @Override public void run() { // Configure the client. EventLoopGroup group = new NioEventLoopGroup(); try { Bootstrap b = new Bootstrap(); + b.group(group) .channel(LocalChannel.class) - .handler(new ChannelInitializer() { - @Override - public void initChannel(LocalChannel ch) throws Exception { - ch.pipeline().addLast(clientHandler); - } - }); + .handler(channelInitializer); // Start the client. LocalAddress localAddress = new LocalAddress("foo");