use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testListenerCancellation.
@Test
public void testListenerCancellation() throws Exception {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).when(rpc).invokeRpc(any(QName.class), isNull());
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.cancel();
verify(listener).onTransactionCancelled(tx);
verify(listener, never()).onTransactionSubmitted(tx);
verify(listener, never()).onTransactionSuccessful(tx);
verify(listener, never()).onTransactionFailed(eq(tx), any());
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method setUp.
@Before
public void setUp() {
final FluentFuture<DefaultDOMRpcResult> successFuture = FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null));
doReturn(successFuture).doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("Failed tx"))).doReturn(successFuture).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
yangIId = YangInstanceIdentifier.builder().node(NetconfState.QNAME).build();
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testDiscardChangesNotSentWithoutCandidate.
@Test
public void testDiscardChangesNotSentWithoutCandidate() {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).doReturn(FluentFutures.immediateFailedFluentFuture(new IllegalStateException("Failed tx"))).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
final WriteRunningTx tx = new WriteRunningTx(id, new NetconfBaseOps(rpc, BASE_SCHEMAS.getBaseSchemaWithNotifications().getMountPointContext()), false);
tx.delete(LogicalDatastoreType.CONFIGURATION, yangIId);
tx.commit();
// verify discard changes was sent
final InOrder inOrder = inOrder(rpc);
inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME, NetconfBaseOps.getLockContent(NETCONF_RUNNING_QNAME));
inOrder.verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME), any(ContainerNode.class));
inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME, NetconfBaseOps.getUnLockContent(NETCONF_RUNNING_QNAME));
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testFailedCommit.
@Test
public void testFailedCommit() throws Exception {
final FluentFuture<DefaultDOMRpcResult> rpcErrorFuture = FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult(RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, "a", "m")));
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).doReturn(rpcErrorFuture).when(rpc).invokeRpc(any(QName.class), any(ContainerNode.class));
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(MountPointContext.class)), false);
try {
tx.commit().get();
fail("Submit should fail");
} catch (final ExecutionException e) {
// Intended
}
}
use of org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult in project netconf by opendaylight.
the class NetconfDeviceWriteOnlyTxTest method testDiscardChanges.
@Test
public void testDiscardChanges() throws InterruptedException {
doReturn(FluentFutures.immediateFluentFuture(new DefaultDOMRpcResult((NormalizedNode) null))).when(rpc).invokeRpc(any(QName.class), isNull());
final WriteCandidateTx tx = new WriteCandidateTx(id, new NetconfBaseOps(rpc, mock(MountPointContext.class)), false);
try {
tx.commit().get();
} catch (final ExecutionException e) {
// verify discard changes was sent
final InOrder inOrder = inOrder(rpc);
inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_LOCK_QNAME, NetconfBaseOps.getLockContent(NETCONF_CANDIDATE_QNAME));
inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME, NetconfMessageTransformUtil.COMMIT_RPC_CONTENT);
inOrder.verify(rpc).invokeRpc(eq(NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME), isNull());
inOrder.verify(rpc).invokeRpc(NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME, NetconfBaseOps.getUnLockContent(NETCONF_CANDIDATE_QNAME));
return;
}
fail("Submit should fail");
}
Aggregations