Search in sources :

Example 16 with SessionID

use of quickfix.SessionID 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();
    }
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) NoHops(quickfix.fix44.Message.Header.NoHops) Message(quickfix.Message) SessionID(quickfix.SessionID) Test(org.junit.Test)

Example 17 with SessionID

use of quickfix.SessionID 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));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) Message(quickfix.Message) SessionID(quickfix.SessionID) Test(org.junit.Test)

Example 18 with SessionID

use of quickfix.SessionID in project camel by apache.

the class QuickfixjConvertersTest method convertToExchangeWithNullMessage.

@Test
public void convertToExchangeWithNullMessage() {
    SessionID sessionID = new SessionID("FIX.4.0", "FOO", "BAR");
    QuickfixjEndpoint endpoint = new QuickfixjEndpoint(null, "", new QuickfixjComponent());
    Exchange exchange = QuickfixjConverters.toExchange(endpoint, sessionID, null, 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(exchange.getIn().getHeader(QuickfixjEndpoint.MESSAGE_TYPE_KEY), is(nullValue()));
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) SessionID(quickfix.SessionID) Test(org.junit.Test)

Example 19 with SessionID

use of quickfix.SessionID 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();
    }
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) NoHops(quickfix.fix44.Message.Header.NoHops) Message(quickfix.Message) DataDictionary(quickfix.DataDictionary) SessionID(quickfix.SessionID) Test(org.junit.Test)

Example 20 with SessionID

use of quickfix.SessionID 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();
    }
}
Also used : Exchange(org.apache.camel.Exchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) DefaultExchange(org.apache.camel.impl.DefaultExchange) NoHops(quickfix.fix44.Message.Header.NoHops) Message(quickfix.Message) SessionID(quickfix.SessionID) Test(org.junit.Test)

Aggregations

SessionID (quickfix.SessionID)27 Test (org.junit.Test)13 Message (quickfix.Message)13 Session (quickfix.Session)7 Exchange (org.apache.camel.Exchange)6 SessionSettings (quickfix.SessionSettings)6 DefaultExchange (org.apache.camel.impl.DefaultExchange)5 CountDownLatch (java.util.concurrent.CountDownLatch)4 DataDictionary (quickfix.DataDictionary)4 ArrayList (java.util.ArrayList)3 NoHops (quickfix.fix44.Message.Header.NoHops)3 IOException (java.io.IOException)2 URL (java.net.URL)2 URLClassLoader (java.net.URLClassLoader)2 Properties (java.util.Properties)2 Before (org.junit.Before)2 BeginString (quickfix.field.BeginString)2 Email (quickfix.fix42.Email)2 MalformedURLException (java.net.MalformedURLException)1 Date (java.util.Date)1