import static org.junit.Assert.fail;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType.OPERATIONAL;
+
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ListenableFuture;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+@Deprecated
public class DOMTransactionChainTest {
private SchemaContext schemaContext;
@Before
public void setupStore() {
- InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.sameThreadExecutor());
- InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.sameThreadExecutor());
+ InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER", MoreExecutors.newDirectExecutorService());
+ InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG", MoreExecutors.newDirectExecutorService());
schemaContext = TestModel.createTestContext();
operStore.onGlobalContextUpdated(schemaContext);
configStore.onGlobalContextUpdated(schemaContext);
- ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder() //
+ ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder() //
.put(CONFIGURATION, configStore) //
.put(OPERATIONAL, operStore) //
.build();
assertNotNull(txChain);
/**
- * We alocate new read-write transaction and write /test
- *
- *
+ * We alocate new read-write transaction and write /test.
*/
DOMDataReadWriteTransaction firstTx = allocateAndWrite(txChain);
/**
* First transaction is marked as ready, we are able to allocate chained
- * transactions
+ * transactions.
*/
- ListenableFuture<Void> firstWriteTxFuture = firstTx.submit();
+ ListenableFuture<?> firstWriteTxFuture = firstTx.commit();
/**
* We alocate chained transaction - read transaction.
*
* We test if we are able to read data from tx, read should not fail
* since we are using chained transaction.
- *
- *
*/
assertTestContainerExists(secondReadTx);
/**
- *
* We alocate next transaction, which is still based on first one, but
* is read-write.
*
DOMDataReadWriteTransaction thirdDeleteTx = allocateAndDelete(txChain);
/**
- * We commit first transaction
+ * We commit first transaction.
*
*/
assertCommitSuccessful(firstWriteTxFuture);
/**
- *
* Allocates transaction from data store.
- *
*/
DOMDataReadTransaction storeReadTx = domBroker.newReadOnlyTransaction();
assertTestContainerExists(storeReadTx);
/**
- * third transaction is sealed and commited
+ * third transaction is sealed and commited.
*/
- ListenableFuture<Void> thirdDeleteTxFuture = thirdDeleteTx.submit();
+ ListenableFuture<?> thirdDeleteTxFuture = thirdDeleteTx.commit();
assertCommitSuccessful(thirdDeleteTxFuture);
/**
}
@Test
- public void testTransactionChainNotSealed() throws InterruptedException, ExecutionException, TimeoutException {
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ public void testTransactionChainNotSealed() throws InterruptedException, ExecutionException {
BlockingTransactionChainListener listener = new BlockingTransactionChainListener();
DOMTransactionChain txChain = domBroker.createTransactionChain(listener);
assertNotNull(txChain);
/**
* We alocate new read-write transaction and write /test
- *
- *
*/
allocateAndWrite(txChain);
}
}
- private static DOMDataReadWriteTransaction allocateAndDelete(final DOMTransactionChain txChain)
- throws InterruptedException, ExecutionException {
+ private static DOMDataReadWriteTransaction allocateAndDelete(
+ final DOMTransactionChain txChain) throws InterruptedException, ExecutionException {
DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction();
/**
return tx;
}
- private static void assertCommitSuccessful(final ListenableFuture<Void> future)
+ private static void assertCommitSuccessful(final ListenableFuture<?> future)
throws InterruptedException, ExecutionException {
future.get();
}
- private static void assertTestContainerExists(final DOMDataReadTransaction readTx) throws InterruptedException,
- ExecutionException {
+ private static void assertTestContainerExists(final DOMDataReadTransaction readTx)
+ throws InterruptedException, ExecutionException {
ListenableFuture<Optional<NormalizedNode<?, ?>>> readFuture = readTx.read(OPERATIONAL, TestModel.TEST_PATH);
Optional<NormalizedNode<?, ?>> readedData = readFuture.get();
assertTrue(readedData.isPresent());
}
- private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx) throws InterruptedException,
- ExecutionException {
+ private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx)
+ throws InterruptedException, ExecutionException {
tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
assertTestContainerExists(tx);
}