@Test
// QFJ-716 - we need to make sure that the first message sent is a Logon
public void testStartOfInitiatorInsideOfSessionTime() throws Exception {

    final LocalDateTime now = LocalDateTime.now();
    ZoneOffset offset = ZoneOffset.systemDefault().getRules().getOffset(now);
    final MockSystemTimeSource systemTimeSource = new MockSystemTimeSource(
            now.toInstant(offset).toEpochMilli());
    SystemTime.setTimeSource(systemTimeSource);
    // set up some basic stuff
    final SessionID sessionID = new SessionID(
            FixVersions.BEGINSTRING_FIX44, "SENDER", "TARGET");
    final SessionSettings settings = SessionSettingsTest.setUpSession(null);
    // we want to start the initiator before the StartTime
    // make sure we start inside the Session time
    settings.setString("StartTime", UtcTimeOnlyConverter.convert(now.toLocalTime().minus(2000L, ChronoUnit.MILLIS), UtcTimestampPrecision.SECONDS));
    settings.setString("EndTime",   UtcTimeOnlyConverter.convert(now.toLocalTime().plus(3600000L, ChronoUnit.MILLIS), UtcTimestampPrecision.SECONDS));
    settings.setString("TimeZone", TimeZone.getDefault().getID());
    setupFileStoreForQFJ357(sessionID, settings);
    // Session gets constructed, triggering a reset
    final UnitTestApplication application = new UnitTestApplication();
    try (Session session = setUpFileStoreSession(application, true,
            new UnitTestResponder(), settings, sessionID)) {
        final SessionState state = getSessionState(session);
        
        assertEquals(1, state.getNextSenderMsgSeqNum());
        assertEquals(1, state.getNextTargetMsgSeqNum());
        
        session.next();
        systemTimeSource.increment(1000);
        session.next();
        systemTimeSource.increment(1000);
        session.next();
        
        // we should have sent a Logon since we are inside of the SessionTime
        assertEquals(1, application.toAdminMessages.size());
        assertEquals(MsgType.LOGON, application.toAdminMessages.get(0)
                .getHeader().getString(MsgType.FIELD));
        // no reset should have been triggered by QF/J
        assertEquals(0, application.sessionResets);
        
        assertEquals(2, state.getNextSenderMsgSeqNum());
        assertEquals(1, state.getNextTargetMsgSeqNum());
    }
}