@Test
public void testLargePayloadSlicingExpiration() {

    logStart("testLargePayloadSlicingExpiration");
    MockRaftActorContext leaderActorContext = createActorContextWithFollower();
    ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setHeartBeatInterval(
            new FiniteDuration(100, TimeUnit.MILLISECONDS));
    ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setElectionTimeoutFactor(1);
    ((DefaultConfigParamsImpl)leaderActorContext.getConfigParams()).setSnapshotChunkSize(10);
    leaderActorContext.setReplicatedLog(new MockRaftActorContext.MockReplicatedLogBuilder().build());
    leaderActorContext.setCommitIndex(-1);
    leaderActorContext.setLastApplied(-1);
    final long term = leaderActorContext.getTermInformation().getCurrentTerm();
    leader = new Leader(leaderActorContext);
    leaderActorContext.setCurrentBehavior(leader);
    // Send initial heartbeat reply so follower is marked active
    MessageCollectorActor.expectFirstMatching(followerActor, AppendEntries.class);
    leader.handleMessage(followerActor, new AppendEntriesReply(FOLLOWER_ID, -1, true, -1, -1, (short)0));
    MessageCollectorActor.clearMessages(followerActor);
    sendReplicate(leaderActorContext, term, 0, new MockRaftActorContext.MockPayload("large",
            leaderActorContext.getConfigParams().getSnapshotChunkSize() + 1));
    MessageCollectorActor.expectFirstMatching(followerActor, MessageSlice.class);
    // Sleep for at least 3 * election timeout so the slicing state expires.
    Uninterruptibles.sleepUninterruptibly(leaderActorContext.getConfigParams()
            .getElectionTimeOutInterval().toMillis() * 3  + 50, TimeUnit.MILLISECONDS);
    MessageCollectorActor.clearMessages(followerActor);
    leader.handleMessage(leaderActor, SendHeartBeat.INSTANCE);
    AppendEntries appendEntries = MessageCollectorActor.expectFirstMatching(followerActor, AppendEntries.class);
    assertEquals("getLeaderCommit", -1, appendEntries.getLeaderCommit());
    assertEquals("Entries size", 0, appendEntries.getEntries().size());
    MessageCollectorActor.assertNoneMatching(followerActor, MessageSlice.class, 300);
    MessageCollectorActor.clearMessages(followerActor);
    // Send an AppendEntriesReply - this should restart the slicing.
    Uninterruptibles.sleepUninterruptibly(leaderActorContext.getConfigParams()
            .getHeartBeatInterval().toMillis() + 50, TimeUnit.MILLISECONDS);
    leader.handleMessage(followerActor, new AppendEntriesReply(FOLLOWER_ID, term, true, -1, term, (short)0));
    MessageCollectorActor.expectFirstMatching(followerActor, MessageSlice.class);
}