Search in sources :

Example 1 with Transaction

use of org.opendaylight.mdsal.binding.api.Transaction in project netconf by opendaylight.

the class MountPointEndToEndTest method setupSlave.

private void setupSlave() throws Exception {
    AbstractConcurrentDataBrokerTest dataBrokerTest = newDataBrokerTest();
    slaveDataBroker = dataBrokerTest.getDataBroker();
    slaveSystem = ActorSystem.create(ACTOR_SYSTEM_NAME, ConfigFactory.load().getConfig("Slave"));
    doReturn(slaveSystem).when(mockSlaveActorSystemProvider).getActorSystem();
    doReturn(mockSlaveClusterSingletonServiceReg).when(mockSlaveClusterSingletonServiceProvider).registerClusterSingletonService(any());
    slaveNetconfTopologyManager = new NetconfTopologyManager(BASE_SCHEMAS, slaveDataBroker, mockRpcProviderRegistry, mockActionProviderRegistry, mockSlaveClusterSingletonServiceProvider, mockKeepaliveExecutor, mockThreadPool, mockSlaveActorSystemProvider, eventExecutor, mockClientDispatcher, TOPOLOGY_ID, config, slaveMountPointService, mockEncryptionService, mockRpcProviderService, deviceActionFactory, resourceManager) {

        @Override
        protected NetconfTopologyContext newNetconfTopologyContext(final NetconfTopologySetup setup, final ServiceGroupIdentifier serviceGroupIdent, final Timeout actorResponseWaitTime, final DeviceActionFactory actionFactory) {
            NetconfTopologyContext spiedContext = spy(super.newNetconfTopologyContext(setup, serviceGroupIdent, actorResponseWaitTime, actionFactory));
            slaveNetconfTopologyContextFuture.set(spiedContext);
            return spiedContext;
        }
    };
    slaveNetconfTopologyManager.init();
    verifyTopologyNodesCreated(slaveDataBroker);
    slaveTxChain = slaveDataBroker.createTransactionChain(new TransactionChainListener() {

        @Override
        public void onTransactionChainSuccessful(final TransactionChain chain) {
        }

        @Override
        public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction, final Throwable cause) {
            LOG.error("Slave transaction chain failed", cause);
        }
    });
}
Also used : TransactionChainListener(org.opendaylight.mdsal.binding.api.TransactionChainListener) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) DOMDataTreeReadWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction) Transaction(org.opendaylight.mdsal.binding.api.Transaction) Timeout(akka.util.Timeout) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) ServiceGroupIdentifier(org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier) DeviceActionFactory(org.opendaylight.netconf.sal.connect.api.DeviceActionFactory) AbstractConcurrentDataBrokerTest(org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest) NetconfTopologySetup(org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup)

Example 2 with Transaction

use of org.opendaylight.mdsal.binding.api.Transaction in project lispflowmapping by opendaylight.

the class DataStoreBackEndTest method onTransactionChainFailedTest.

/**
 * Increases {@link DataStoreBackEnd} code coverage.
 */
@Test
public void onTransactionChainFailedTest() {
    Transaction asyncTransactionMock = Mockito.mock(Transaction.class);
    Mockito.when(asyncTransactionMock.getIdentifier()).thenReturn(new Object());
    dataStoreBackEnd.onTransactionChainFailed(Mockito.mock(TransactionChain.class), asyncTransactionMock, Mockito.mock(Throwable.class));
}
Also used : ReadTransaction(org.opendaylight.mdsal.binding.api.ReadTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Transaction(org.opendaylight.mdsal.binding.api.Transaction) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with Transaction

use of org.opendaylight.mdsal.binding.api.Transaction in project netconf by opendaylight.

the class NetconfDeviceTopologyAdapterTest method setUp.

@Before
public void setUp() throws Exception {
    doReturn(writeTx).when(txChain).newWriteOnlyTransaction();
    doNothing().when(writeTx).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class));
    doNothing().when(writeTx).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(NetworkTopology.class));
    doReturn(txIdent).when(writeTx).getIdentifier();
    ConcurrentDataBrokerTestCustomizer customizer = new ConcurrentDataBrokerTestCustomizer(true);
    domDataBroker = customizer.getDOMDataBroker();
    dataBroker = customizer.createDataBroker();
    customizer.updateSchema(RUNTIME_CONTEXT);
    transactionChain = dataBroker.createTransactionChain(new TransactionChainListener() {

        @Override
        public void onTransactionChainFailed(final TransactionChain chain, final Transaction transaction, final Throwable cause) {
        }

        @Override
        public void onTransactionChainSuccessful(final TransactionChain chain) {
        }
    });
}
Also used : ConcurrentDataBrokerTestCustomizer(org.opendaylight.mdsal.binding.dom.adapter.test.ConcurrentDataBrokerTestCustomizer) TransactionChainListener(org.opendaylight.mdsal.binding.api.TransactionChainListener) DOMDataTreeWriteTransaction(org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction) WriteTransaction(org.opendaylight.mdsal.binding.api.WriteTransaction) Transaction(org.opendaylight.mdsal.binding.api.Transaction) NetconfNode(org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode) Node(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) NetworkTopology(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology) TransactionChain(org.opendaylight.mdsal.binding.api.TransactionChain) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) InstanceIdentifier(org.opendaylight.yangtools.yang.binding.InstanceIdentifier) LogicalDatastoreType(org.opendaylight.mdsal.common.api.LogicalDatastoreType) Before(org.junit.Before)

Aggregations

Transaction (org.opendaylight.mdsal.binding.api.Transaction)3 TransactionChain (org.opendaylight.mdsal.binding.api.TransactionChain)3 WriteTransaction (org.opendaylight.mdsal.binding.api.WriteTransaction)3 ReadTransaction (org.opendaylight.mdsal.binding.api.ReadTransaction)2 TransactionChainListener (org.opendaylight.mdsal.binding.api.TransactionChainListener)2 DOMDataTreeWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction)2 Timeout (akka.util.Timeout)1 Before (org.junit.Before)1 Test (org.junit.Test)1 AbstractConcurrentDataBrokerTest (org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest)1 ConcurrentDataBrokerTestCustomizer (org.opendaylight.mdsal.binding.dom.adapter.test.ConcurrentDataBrokerTestCustomizer)1 LogicalDatastoreType (org.opendaylight.mdsal.common.api.LogicalDatastoreType)1 DOMDataTreeReadWriteTransaction (org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction)1 ServiceGroupIdentifier (org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier)1 DeviceActionFactory (org.opendaylight.netconf.sal.connect.api.DeviceActionFactory)1 NetconfTopologySetup (org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup)1 NetconfNode (org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode)1 NetworkTopology (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology)1 Node (org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node)1 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)1