use of quickfix.Message in project camel by apache.
the class QuickfixjConvertersTest method convertMessageWithRepeatingGroupsUsingExchangeDictionaryResource.
@Test
public void convertMessageWithRepeatingGroupsUsingExchangeDictionaryResource() throws Exception {
SessionID sessionID = new SessionID("FIX.4.4", "FOO", "BAR");
createSession(sessionID);
try {
String data = "8=FIX.4.4\0019=40\00135=A\001" + "627=2\001628=FOO\001628=BAR\001" + "98=0\001384=2\001372=D\001385=R\001372=8\001385=S\00110=230\001";
Exchange exchange = new DefaultExchange(context);
exchange.setProperty(QuickfixjEndpoint.DATA_DICTIONARY_KEY, "FIX44.xml");
exchange.getIn().setBody(data);
Message message = exchange.getIn().getBody(Message.class);
NoHops hop = new NoHops();
message.getHeader().getGroup(1, hop);
assertEquals("FOO", hop.getString(HopCompID.FIELD));
message.getHeader().getGroup(2, hop);
assertEquals("BAR", hop.getString(HopCompID.FIELD));
} finally {
quickfixjEngine.stop();
}
}
use of quickfix.Message in project camel by apache.
the class QuickfixjConvertersTest method convertToExchange.
@Test
public void convertToExchange() {
SessionID sessionID = new SessionID("FIX.4.0", "FOO", "BAR");
QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent());
Message message = new Message();
message.getHeader().setString(MsgType.FIELD, MsgType.ORDER_SINGLE);
Exchange exchange = QuickfixjConverters.toExchange(endpoint, sessionID, message, QuickfixjEventCategory.AppMessageSent);
assertThat((SessionID) exchange.getIn().getHeader(QuickfixjEndpoint.SESSION_ID_KEY), is(sessionID));
assertThat((QuickfixjEventCategory) exchange.getIn().getHeader(QuickfixjEndpoint.EVENT_CATEGORY_KEY), is(QuickfixjEventCategory.AppMessageSent));
assertThat((String) exchange.getIn().getHeader(QuickfixjEndpoint.MESSAGE_TYPE_KEY), is(MsgType.ORDER_SINGLE));
}
use of quickfix.Message in project camel by apache.
the class QuickfixjConvertersTest method convertMessageWithRepeatingGroupsUsingExchangeDictionary.
@Test
public void convertMessageWithRepeatingGroupsUsingExchangeDictionary() throws Exception {
SessionID sessionID = new SessionID("FIX.4.4", "FOO", "BAR");
createSession(sessionID);
try {
String data = "8=FIX.4.4\0019=40\00135=A\001" + "627=2\001628=FOO\001628=BAR\001" + "98=0\001384=2\001372=D\001385=R\001372=8\001385=S\00110=230\001";
Exchange exchange = new DefaultExchange(context);
exchange.setProperty(QuickfixjEndpoint.DATA_DICTIONARY_KEY, new DataDictionary("FIX44.xml"));
exchange.getIn().setBody(data);
Message message = exchange.getIn().getBody(Message.class);
NoHops hop = new NoHops();
message.getHeader().getGroup(1, hop);
assertEquals("FOO", hop.getString(HopCompID.FIELD));
message.getHeader().getGroup(2, hop);
assertEquals("BAR", hop.getString(HopCompID.FIELD));
} finally {
quickfixjEngine.stop();
}
}
use of quickfix.Message in project camel by apache.
the class QuickfixjConvertersTest method convertMessageWithRepeatingGroupsUsingSessionID.
@Test
public void convertMessageWithRepeatingGroupsUsingSessionID() throws Exception {
SessionID sessionID = new SessionID("FIX.4.4", "FOO", "BAR");
createSession(sessionID);
try {
String data = "8=FIX.4.4\0019=40\00135=A\001" + "627=2\001628=FOO\001628=BAR\001" + "98=0\001384=2\001372=D\001385=R\001372=8\001385=S\00110=230\001";
Exchange exchange = new DefaultExchange(context);
exchange.getIn().setHeader(QuickfixjEndpoint.SESSION_ID_KEY, sessionID);
exchange.getIn().setBody(data);
Message message = exchange.getIn().getBody(Message.class);
NoHops hop = new NoHops();
message.getHeader().getGroup(1, hop);
assertEquals("FOO", hop.getString(HopCompID.FIELD));
message.getHeader().getGroup(2, hop);
assertEquals("BAR", hop.getString(HopCompID.FIELD));
} finally {
quickfixjEngine.stop();
}
}
use of quickfix.Message in project camel by apache.
the class QuickfixjEngineTest method doApplicationMessageEventsTest.
private void doApplicationMessageEventsTest(SessionID acceptorSessionID, SessionID initiatorSessionID, QuickfixjEngine quickfixjEngine) throws SessionNotFound, InterruptedException, FieldNotFound {
final List<EventRecord> events = new ArrayList<EventRecord>();
final CountDownLatch messageLatch = new CountDownLatch(1);
QuickfixjEventListener messageListener = new QuickfixjEventListener() {
@Override
public synchronized void onEvent(QuickfixjEventCategory eventCategory, SessionID sessionID, Message message) {
EventRecord event = new EventRecord(eventCategory, sessionID, message);
events.add(event);
if (eventCategory == QuickfixjEventCategory.AppMessageReceived) {
messageLatch.countDown();
}
}
};
quickfixjEngine.addEventListener(messageListener);
Email email = TestSupport.createEmailMessage("Test");
Session.sendToTarget(email, initiatorSessionID);
assertTrue("Application message not received", messageLatch.await(5000, TimeUnit.MILLISECONDS));
quickfixjEngine.removeEventListener(messageListener);
assertThat(events.size(), is(2));
EventRecord sendEvent = new EventRecord(QuickfixjEventCategory.AppMessageSent, initiatorSessionID, new Message());
assertTrue(events.contains(sendEvent));
int sendEventIndex = events.indexOf(sendEvent);
assertThat(events.get(sendEventIndex).message.getHeader().getString(MsgType.FIELD), is(MsgType.EMAIL));
EventRecord receiveEvent = new EventRecord(QuickfixjEventCategory.AppMessageReceived, acceptorSessionID, new Message());
assertTrue(events.contains(receiveEvent));
int receiveEventIndex = events.indexOf(receiveEvent);
assertThat(events.get(receiveEventIndex).message.getHeader().getString(MsgType.FIELD), is(MsgType.EMAIL));
}
Aggregations