use of org.opendaylight.netconf.api.NetconfTerminationReason in project netconf by opendaylight.
the class AbstractNetconfSession method close.
@Override
public void close() {
channel.close();
up = false;
sessionListener.onSessionTerminated(thisInstance(), new NetconfTerminationReason("Session closed"));
}
use of org.opendaylight.netconf.api.NetconfTerminationReason in project netconf by opendaylight.
the class CallHomeMountSessionContextTest method activationOfListenerSupportsSessionTermination.
@Test
public void activationOfListenerSupportsSessionTermination() {
// given
when(mockActivator.activate(any(NetconfClientSessionListener.class))).thenAnswer(invocationOnMock -> {
NetconfClientSession mockSession = mock(NetconfClientSession.class);
NetconfTerminationReason mockReason = mock(NetconfTerminationReason.class);
Object arg = invocationOnMock.getArguments()[0];
((NetconfClientSessionListener) arg).onSessionTerminated(mockSession, mockReason);
return null;
});
NetconfClientSessionListener mockListener = mock(NetconfClientSessionListener.class);
// when
mockActivator.activate(mockListener);
// then
verify(mockListener, times(1)).onSessionTerminated(any(NetconfClientSession.class), any(NetconfTerminationReason.class));
}
use of org.opendaylight.netconf.api.NetconfTerminationReason in project netconf by opendaylight.
the class NetconfDeviceCommunicatorTest method testOnSessionTerminated.
@Test
public void testOnSessionTerminated() throws Exception {
setupSession();
ListenableFuture<RpcResult<NetconfMessage>> resultFuture = sendRequest();
doNothing().when(mockDevice).onRemoteSessionDown();
String reasonText = "testing terminate";
NetconfTerminationReason reason = new NetconfTerminationReason(reasonText);
communicator.onSessionTerminated(mockSession, reason);
RpcError rpcError = verifyErrorRpcResult(resultFuture.get(), RpcError.ErrorType.TRANSPORT, "operation-failed");
assertEquals("RpcError message", reasonText, rpcError.getMessage());
verify(mockDevice).onRemoteSessionDown();
}
use of org.opendaylight.netconf.api.NetconfTerminationReason in project netconf by opendaylight.
the class NetconfServerSessionListenerTest method testOnSessionTerminated.
@Test
public void testOnSessionTerminated() throws Exception {
listener.onSessionTerminated(session, new NetconfTerminationReason("reason"));
verify(monitoringListener).onSessionDown(session);
verify(closeable).close();
verify(router).close();
}
Aggregations