Merge "fix failure during connecting device when channelActive happens later than...
[netconf.git] / netconf / netconf-client / src / test / java / org / opendaylight / netconf / client / NetconfClientSessionNegotiatorTest.java
index 874b0a17bacba21355500d063951589d2ba03494..7b84cb0be481ae9ff77e7706a40923774718e704 100644 (file)
@@ -162,6 +162,22 @@ public class NetconfClientSessionNegotiatorTest {
         verify(promise).setSuccess(anyObject());
     }
 
+    @Test
+    public void testNegotiatorWhenChannelActiveHappenAfterHandleMessage() throws Exception {
+        Promise promise = mock(Promise.class);
+        doReturn(false).when(promise).isDone();
+        doReturn(promise).when(promise).setSuccess(anyObject());
+        NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
+        Set<String> caps = Sets.newSet("a", "b");
+        NetconfHelloMessage helloServerMessage = NetconfHelloMessage.createServerHello(caps, 10);
+
+        negotiator.handleMessage(helloServerMessage);
+        negotiator.channelActive(null);
+
+        verify(promise).setSuccess(anyObject());
+    }
+
+
     @Test
     public void testNetconfClientSessionNegotiatorWithEXI() throws Exception {
         Promise<NetconfClientSession> promise = mock(Promise.class);