+ String pathSuffix = shard.path().toString().replaceFirst("akka://test", "");
+ assertTrue("Cohort path", readyReply.getCohortPath().endsWith(pathSuffix));
+ // Send the CanCommitTransaction message for the first Tx.
+
+ shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), testKit.getRef());
+ final CanCommitTransactionReply canCommitReply = CanCommitTransactionReply
+ .fromSerializable(testKit.expectMsgClass(duration, CanCommitTransactionReply.class));
+ assertTrue("Can commit", canCommitReply.getCanCommit());
+
+ // Ready 2 more Tx's.
+
+ shard.tell(prepareBatchedModifications(transactionID2, TestModel.OUTER_LIST_PATH,
+ ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME).build(), false), testKit.getRef());
+ testKit.expectMsgClass(duration, ReadyTransactionReply.class);
+
+ shard.tell(
+ prepareBatchedModifications(transactionID3,
+ YangInstanceIdentifier.builder(TestModel.OUTER_LIST_PATH)
+ .nodeWithKey(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1).build(),
+ ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1), false), testKit.getRef());
+ testKit.expectMsgClass(duration, ReadyTransactionReply.class);
+
+ // Send the CanCommitTransaction message for the next 2 Tx's.
+ // These should get queued and
+ // processed after the first Tx completes.
+
+ final Future<Object> canCommitFuture1 = Patterns.ask(shard,
+ new CanCommitTransaction(transactionID2, CURRENT_VERSION).toSerializable(), timeout);
+
+ final Future<Object> canCommitFuture2 = Patterns.ask(shard,
+ new CanCommitTransaction(transactionID3, CURRENT_VERSION).toSerializable(), timeout);
+
+ // Send the CommitTransaction message for the first Tx. After it
+ // completes, it should
+ // trigger the 2nd Tx to proceed which should in turn then
+ // trigger the 3rd.
+
+ shard.tell(new CommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), testKit.getRef());
+ testKit.expectMsgClass(duration, CommitTransactionReply.class);
+
+ // Wait for the next 2 Tx's to complete.
+
+ canCommitFuture1.onComplete(new OnCanCommitFutureComplete(transactionID2), getSystem().dispatcher());
+
+ canCommitFuture2.onComplete(new OnCanCommitFutureComplete(transactionID3), getSystem().dispatcher());
+
+ final boolean done = commitLatch.await(timeoutSec, TimeUnit.SECONDS);
+
+ final Throwable t = caughtEx.get();
+ if (t != null) {
+ Throwables.propagateIfPossible(t, Exception.class);
+ throw new RuntimeException(t);
+ }
+
+ assertTrue("Commits complete", done);
+
+// final InOrder inOrder = inOrder(cohort1.getCanCommit(), cohort1.getPreCommit(), cohort1.getCommit(),
+// cohort2.getCanCommit(), cohort2.getPreCommit(), cohort2.getCommit(), cohort3.getCanCommit(),
+// cohort3.getPreCommit(), cohort3.getCommit());
+// inOrder.verify(cohort1.getCanCommit()).onSuccess(any(Void.class));
+// inOrder.verify(cohort1.getPreCommit()).onSuccess(any(DataTreeCandidate.class));
+// inOrder.verify(cohort2.getCanCommit()).onSuccess(any(Void.class));
+// inOrder.verify(cohort2.getPreCommit()).onSuccess(any(DataTreeCandidate.class));
+// inOrder.verify(cohort3.getCanCommit()).onSuccess(any(Void.class));
+// inOrder.verify(cohort3.getPreCommit()).onSuccess(any(DataTreeCandidate.class));
+// inOrder.verify(cohort1.getCommit()).onSuccess(any(UnsignedLong.class));
+// inOrder.verify(cohort2.getCommit()).onSuccess(any(UnsignedLong.class));
+// inOrder.verify(cohort3.getCommit()).onSuccess(any(UnsignedLong.class));
+
+ // Verify data in the data store.
+
+ verifyOuterListEntry(shard, 1);
+
+ verifyLastApplied(shard, 3);