use of quickfix.SessionSettings in project camel by apache.
the class QuickfixjEngineTest method setUp.
@Before
public void setUp() throws Exception {
settingsFile = File.createTempFile("quickfixj_test_", ".cfg");
tempdir = settingsFile.getParentFile();
URL[] urls = new URL[] { tempdir.toURI().toURL() };
contextClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader testClassLoader = new URLClassLoader(urls, contextClassLoader);
Thread.currentThread().setContextClassLoader(testClassLoader);
sessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "FOO", "BAR");
settings = new SessionSettings();
settings.setString(Acceptor.SETTING_SOCKET_ACCEPT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
settings.setString(Initiator.SETTING_SOCKET_CONNECT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
settings.setBool(Session.SETTING_USE_DATA_DICTIONARY, false);
settings.setBool(QuickfixjEngine.SETTING_USE_JMX, false);
TestSupport.setSessionID(settings, sessionID);
}
use of quickfix.SessionSettings in project camel by apache.
the class QuickfixjSpringTest method configureInSpring.
@Test
public void configureInSpring() throws Exception {
if (isJava16()) {
// cannot test on java 1.6
return;
}
SessionID sessionID = new SessionID("FIX.4.2:INITIATOR->ACCEPTOR");
QuickfixjConfiguration configuration = context.getRegistry().lookupByNameAndType("quickfixjConfiguration", QuickfixjConfiguration.class);
SessionSettings springSessionSettings = configuration.createSessionSettings();
Properties sessionProperties = springSessionSettings.getSessionProperties(sessionID, true);
assertThat(sessionProperties.get("ConnectionType").toString(), CoreMatchers.is("initiator"));
assertThat(sessionProperties.get("SocketConnectProtocol").toString(), CoreMatchers.is("VM_PIPE"));
QuickfixjComponent component = context.getComponent("quickfix", QuickfixjComponent.class);
assertThat(component.isLazyCreateEngines(), is(false));
QuickfixjEngine engine = component.getEngines().values().iterator().next();
assertThat(engine.isInitialized(), is(true));
QuickfixjComponent lazyComponent = context.getComponent("lazyQuickfix", QuickfixjComponent.class);
assertThat(lazyComponent.isLazyCreateEngines(), is(true));
QuickfixjEngine lazyEngine = lazyComponent.getEngines().values().iterator().next();
assertThat(lazyEngine.isInitialized(), is(false));
assertThat(engine.getMessageFactory(), is(instanceOf(CustomMessageFactory.class)));
}
use of quickfix.SessionSettings in project camel by apache.
the class QuickfixjComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
// Look up the engine instance based on the settings file ("remaining")
QuickfixjEngine engine;
synchronized (engineInstancesLock) {
QuickfixjEndpoint endpoint = endpoints.get(uri);
if (endpoint == null) {
engine = engines.get(remaining);
if (engine == null) {
engine = provisionalEngines.get(remaining);
}
if (engine == null) {
QuickfixjConfiguration configuration = configurations.get(remaining);
SessionSettings settings;
if (configuration != null) {
settings = configuration.createSessionSettings();
} else {
settings = QuickfixjEngine.loadSettings(remaining);
}
Boolean lazyCreateEngineForEndpoint = super.getAndRemoveParameter(parameters, PARAMETER_LAZY_CREATE_ENGINE, Boolean.TYPE);
if (lazyCreateEngineForEndpoint == null) {
lazyCreateEngineForEndpoint = isLazyCreateEngines();
}
engine = new QuickfixjEngine(uri, settings, messageStoreFactory, logFactory, messageFactory, lazyCreateEngineForEndpoint);
// automatic later when CamelContext has been started using the StartupListener
if (getCamelContext().getStatus().isStarted()) {
startQuickfixjEngine(engine);
engines.put(remaining, engine);
} else {
// engines to be started later
provisionalEngines.put(remaining, engine);
}
}
endpoint = new QuickfixjEndpoint(engine, uri, this);
endpoint.setConfigurationName(remaining);
endpoint.setLazyCreateEngine(engine.isLazy());
engine.addEventListener(endpoint);
endpoints.put(uri, endpoint);
}
return endpoint;
}
}
use of quickfix.SessionSettings in project camel by apache.
the class QuickfixjComponentTest method setUp.
@Before
public void setUp() throws Exception {
settingsFile = File.createTempFile("quickfixj_test_", ".cfg");
settingsFile2 = File.createTempFile("quickfixj_test2_", ".cfg");
tempdir = settingsFile.getParentFile();
tempdir2 = settingsFile.getParentFile();
URL[] urls = new URL[] { tempdir.toURI().toURL(), tempdir2.toURI().toURL() };
sessionID = new SessionID(FixVersions.BEGINSTRING_FIX44, "FOO", "BAR");
settings = new SessionSettings();
settings.setString(Acceptor.SETTING_SOCKET_ACCEPT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
settings.setString(Initiator.SETTING_SOCKET_CONNECT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
settings.setBool(Session.SETTING_USE_DATA_DICTIONARY, false);
setSessionID(settings, sessionID);
contextClassLoader = Thread.currentThread().getContextClassLoader();
ClassLoader testClassLoader = new URLClassLoader(urls, contextClassLoader);
Thread.currentThread().setContextClassLoader(testClassLoader);
}
use of quickfix.SessionSettings in project camel by apache.
the class QuickfixjConvertersTest method createSession.
private void createSession(SessionID sessionID) throws IOException, ConfigError, FieldConvertError, JMException, Exception {
SessionSettings settings = new SessionSettings();
settings.setString(Acceptor.SETTING_SOCKET_ACCEPT_PROTOCOL, ProtocolFactory.getTypeString(ProtocolFactory.VM_PIPE));
settings.setString(sessionID, SessionFactory.SETTING_CONNECTION_TYPE, SessionFactory.ACCEPTOR_CONNECTION_TYPE);
settings.setLong(sessionID, Acceptor.SETTING_SOCKET_ACCEPT_PORT, 1234);
TestSupport.setSessionID(settings, sessionID);
TestSupport.writeSettings(settings, settingsFile);
quickfixjEngine = new QuickfixjEngine("quickfix:test", settingsFile.getName());
quickfixjEngine.start();
}
Aggregations