DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
/**
- *
+ *
* Writes /test in writeTx
- *
+ *
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
/**
- *
+ *
* Reads /test from writeTx Read should return container.
- *
+ *
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
/**
- *
+ *
* Reads /test from readTx Read should return Absent.
- *
+ *
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> readTxContainer = readTx.read(TestModel.TEST_PATH);
assertFalse(readTxContainer.get().isPresent());
DOMStoreReadWriteTransaction writeTx = domStore.newReadWriteTransaction();
assertNotNull(writeTx);
/**
- *
+ *
* Writes /test in writeTx
- *
+ *
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
/**
- *
+ *
* Reads /test from writeTx Read should return container.
- *
+ *
*/
ListenableFuture<Optional<NormalizedNode<?, ?>>> writeTxContainer = writeTx.read(TestModel.TEST_PATH);
assertTrue(writeTxContainer.get().isPresent());
/**
* We alocate new read-write transaction and write /test
- *
- *
+ *
+ *
*/
DOMStoreReadWriteTransaction firstTx = txChain.newReadWriteTransaction();
assertTestContainerWrite(firstTx);
DOMStoreReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
/**
- *
+ *
* 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.
- *
+ *
*/
DOMStoreReadWriteTransaction thirdDeleteTx = txChain.newReadWriteTransaction();
/**
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
- *
- *
+ *
+ *
*/
assertTestContainerExists(thirdDeleteTx);
/**
* We commit first transaction
- *
+ *
*/
assertThreePhaseCommit(firstWriteTxCohort);
assertTestContainerExists(storeReadTx);
/**
* We commit third transaction
- *
+ *
*/
assertThreePhaseCommit(thirdDeleteTxCohort);
}
private static Optional<NormalizedNode<?, ?>> assertTestContainerWrite(final DOMStoreReadWriteTransaction writeTx)
throws InterruptedException, ExecutionException {
/**
- *
+ *
* Writes /test in writeTx
- *
+ *
*/
writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
}
/**
- *
+ *
* Reads /test from readTx Read should return container.
- *
+ *
*/
private static Optional<NormalizedNode<?, ?>> assertTestContainerExists(DOMStoreReadTransaction readTx)
throws InterruptedException, ExecutionException {