@Test public void defaultAcceptor() throws Exception { settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE); settings.setLong(sessionID, Acceptor.SETTING_SOCKET_ACCEPT_PORT, 1234); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), nullValue()); assertThat(quickfixjEngine.getAcceptor(), instanceOf(SocketAcceptor.class)); assertDefaultConfiguration(quickfixjEngine); }
@Test public void inferSlf4jLog() throws Exception { settings.setString(SLF4JLogFactory.SETTING_EVENT_CATEGORY, "Events"); settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), notNullValue()); assertThat(quickfixjEngine.getAcceptor(), nullValue()); assertThat(quickfixjEngine.getMessageStoreFactory(), instanceOf(MemoryStoreFactory.class)); assertThat(quickfixjEngine.getLogFactory(), instanceOf(SLF4JLogFactory.class)); assertThat(quickfixjEngine.getMessageFactory(), instanceOf(DefaultMessageFactory.class)); }
@Test public void inferFileLog() throws Exception { settings.setString(FileLogFactory.SETTING_FILE_LOG_PATH, tempdir.toString()); settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), notNullValue()); assertThat(quickfixjEngine.getAcceptor(), nullValue()); assertThat(quickfixjEngine.getMessageStoreFactory(), instanceOf(MemoryStoreFactory.class)); assertThat(quickfixjEngine.getLogFactory(), instanceOf(FileLogFactory.class)); assertThat(quickfixjEngine.getMessageFactory(), instanceOf(DefaultMessageFactory.class)); }
@Test public void inferSleepycatStore() throws Exception { settings.setString(SleepycatStoreFactory.SETTING_SLEEPYCAT_DATABASE_DIR, tempdir.toString()); settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), notNullValue()); assertThat(quickfixjEngine.getAcceptor(), nullValue()); assertThat(quickfixjEngine.getMessageStoreFactory(), instanceOf(SleepycatStoreFactory.class)); assertThat(quickfixjEngine.getLogFactory(), instanceOf(ScreenLogFactory.class)); assertThat(quickfixjEngine.getMessageFactory(), instanceOf(DefaultMessageFactory.class)); }
@Test public void threadPerSessionInitiator() throws Exception { settings.setString( QuickfixjEngine.SETTING_THREAD_MODEL, QuickfixjEngine.ThreadModel.ThreadPerSession.toString()); settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), instanceOf(ThreadedSocketInitiator.class)); assertThat(quickfixjEngine.getAcceptor(), nullValue()); assertDefaultConfiguration(quickfixjEngine); }
@Test public void inferJdbcStoreWithInferredLog() throws Exception { settings.setString(JdbcSetting.SETTING_JDBC_DRIVER, "driver"); settings.setBool(ScreenLogFactory.SETTING_LOG_EVENTS, true); settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), notNullValue()); assertThat(quickfixjEngine.getAcceptor(), nullValue()); assertThat(quickfixjEngine.getMessageStoreFactory(), instanceOf(JdbcStoreFactory.class)); assertThat(quickfixjEngine.getLogFactory(), instanceOf(ScreenLogFactory.class)); assertThat(quickfixjEngine.getMessageFactory(), instanceOf(DefaultMessageFactory.class)); }
@Test public void inferJdbcStoreViaJNDI() throws Exception { // If there is a setting of the LOG_EVENT_TABLE, we should create a jdbcLogFactory for it settings.setString(JdbcSetting.SETTING_JDBC_DS_NAME, "ds_name"); settings.setString(JdbcSetting.SETTING_LOG_EVENT_TABLE, "table"); settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), notNullValue()); assertThat(quickfixjEngine.getAcceptor(), nullValue()); assertThat(quickfixjEngine.getMessageStoreFactory(), instanceOf(JdbcStoreFactory.class)); assertThat(quickfixjEngine.getLogFactory(), instanceOf(JdbcLogFactory.class)); assertThat(quickfixjEngine.getMessageFactory(), instanceOf(DefaultMessageFactory.class)); }
@Test public void minimalInitiatorAndAcceptor() throws Exception { settings.setString( sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE); settings.setLong(sessionID, Acceptor.SETTING_SOCKET_ACCEPT_PORT, 1234); SessionID initiatorSessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "FARGLE", "BARGLE"); settings.setString( initiatorSessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.INITIATOR_CONNECTION_TYPE); TestSupport.setSessionID(settings, initiatorSessionID); writeSettings(); quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName()); assertThat(quickfixjEngine.getInitiator(), notNullValue()); assertThat(quickfixjEngine.getAcceptor(), notNullValue()); assertDefaultConfiguration(quickfixjEngine); }