Search in sources :

Example 31 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class KeepaliveSalFacadeResponseWaitingTest method testKeepaliveSalResponseWaiting.

/**
 * Not sending keepalive rpc test while the repsonse is processing.
 */
@Test
public void testKeepaliveSalResponseWaiting() {
    // This settable future object will be never set to any value. The test wants to simulate waiting for the result
    // of the future object.
    final SettableFuture<DOMRpcResult> settableFuture = SettableFuture.create();
    doReturn(settableFuture).when(deviceRpc).invokeRpc(null, null);
    // This settable future will be used to check the invokation of keepalive RPC. Should be never invoked.
    final SettableFuture<DOMRpcResult> keepaliveSettableFuture = SettableFuture.create();
    final DOMRpcResult keepaliveResult = new DefaultDOMRpcResult(Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME)).build());
    keepaliveSettableFuture.set(keepaliveResult);
    keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
    // Invoke general RPC on simulated local facade without args (or with null args). Will be returned
    // settableFuture variable without any set value. WaitingShaduler in keepalive sal facade should wait for any
    // result from the RPC and reset keepalive scheduler.
    underlyingSalFacade.invokeNullRpc();
    // Invoking of general RPC.
    verify(deviceRpc, after(2000).times(1)).invokeRpc(null, null);
    // verify the keepalive RPC invoke. Should be never happen.
    verify(deviceRpc, after(2000).never()).invokeRpc(NETCONF_GET_CONFIG_QNAME, KEEPALIVE_PAYLOAD);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 32 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class KeepaliveSalFacadeTest method testKeepaliveSuccess.

@Test
public void testKeepaliveSuccess() throws Exception {
    final DOMRpcResult result = new DefaultDOMRpcResult(Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME)).build());
    doReturn(FluentFutures.immediateFluentFuture(result)).when(deviceRpc).invokeRpc(any(QName.class), any(ContainerNode.class));
    keepaliveSalFacade.onDeviceConnected(null, null, deviceRpc);
    verify(underlyingSalFacade).onDeviceConnected(isNull(), isNull(), any(DOMRpcService.class), isNull());
    verify(deviceRpc, timeout(15000).times(5)).invokeRpc(any(QName.class), any(ContainerNode.class));
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcService(org.opendaylight.mdsal.dom.api.DOMRpcService) DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMRpcResult(org.opendaylight.mdsal.dom.api.DOMRpcResult) QName(org.opendaylight.yangtools.yang.common.QName) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Example 33 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class NetconfDataTreeServiceImplTest method setUp.

@Before
public void setUp() {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult())).when(rpcService).invokeRpc(any(), any());
    netconService = getNetconService();
    final EffectiveModelContext model = BindingRuntimeHelpers.createEffectiveModel(IetfNetconfService.class, NetconfState.class);
    netconfMessageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(model), true, BASE_SCHEMAS.getBaseSchema());
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) EmptyMountPointContext(org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext) NetconfMessageTransformer(org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer) EffectiveModelContext(org.opendaylight.yangtools.yang.model.api.EffectiveModelContext) Before(org.junit.Before)

Example 34 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class BaseRpcSchemalessTransformer method toRpcResult.

@Override
public DOMRpcResult toRpcResult(final NetconfMessage message, final QName rpc) {
    final NormalizedNode normalizedNode;
    if (NetconfMessageTransformUtil.isDataRetrievalOperation(rpc)) {
        final Element xmlData = NetconfMessageTransformUtil.getDataSubtree(message.getDocument());
        final Document data = XmlUtil.newDocument();
        data.appendChild(data.importNode(xmlData, true));
        DOMSourceAnyxmlNode xmlDataNode = Builders.anyXmlBuilder().withNodeIdentifier(NetconfMessageTransformUtil.NETCONF_DATA_NODEID).withValue(new DOMSource(data)).build();
        normalizedNode = Builders.containerBuilder().withNodeIdentifier(NetconfMessageTransformUtil.NETCONF_RPC_REPLY_NODEID).withChild(xmlDataNode).build();
    } else {
        // other base rpcs don't have any output, we can simply construct the payload here
        Preconditions.checkArgument(isOkPresent(message.getDocument()), "Unexpected content in response of rpc: %s, %s", rpc, message);
        normalizedNode = null;
    }
    return new DefaultDOMRpcResult(normalizedNode);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) DOMSource(javax.xml.transform.dom.DOMSource) DOMSourceAnyxmlNode(org.opendaylight.yangtools.yang.data.api.schema.DOMSourceAnyxmlNode) XmlElement(org.opendaylight.netconf.api.xml.XmlElement) Element(org.w3c.dom.Element) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) Document(org.w3c.dom.Document)

Example 35 with DefaultDOMRpcResult

use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.

the class NetconfDeviceWriteOnlyTxTest method testListenerSuccess.

@Test
public void testListenerSuccess() throws Exception {
    doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
    final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchema().getMountPointContext()), false);
    final TxListener listener = mock(TxListener.class);
    tx.addListener(listener);
    tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
    tx.commit();
    verify(listener).onTransactionSubmitted(tx);
    verify(listener).onTransactionSuccessful(tx);
    verify(listener, never()).onTransactionFailed(eq(tx), any());
    verify(listener, never()).onTransactionCancelled(tx);
}
Also used : DefaultDOMRpcResult(org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult) NetconfBaseOps(org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps) QName(org.opendaylight.yangtools.yang.common.QName) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) AbstractBaseSchemasTest(org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest) Test(org.junit.Test)

Aggregations

DefaultDOMRpcResult (org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult)72 Test (org.junit.Test)51 QName (org.opendaylight.yangtools.yang.common.QName)27 DOMRpcResult (org.opendaylight.mdsal.dom.api.DOMRpcResult)25 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)25 NormalizedNode (org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode)16 InstanceIdentifierContext (org.opendaylight.restconf.common.context.InstanceIdentifierContext)15 NetconfRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.NetconfRestconfStrategy)15 NormalizedNodePayload (org.opendaylight.restconf.nb.rfc8040.legacy.NormalizedNodePayload)12 Before (org.junit.Before)10 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)10 DataSchemaNode (org.opendaylight.yangtools.yang.model.api.DataSchemaNode)10 NetconfBaseOps (org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps)9 MdsalRestconfStrategy (org.opendaylight.restconf.nb.rfc8040.rests.transactions.MdsalRestconfStrategy)9 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)9 AbstractBaseSchemasTest (org.opendaylight.netconf.sal.connect.netconf.AbstractBaseSchemasTest)5 RemoteDeviceId (org.opendaylight.netconf.sal.connect.util.RemoteDeviceId)5 RpcError (org.opendaylight.yangtools.yang.common.RpcError)5 ArrayList (java.util.ArrayList)4 NormalizedNodeMessage (org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage)4