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);
}
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));
}
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());
}
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);
}
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);
}
Aggregations