From fcd38bb036c5dd44b3111cc98fdc4ed1093e01ce Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Wed, 25 Apr 2018 11:20:09 +0200 Subject: [PATCH] Move TestSessionNegotiator class to separate file Change-Id: I20ba4048cc65c40b0b1247e3412abb5c5cb6caed Signed-off-by: Marek Gradzki --- .../AbstractNetconfSessionNegotiatorTest.java | 30 ------------- .../netconf/nettyutil/Netconf539Test.java | 29 ------------- .../nettyutil/TestSessionNegotiator.java | 43 +++++++++++++++++++ 3 files changed, 43 insertions(+), 59 deletions(-) create mode 100644 netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestSessionNegotiator.java diff --git a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java index a2e628366c..0e0458dc7d 100644 --- a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java +++ b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/AbstractNetconfSessionNegotiatorTest.java @@ -22,14 +22,12 @@ import static org.opendaylight.netconf.nettyutil.AbstractChannelInitializer.NETC import com.google.common.base.Optional; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import io.netty.channel.Channel; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.ChannelOutboundHandler; import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.handler.ssl.SslHandler; import io.netty.util.HashedWheelTimer; -import io.netty.util.Timer; import io.netty.util.concurrent.Future; import io.netty.util.concurrent.Promise; import java.util.ArrayList; @@ -41,7 +39,6 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.opendaylight.netconf.api.NetconfDocumentedException; import org.opendaylight.netconf.api.NetconfSessionListener; import org.opendaylight.netconf.api.NetconfSessionPreferences; import org.opendaylight.netconf.api.messages.NetconfHelloMessage; @@ -165,31 +162,4 @@ public class AbstractNetconfSessionNegotiatorTest { channel.pipeline().fireExceptionCaught(cause); verify(promise).setFailure(cause); } - - private static class TestSessionNegotiator extends - AbstractNetconfSessionNegotiator> { - - - TestSessionNegotiator(final NetconfSessionPreferences sessionPreferences, - final Promise promise, final Channel channel, - final Timer timer, - final NetconfSessionListener sessionListener, - final long connectionTimeoutMillis) { - super(sessionPreferences, promise, channel, timer, sessionListener, connectionTimeoutMillis); - } - - @Override - protected TestingNetconfSession getSession(final NetconfSessionListener sessionListener, final Channel channel, - final NetconfHelloMessage message) throws NetconfDocumentedException { - return new TestingNetconfSession(sessionListener, channel, 0L); - } - - @Override - protected void handleMessage(final NetconfHelloMessage netconfHelloMessage) throws Exception { - - } - } - - } diff --git a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/Netconf539Test.java b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/Netconf539Test.java index 53fe8e6cda..8f746ac632 100644 --- a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/Netconf539Test.java +++ b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/Netconf539Test.java @@ -14,11 +14,9 @@ import static org.opendaylight.netconf.nettyutil.AbstractChannelInitializer.NETC import static org.opendaylight.netconf.nettyutil.AbstractChannelInitializer.NETCONF_MESSAGE_FRAME_ENCODER; import com.google.common.base.Optional; -import io.netty.channel.Channel; import io.netty.channel.ChannelInboundHandlerAdapter; import io.netty.channel.embedded.EmbeddedChannel; import io.netty.util.HashedWheelTimer; -import io.netty.util.Timer; import io.netty.util.concurrent.Promise; import java.util.Collections; import org.junit.Assert; @@ -26,7 +24,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.netconf.api.NetconfDocumentedException; import org.opendaylight.netconf.api.NetconfSessionListener; import org.opendaylight.netconf.api.NetconfSessionPreferences; import org.opendaylight.netconf.api.messages.NetconfHelloMessage; @@ -90,30 +87,4 @@ public class Netconf539Test { Assert.assertTrue("ChunkedFramingMechanismEncoder was not installed in the Netconf pipeline", channel.pipeline().get(NETCONF_MESSAGE_FRAME_ENCODER) instanceof ChunkedFramingMechanismEncoder); } - - private static class TestSessionNegotiator extends - AbstractNetconfSessionNegotiator> { - - - TestSessionNegotiator(final NetconfSessionPreferences sessionPreferences, - final Promise promise, final Channel channel, - final Timer timer, - final NetconfSessionListener sessionListener, - final long connectionTimeoutMillis) { - super(sessionPreferences, promise, channel, timer, sessionListener, connectionTimeoutMillis); - } - - @Override - protected TestingNetconfSession getSession(final NetconfSessionListener sessionListener, final Channel channel, - final NetconfHelloMessage message) - throws NetconfDocumentedException { - return new TestingNetconfSession(sessionListener, channel, 0L); - } - - @Override - protected void handleMessage(final NetconfHelloMessage netconfHelloMessage) throws Exception { - - } - } } \ No newline at end of file diff --git a/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestSessionNegotiator.java b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestSessionNegotiator.java new file mode 100644 index 0000000000..d5e895515b --- /dev/null +++ b/netconf/netconf-netty-util/src/test/java/org/opendaylight/netconf/nettyutil/TestSessionNegotiator.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * 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.Timer; +import io.netty.util.concurrent.Promise; +import org.opendaylight.netconf.api.NetconfDocumentedException; +import org.opendaylight.netconf.api.NetconfSessionListener; +import org.opendaylight.netconf.api.NetconfSessionPreferences; +import org.opendaylight.netconf.api.messages.NetconfHelloMessage; + +final class TestSessionNegotiator extends + AbstractNetconfSessionNegotiator> { + + + TestSessionNegotiator(final NetconfSessionPreferences sessionPreferences, + final Promise promise, final Channel channel, + final Timer timer, + final NetconfSessionListener sessionListener, + final long connectionTimeoutMillis) { + super(sessionPreferences, promise, channel, timer, sessionListener, connectionTimeoutMillis); + } + + @Override + protected TestingNetconfSession getSession(final NetconfSessionListener sessionListener, final Channel channel, + final NetconfHelloMessage message) + throws NetconfDocumentedException { + return new TestingNetconfSession(sessionListener, channel, 0L); + } + + @Override + protected void handleMessage(final NetconfHelloMessage netconfHelloMessage) throws Exception { + + } +} \ No newline at end of file -- 2.36.6