Search in sources :

Example 1 with NetconfTerminationReason

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"));
}
Also used : NetconfTerminationReason(org.opendaylight.netconf.api.NetconfTerminationReason)

Example 2 with NetconfTerminationReason

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));
}
Also used : NetconfClientSessionListener(org.opendaylight.netconf.client.NetconfClientSessionListener) NetconfTerminationReason(org.opendaylight.netconf.api.NetconfTerminationReason) NetconfClientSession(org.opendaylight.netconf.client.NetconfClientSession) Test(org.junit.Test)

Example 3 with NetconfTerminationReason

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();
}
Also used : NetconfTerminationReason(org.opendaylight.netconf.api.NetconfTerminationReason) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError) Test(org.junit.Test)

Example 4 with NetconfTerminationReason

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();
}
Also used : NetconfTerminationReason(org.opendaylight.netconf.api.NetconfTerminationReason) Test(org.junit.Test)

Aggregations

NetconfTerminationReason (org.opendaylight.netconf.api.NetconfTerminationReason)4 Test (org.junit.Test)3 NetconfClientSession (org.opendaylight.netconf.client.NetconfClientSession)1 NetconfClientSessionListener (org.opendaylight.netconf.client.NetconfClientSessionListener)1 RpcError (org.opendaylight.yangtools.yang.common.RpcError)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1