+ @Test
+ public void testCreateChainedTransactionsInQuickSuccession() throws Exception{
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionsInQuickSuccession", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ NormalizedNode<?, ?> testNode = ImmutableNodes.containerNode(TestModel.TEST_QNAME);
+
+ int nTxs = 20;
+ List<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(nTxs);
+ for(int i = 0; i < nTxs; i++) {
+ DOMStoreReadWriteTransaction rwTx = txChain.newReadWriteTransaction();
+
+ rwTx.merge(TestModel.TEST_PATH, testNode);
+
+ cohorts.add(rwTx.ready());
+
+ }
+
+ for(DOMStoreThreePhaseCommitCohort cohort: cohorts) {
+ doCommit(cohort);
+ }
+
+ txChain.close();
+
+ cleanup(dataStore);
+ }};
+ }
+
+ @Test
+ public void testCreateChainedTransactionAfterEmptyTxReadied() throws Exception{
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionAfterEmptyTxReadied", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ DOMStoreReadWriteTransaction rwTx1 = txChain.newReadWriteTransaction();
+
+ rwTx1.ready();
+
+ DOMStoreReadWriteTransaction rwTx2 = txChain.newReadWriteTransaction();
+
+ Optional<NormalizedNode<?, ?>> optional = rwTx2.read(TestModel.TEST_PATH).get(5, TimeUnit.SECONDS);
+ assertEquals("isPresent", false, optional.isPresent());
+
+ txChain.close();
+
+ cleanup(dataStore);
+ }};
+ }
+
+ @Test
+ public void testCreateChainedTransactionWhenPreviousNotReady() throws Throwable {
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionWhenPreviousNotReady", "test-1");
+
+ final DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ DOMStoreWriteTransaction writeTx = txChain.newWriteOnlyTransaction();
+ assertNotNull("newWriteOnlyTransaction returned null", writeTx);
+
+ writeTx.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+
+ // Try to create another Tx of each type - each should fail b/c the previous Tx wasn't
+ // readied.
+
+ assertExceptionOnTxChainCreates(txChain, IllegalStateException.class);
+ }};
+ }
+
+ @Test
+ public void testCreateChainedTransactionAfterClose() throws Throwable {
+ new IntegrationTestKit(getSystem()) {{
+ DistributedDataStore dataStore = setupDistributedDataStore(
+ "testCreateChainedTransactionAfterClose", "test-1");
+
+ DOMStoreTransactionChain txChain = dataStore.createTransactionChain();
+
+ txChain.close();
+
+ // Try to create another Tx of each type - should fail b/c the previous Tx was closed.
+
+ assertExceptionOnTxChainCreates(txChain, TransactionChainClosedException.class);
+ }};
+ }
+