Search in sources :

Example 1 with MessageStoreFactory

use of quickfix.MessageStoreFactory in project camel by apache.

the class TestSupport method createSession.

public static Session createSession(SessionID sessionID) throws ConfigError, IOException {
    MessageStoreFactory mockMessageStoreFactory = Mockito.mock(MessageStoreFactory.class);
    MessageStore mockMessageStore = Mockito.mock(MessageStore.class);
    Mockito.when(mockMessageStore.getCreationTime()).thenReturn(new Date());
    Mockito.when(mockMessageStoreFactory.create(sessionID)).thenReturn(mockMessageStore);
    DefaultSessionFactory factory = new DefaultSessionFactory(Mockito.mock(Application.class), mockMessageStoreFactory, Mockito.mock(LogFactory.class));
    SessionSettings settings = new SessionSettings();
    settings.setLong(Session.SETTING_HEARTBTINT, 10);
    settings.setString(Session.SETTING_START_TIME, "00:00:00");
    settings.setString(Session.SETTING_END_TIME, "00:00:00");
    settings.setString(SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE);
    settings.setBool(Session.SETTING_USE_DATA_DICTIONARY, false);
    return factory.create(sessionID, settings);
}
Also used : MessageStore(quickfix.MessageStore) LogFactory(quickfix.LogFactory) DefaultSessionFactory(quickfix.DefaultSessionFactory) MessageStoreFactory(quickfix.MessageStoreFactory) Application(quickfix.Application) Date(java.util.Date) SessionSettings(quickfix.SessionSettings)

Example 2 with MessageStoreFactory

use of quickfix.MessageStoreFactory in project camel by apache.

the class TestSupport method createEngine.

public static QuickfixjEngine createEngine(boolean lazy) throws ConfigError, FieldConvertError, IOException, JMException {
    SessionID sessionID = new SessionID("FIX.4.4:SENDER->TARGET");
    MessageStoreFactory mockMessageStoreFactory = Mockito.mock(MessageStoreFactory.class);
    MessageStore mockMessageStore = Mockito.mock(MessageStore.class);
    Mockito.when(mockMessageStore.getCreationTime()).thenReturn(new Date());
    Mockito.when(mockMessageStoreFactory.create(sessionID)).thenReturn(mockMessageStore);
    SessionSettings settings = new SessionSettings();
    settings.setLong(sessionID, Session.SETTING_HEARTBTINT, 10);
    settings.setString(sessionID, Session.SETTING_START_TIME, "00:00:00");
    settings.setString(sessionID, Session.SETTING_END_TIME, "00:00:00");
    settings.setString(sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE);
    settings.setLong(sessionID, Acceptor.SETTING_SOCKET_ACCEPT_PORT, 8000);
    settings.setBool(sessionID, Session.SETTING_USE_DATA_DICTIONARY, false);
    return new QuickfixjEngine("", settings, mockMessageStoreFactory, Mockito.mock(LogFactory.class), Mockito.mock(MessageFactory.class), lazy);
}
Also used : MessageStore(quickfix.MessageStore) LogFactory(quickfix.LogFactory) MessageFactory(quickfix.MessageFactory) MessageStoreFactory(quickfix.MessageStoreFactory) SessionID(quickfix.SessionID) Date(java.util.Date) SessionSettings(quickfix.SessionSettings)

Example 3 with MessageStoreFactory

use of quickfix.MessageStoreFactory in project camel by apache.

the class QuickfixjEngineTest method useExplicitComponentImplementations.

@Test
public void useExplicitComponentImplementations() throws Exception {
    settings.setString(SLF4JLogFactory.SETTING_EVENT_CATEGORY, "Events");
    settings.setString(sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE);
    writeSettings();
    MessageStoreFactory messageStoreFactory = Mockito.mock(MessageStoreFactory.class);
    LogFactory logFactory = Mockito.mock(LogFactory.class);
    MessageFactory messageFactory = Mockito.mock(MessageFactory.class);
    quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName(), messageStoreFactory, logFactory, messageFactory);
    assertThat(quickfixjEngine.getMessageStoreFactory(), is(messageStoreFactory));
    assertThat(quickfixjEngine.getLogFactory(), is(logFactory));
    assertThat(quickfixjEngine.getMessageFactory(), is(messageFactory));
}
Also used : ScreenLogFactory(quickfix.ScreenLogFactory) LogFactory(quickfix.LogFactory) SLF4JLogFactory(quickfix.SLF4JLogFactory) JdbcLogFactory(quickfix.JdbcLogFactory) FileLogFactory(quickfix.FileLogFactory) MessageFactory(quickfix.MessageFactory) DefaultMessageFactory(quickfix.DefaultMessageFactory) MessageStoreFactory(quickfix.MessageStoreFactory) Test(org.junit.Test)

Example 4 with MessageStoreFactory

use of quickfix.MessageStoreFactory in project camel by apache.

the class QuickfixjEngine method inferMessageStoreFactory.

private MessageStoreFactory inferMessageStoreFactory(SessionSettings settings) throws ConfigError {
    Set<MessageStoreFactory> impliedMessageStoreFactories = new HashSet<MessageStoreFactory>();
    isJdbcStore(settings, impliedMessageStoreFactories);
    isFileStore(settings, impliedMessageStoreFactories);
    isSleepycatStore(settings, impliedMessageStoreFactories);
    if (impliedMessageStoreFactories.size() > 1) {
        throw new ConfigError("Ambiguous message store implied in configuration.");
    }
    MessageStoreFactory messageStoreFactory;
    if (impliedMessageStoreFactories.size() == 1) {
        messageStoreFactory = impliedMessageStoreFactories.iterator().next();
    } else {
        messageStoreFactory = new MemoryStoreFactory();
    }
    LOG.info("Inferring message store factory: {}", messageStoreFactory.getClass().getName());
    return messageStoreFactory;
}
Also used : MemoryStoreFactory(quickfix.MemoryStoreFactory) ConfigError(quickfix.ConfigError) MessageStoreFactory(quickfix.MessageStoreFactory) HashSet(java.util.HashSet)

Aggregations

MessageStoreFactory (quickfix.MessageStoreFactory)4 LogFactory (quickfix.LogFactory)3 Date (java.util.Date)2 MessageFactory (quickfix.MessageFactory)2 MessageStore (quickfix.MessageStore)2 SessionSettings (quickfix.SessionSettings)2 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 Application (quickfix.Application)1 ConfigError (quickfix.ConfigError)1 DefaultMessageFactory (quickfix.DefaultMessageFactory)1 DefaultSessionFactory (quickfix.DefaultSessionFactory)1 FileLogFactory (quickfix.FileLogFactory)1 JdbcLogFactory (quickfix.JdbcLogFactory)1 MemoryStoreFactory (quickfix.MemoryStoreFactory)1 SLF4JLogFactory (quickfix.SLF4JLogFactory)1 ScreenLogFactory (quickfix.ScreenLogFactory)1 SessionID (quickfix.SessionID)1