Introduce NetconfTimer
[netconf.git] / netconf / netconf-netty-util / src / test / java / org / opendaylight / netconf / nettyutil / AbstractNetconfSessionNegotiatorTest.java
index 0eb90f5841928fdf77d536b7e7fb80aa65431e28..323c6aa056311ad51d62d7663758c381f72e785f 100644 (file)
@@ -32,7 +32,6 @@ import io.netty.channel.ChannelPromise;
 import io.netty.channel.embedded.EmbeddedChannel;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.util.Timeout;
-import io.netty.util.Timer;
 import io.netty.util.TimerTask;
 import io.netty.util.concurrent.Future;
 import io.netty.util.concurrent.Promise;
@@ -47,17 +46,16 @@ import org.junit.runner.RunWith;
 import org.mockito.ArgumentCaptor;
 import org.mockito.Mock;
 import org.mockito.junit.MockitoJUnitRunner;
+import org.opendaylight.netconf.api.CapabilityURN;
 import org.opendaylight.netconf.api.NetconfSessionListener;
-import org.opendaylight.netconf.api.messages.NetconfHelloMessage;
-import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.api.messages.HelloMessage;
 import org.opendaylight.netconf.api.xml.XmlUtil;
+import org.opendaylight.netconf.common.NetconfTimer;
 import org.opendaylight.netconf.nettyutil.handler.ChunkedFramingMechanismEncoder;
 import org.opendaylight.netconf.nettyutil.handler.EOMFramingMechanismEncoder;
-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 {
@@ -68,13 +66,13 @@ public class AbstractNetconfSessionNegotiatorTest {
     @Mock
     private SslHandler sslHandler;
     @Mock
-    private Timer timer;
+    private NetconfTimer timer;
     @Mock
     private Timeout timeout;
     private EmbeddedChannel channel;
     private TestSessionNegotiator negotiator;
-    private NetconfHelloMessage hello;
-    private NetconfHelloMessage helloBase11;
+    private HelloMessage hello;
+    private HelloMessage helloBase11;
     private NetconfXMLToHelloMessageDecoder xmlToHello;
 
     @Before
@@ -84,12 +82,10 @@ public class AbstractNetconfSessionNegotiatorTest {
         channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_ENCODER,
                 new ChannelInboundHandlerAdapter());
         channel.pipeline().addLast(AbstractChannelInitializer.NETCONF_MESSAGE_DECODER, xmlToHello);
-        channel.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER,
-                FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
+        channel.pipeline().addLast(NETCONF_MESSAGE_FRAME_ENCODER, new EOMFramingMechanismEncoder());
         channel.pipeline().addLast(NETCONF_MESSAGE_AGGREGATOR, new NetconfEOMAggregator());
-        hello = NetconfHelloMessage.createClientHello(Set.of(), Optional.empty());
-        helloBase11 = NetconfHelloMessage.createClientHello(
-            Set.of(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1), Optional.empty());
+        hello = HelloMessage.createClientHello(Set.of(), Optional.empty());
+        helloBase11 = HelloMessage.createClientHello(Set.of(CapabilityURN.BASE_1_1), Optional.empty());
         doReturn(promise).when(promise).setFailure(any());
         negotiator = new TestSessionNegotiator(helloBase11, promise, channel, timer, listener, 100L);
     }
@@ -185,7 +181,7 @@ public class AbstractNetconfSessionNegotiatorTest {
         doReturn(timeout).when(timer).newTimeout(any(), eq(100L), eq(TimeUnit.MILLISECONDS));
     }
 
-    private static class CloseDetector extends ChannelOutboundHandlerAdapter {
+    private static final class CloseDetector extends ChannelOutboundHandlerAdapter {
         @Override
         public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) {
             // Override needed so @Skip from superclass is not effective