@Test
public void testAbortAfterReady() {

    dataStoreContextBuilder.shardTransactionCommitTimeoutInSeconds(1);
    final ShardTestKit testKit = new ShardTestKit(getSystem());
    final TestActorRef<Shard> shard = actorFactory.createTestActor(
        newShardProps().withDispatcher(Dispatchers.DefaultDispatcherId()), "testAbortAfterReady");
    ShardTestKit.waitUntilLeader(shard);
    final Duration duration = Duration.ofSeconds(5);
    // Ready a tx.
    final TransactionIdentifier transactionID1 = nextTransactionId();
    shard.tell(newBatchedModifications(transactionID1, TestModel.TEST_PATH,
        ImmutableNodes.containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
    testKit.expectMsgClass(duration, ReadyTransactionReply.class);
    // Send the AbortTransaction message.
    shard.tell(new AbortTransaction(transactionID1, CURRENT_VERSION).toSerializable(), testKit.getRef());
    testKit.expectMsgClass(duration, AbortTransactionReply.class);
    assertEquals("getPendingTxCommitQueueSize", 0, shard.underlyingActor().getPendingTxCommitQueueSize());
    // Now send CanCommitTransaction - should fail.
    shard.tell(new CanCommitTransaction(transactionID1, CURRENT_VERSION).toSerializable(), testKit.getRef());
    final Throwable failure = testKit.expectMsgClass(duration, akka.actor.Status.Failure.class).cause();
    assertTrue("Failure type", failure instanceof IllegalStateException);
    // Ready and CanCommit another and verify success.
    final TransactionIdentifier transactionID2 = nextTransactionId();
    shard.tell(newBatchedModifications(transactionID2, TestModel.TEST_PATH,
        ImmutableNodes.containerNode(TestModel.TEST_QNAME), true, false, 1), testKit.getRef());
    testKit.expectMsgClass(duration, ReadyTransactionReply.class);
    shard.tell(new CanCommitTransaction(transactionID2, CURRENT_VERSION).toSerializable(), testKit.getRef());
    testKit.expectMsgClass(duration, CanCommitTransactionReply.class);
}