Search in sources :

Example 1 with DOMStoreReadTransaction

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction in project controller by opendaylight.

the class AbstractModificationTest method readData.

protected Optional<NormalizedNode<?, ?>> readData(final YangInstanceIdentifier path) throws Exception {
    DOMStoreReadTransaction transaction = store.newReadOnlyTransaction();
    ListenableFuture<Optional<NormalizedNode<?, ?>>> future = transaction.read(path);
    return future.get();
}
Also used : Optional(com.google.common.base.Optional) DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction)

Example 2 with DOMStoreReadTransaction

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction in project controller by opendaylight.

the class InMemoryDataStoreTest method testReadWithReadWriteTransactionClosed.

@Test(expected = ReadFailedException.class)
public void testReadWithReadWriteTransactionClosed() throws Exception {
    DOMStoreReadTransaction readTx = domStore.newReadWriteTransaction();
    assertNotNull(readTx);
    readTx.close();
    doReadAndThrowEx(readTx);
}
Also used : DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) Test(org.junit.Test)

Example 3 with DOMStoreReadTransaction

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction in project controller by opendaylight.

the class InMemoryDataStoreTest method testExistsThrowsReadFailedException.

@Test(expected = ReadFailedException.class)
public void testExistsThrowsReadFailedException() throws Exception {
    DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
    assertNotNull(readTx);
    readTx.close();
    readTx.exists(TestModel.TEST_PATH).checkedGet();
}
Also used : DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) Test(org.junit.Test)

Example 4 with DOMStoreReadTransaction

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction in project controller by opendaylight.

the class InMemoryDataStoreTest method testReadWithReadOnlyTransactionClosed.

@Test(expected = ReadFailedException.class)
public void testReadWithReadOnlyTransactionClosed() throws Exception {
    DOMStoreReadTransaction readTx = domStore.newReadOnlyTransaction();
    assertNotNull(readTx);
    readTx.close();
    doReadAndThrowEx(readTx);
}
Also used : DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) Test(org.junit.Test)

Example 5 with DOMStoreReadTransaction

use of org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction in project controller by opendaylight.

the class InMemoryDataStoreTest method testReadWithReadOnlyTransactionFailure.

@Test(expected = ReadFailedException.class)
public void testReadWithReadOnlyTransactionFailure() throws Exception {
    DataTreeSnapshot mockSnapshot = Mockito.mock(DataTreeSnapshot.class);
    Mockito.doThrow(new RuntimeException("mock ex")).when(mockSnapshot).readNode(Mockito.any(YangInstanceIdentifier.class));
    DOMStoreReadTransaction readTx = SnapshotBackedTransactions.newReadTransaction("1", true, mockSnapshot);
    doReadAndThrowEx(readTx);
}
Also used : DOMStoreReadTransaction(org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction) DataTreeSnapshot(org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) Test(org.junit.Test)

Aggregations

DOMStoreReadTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction)10 Test (org.junit.Test)9 DOMStoreReadWriteTransaction (org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction)4 Optional (com.google.common.base.Optional)2 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)2 DOMStoreThreePhaseCommitCohort (org.opendaylight.controller.sal.core.spi.data.DOMStoreThreePhaseCommitCohort)2 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)2 DataTreeSnapshot (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot)2 DOMStoreTransactionChain (org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1 DataTreeModification (org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification)1