use of org.opendaylight.netconf.client.NetconfClientSession in project netconf by opendaylight.
the class CallHomeTlsSessionContext method doActivate.
private Promise<NetconfClientSession> doActivate(final Channel ch, final NetconfClientSessionListener listener) {
final Promise<NetconfClientSession> activationPromise = newSessionPromise();
if (activated.compareAndExchange(false, true)) {
return activationPromise.setFailure(new IllegalStateException("Session (channel) already activated."));
}
LOG.info("Activating Netconf channel for {} with {}", getRemoteAddress(), listener);
final NetconfClientSessionNegotiatorFactory negotiatorFactory = new NetconfClientSessionNegotiatorFactory(new HashedWheelTimer(), Optional.empty(), TimeUnit.SECONDS.toMillis(5));
final TlsClientChannelInitializer tlsClientChannelInitializer = new TlsClientChannelInitializer(sslHandlerFactory, negotiatorFactory, listener);
tlsClientChannelInitializer.initialize(ch, activationPromise);
return activationPromise;
}
use of org.opendaylight.netconf.client.NetconfClientSession in project netconf by opendaylight.
the class CallHomeMountDispatcherTest method noSessionIsCreatedWithoutAContextAvailableForAGivenAddress.
@Test
public void noSessionIsCreatedWithoutAContextAvailableForAGivenAddress() {
// given
final InetSocketAddress someAddress = InetSocketAddress.createUnresolved("1.2.3.4", 123);
final NetconfClientConfiguration someCfg = someConfiguration(someAddress);
// when
final Future<NetconfClientSession> future = instance.createClient(someCfg);
// then
assertFalse(future.isSuccess());
}
use of org.opendaylight.netconf.client.NetconfClientSession in project netconf by opendaylight.
the class CallHomeMountSessionContextTest method activationOfListenerSupportsSessionDown.
@Test
public void activationOfListenerSupportsSessionDown() {
// given
when(mockActivator.activate(any(NetconfClientSessionListener.class))).thenAnswer(invocationOnMock -> {
NetconfClientSession mockSession = mock(NetconfClientSession.class);
Exception mockException = mock(Exception.class);
Object arg = invocationOnMock.getArguments()[0];
((NetconfClientSessionListener) arg).onSessionDown(mockSession, mockException);
return null;
});
// given
NetconfClientSessionListener mockListener = mock(NetconfClientSessionListener.class);
// when
mockActivator.activate(mockListener);
// then
verify(mockListener, times(1)).onSessionDown(any(NetconfClientSession.class), any(Exception.class));
}
Aggregations