+
+ @Test
+ public void testNetconfClientSessionNegotiatorGetCached() throws Exception {
+ Promise<NetconfClientSession> promise = mock(Promise.class);
+ doReturn(promise).when(promise).setSuccess(any());
+ NetconfClientSessionListener sessionListener = mock(NetconfClientSessionListener.class);
+ NetconfClientSessionNegotiator negotiator = createNetconfClientSessionNegotiator(promise, null);
+
+ Set<String> set = createCapabilities("/helloMessage3.xml");
+
+ final Set<String> cachedS1 = (Set<String>) negotiator.getSession(sessionListener, channel,
+ createHelloMsg("/helloMessage1.xml")).getServerCapabilities();
+
+ //helloMessage2 and helloMessage3 are the same with different order
+ final Set<String> cachedS2 = (Set<String>) negotiator.getSession(sessionListener, channel,
+ createHelloMsg("/helloMessage2.xml")).getServerCapabilities();
+ final Set<String> cachedS3 = (Set<String>) negotiator.getSession(sessionListener, channel,
+ createHelloMsg("/helloMessage3.xml")).getServerCapabilities();
+
+ assertEquals(cachedS3, set);
+ assertNotEquals(cachedS1, set);
+ assertEquals(cachedS2, set);
+ assertEquals(cachedS3, cachedS2);
+ assertNotEquals(cachedS3, cachedS1);
+ assertNotEquals(cachedS2, cachedS1);
+ assertTrue(cachedS2 == cachedS3);
+ }