/**
* We alocate new read-write transaction and write /test
- *
- *
+ *
+ *
*/
DOMDataReadWriteTransaction firstTx = allocateAndWrite(txChain);
DOMDataReadTransaction 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.
- *
+ *
*/
DOMDataReadWriteTransaction thirdDeleteTx = allocateAndDelete(txChain);
/**
* We commit first transaction
- *
+ *
*/
assertCommitSuccessful(firstWriteTxFuture);
assertTestContainerExists(storeReadTx);
/**
* We commit third transaction
- *
+ *
*/
assertCommitSuccessful(thirdDeleteTxFuture);
/**
* We alocate new read-write transaction and write /test
- *
- *
+ *
+ *
*/
allocateAndWrite(txChain);
* IllegalStateException.
*/
try {
- DOMDataReadTransaction secondReadTx = txChain.newReadOnlyTransaction();
+ txChain.newReadOnlyTransaction();
fail("Allocation of secondReadTx should fail with IllegalStateException");
} catch (Exception e) {
assertTrue(e instanceof IllegalStateException);
}
}
- private static DOMDataReadWriteTransaction allocateAndDelete(DOMTransactionChain txChain)
+ private static DOMDataReadWriteTransaction allocateAndDelete(final DOMTransactionChain txChain)
throws InterruptedException, ExecutionException {
DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction();
/**
* We test existence of /test in third transaction container should
* still be visible from first one (which is still uncommmited).
- *
+ *
*/
assertTestContainerExists(tx);
return tx;
}
- private static DOMDataReadWriteTransaction allocateAndWrite(DOMTransactionChain txChain)
+ private static DOMDataReadWriteTransaction allocateAndWrite(final DOMTransactionChain txChain)
throws InterruptedException, ExecutionException {
DOMDataReadWriteTransaction tx = txChain.newReadWriteTransaction();
assertTestContainerWrite(tx);
return tx;
}
- private static void assertCommitSuccessful(ListenableFuture<RpcResult<TransactionStatus>> future)
+ private static void assertCommitSuccessful(final ListenableFuture<RpcResult<TransactionStatus>> future)
throws InterruptedException, ExecutionException {
RpcResult<TransactionStatus> rpcResult = future.get();
assertTrue(rpcResult.isSuccessful());
assertEquals(TransactionStatus.COMMITED, rpcResult.getResult());
}
- private static void assertTestContainerExists(DOMDataReadTransaction readTx) throws InterruptedException,
+ 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(DOMDataReadWriteTransaction tx) throws InterruptedException,
+ private static void assertTestContainerWrite(final DOMDataReadWriteTransaction tx) throws InterruptedException,
ExecutionException {
tx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
assertTestContainerExists(tx);