use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps 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.netconf.sal.connect.netconf.util.NetconfBaseOps 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.netconf.sal.connect.netconf.util.NetconfBaseOps 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");
}
use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class ReadOnlyTxTest method testExists.
@Test
public void testExists() throws Exception {
final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
final ReadOnlyTx readOnlyTx = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
readOnlyTx.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.empty());
verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME), any(ContainerNode.class));
readOnlyTx.exists(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.empty());
verify(rpc).invokeRpc(Mockito.eq(NetconfMessageTransformUtil.NETCONF_GET_QNAME), any(ContainerNode.class));
}
use of org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps in project netconf by opendaylight.
the class ReadOnlyTxTest method testIdentifier.
@Test
public void testIdentifier() throws Exception {
final NetconfBaseOps netconfOps = new NetconfBaseOps(rpc, mock(MountPointContext.class));
final ReadOnlyTx tx1 = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
final ReadOnlyTx tx2 = new ReadOnlyTx(netconfOps, new RemoteDeviceId("a", new InetSocketAddress("localhost", 196)));
Assert.assertNotEquals(tx1.getIdentifier(), tx2.getIdentifier());
}
Aggregations