Search in sources :

Example 1 with SchemalessMessageTransformer

use of org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer in project netconf by opendaylight.

the class SchemalessNetconfDeviceTest method testSessionOnMethods.

@Test
public void testSessionOnMethods() throws Exception {
    final RemoteDeviceHandler<NetconfSessionPreferences> facade = getFacade();
    final NetconfDeviceCommunicator listener = mockCloseableClass(NetconfDeviceCommunicator.class);
    final SchemalessMessageTransformer messageTransformer = mock(SchemalessMessageTransformer.class);
    final RemoteDeviceId remoteDeviceId = new RemoteDeviceId("test-D", InetSocketAddress.createUnresolved("localhost", 22));
    final Throwable throwable = new Throwable();
    final SchemalessNetconfDevice device = new SchemalessNetconfDevice(BASE_SCHEMAS, remoteDeviceId, facade, messageTransformer);
    final NetconfSessionPreferences sessionCaps = getSessionCaps(true, Lists.newArrayList(TEST_NAMESPACE + "?module=" + TEST_MODULE + "&amp;revision=" + TEST_REVISION));
    final NetconfMessage netconfMessage = mock(NetconfMessage.class);
    device.onRemoteSessionUp(sessionCaps, listener);
    verify(facade).onDeviceConnected(any(MountPointContext.class), any(NetconfSessionPreferences.class), any(DOMRpcService.class));
    device.onNotification(netconfMessage);
    verify(facade).onNotification(isNull());
    device.onRemoteSessionDown();
    verify(facade).onDeviceDisconnected();
    device.onRemoteSessionFailed(throwable);
    verify(facade).onDeviceFailed(throwable);
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfDeviceCommunicator(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) SchemalessMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer) NetconfSessionPreferences(org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences) MountPointContext(org.opendaylight.yangtools.rfc8528.data.api.MountPointContext) Test(org.junit.Test)

Example 2 with SchemalessMessageTransformer

use of org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer in project netconf by opendaylight.

the class SchemalessNetconfDeviceRpcTest method setUp.

@Before
public void setUp() throws Exception {
    RpcResult<NetconfMessage> msg = null;
    ListenableFuture<RpcResult<NetconfMessage>> future = Futures.immediateFuture(msg);
    doReturn(future).when(listener).sendRequest(any(), any());
    final MessageCounter counter = new MessageCounter();
    deviceRpc = new SchemalessNetconfDeviceRpc(new RemoteDeviceId("device1", InetSocketAddress.createUnresolved("0.0.0.0", 17830)), listener, new BaseRpcSchemalessTransformer(BASE_SCHEMAS, counter), new SchemalessMessageTransformer(counter));
}
Also used : RemoteDeviceId(org.opendaylight.netconf.sal.connect.util.RemoteDeviceId) NetconfMessage(org.opendaylight.netconf.api.NetconfMessage) MessageCounter(org.opendaylight.netconf.sal.connect.util.MessageCounter) SchemalessMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) BaseRpcSchemalessTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseRpcSchemalessTransformer) Before(org.junit.Before)

Aggregations

NetconfMessage (org.opendaylight.netconf.api.NetconfMessage)2 SchemalessMessageTransformer (org.opendaylight.netconf.sal.connect.netconf.schema.mapping.SchemalessMessageTransformer)2 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)2 Before (org.junit.Before)1 Test (org.junit.Test)1 DOMRpcService (org.opendaylight.mdsal.dom.api.DOMRpcService)1 NetconfDeviceCommunicator (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfDeviceCommunicator)1 NetconfSessionPreferences (org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences)1 BaseRpcSchemalessTransformer (org.opendaylight.netconf.sal.connect.netconf.schema.mapping.BaseRpcSchemalessTransformer)1 MessageCounter (org.opendaylight.netconf.sal.connect.util.MessageCounter)1 MountPointContext (org.opendaylight.yangtools.rfc8528.data.api.MountPointContext)1 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)1