@Test    
public void testDynamicSessionIsAddedToSessionConnectorAndFileStoreIsKept() throws Exception {

    SessionID id = new SessionID("FIX.4.4", "SENDER", "TARGET");
    SessionID templateId = new SessionID("FIX.4.4", "ANY", "ANY");
    SessionSettings ownSettings = new SessionSettings();
    ownSettings.setString(id, "FileStorePath", tempFolder.getRoot().getAbsolutePath());
    ownSettings.setString(templateId, "ConnectionType", "acceptor");
    ownSettings.setString(templateId, "StartTime", "00:00:00");
    ownSettings.setString(templateId, "EndTime", "00:00:00");
    templateMappings.clear();   // only use own template
    templateMappings.add(new TemplateMapping(new SessionID("FIX.4.4", WILDCARD, WILDCARD,
            WILDCARD, WILDCARD, WILDCARD, WILDCARD, WILDCARD), templateId));
    MessageStoreFactory ownMessageStoreFactory = new FileStoreFactory(ownSettings);
    provider = new DynamicAcceptorSessionProvider(ownSettings, templateMappings, application,
            ownMessageStoreFactory, logFactory, messageFactory);
    MySessionConnector connector = new MySessionConnector(ownSettings, null);
    Session session2 = provider.getSession(id, connector);
    assertEquals(1, connector.sessions.size());
    
    assertEquals(1, session2.getStore().getNextSenderMsgSeqNum() );
    Message message = new NewOrderSingle();
    session2.send(message);
    assertEquals(2, session2.getStore().getNextSenderMsgSeqNum() );
    session2.close();
    
    session2 = provider.getSession(id, connector);
    assertEquals(1, connector.sessions.size());
    assertEquals(2, session2.getStore().getNextSenderMsgSeqNum() );
    message = new NewOrderSingle();
    session2.send(message);
    assertEquals(3, session2.getStore().getNextSenderMsgSeqNum() );
    session2.close();
}