Search in sources :

Example 6 with NewOrderSingle

use of quickfix.fix41.NewOrderSingle in project wso2-synapse by wso2.

the class MessageTest method testAdvancedFIXMessage.

public void testAdvancedFIXMessage() throws Exception {
    Message message = new NewOrderSingle();
    message.getHeader().setField(new BeginString(BEGIN_STRING));
    message.getHeader().setField(new SenderCompID(SENDER_ID));
    message.getHeader().setField(new TargetCompID(TARGET_ID));
    message.getHeader().setField(new MsgSeqNum(SEQ_NUM));
    message.setField(new Symbol(SYMBOL));
    message.setField(new ClOrdID(CLORD_ID));
    message.setField(new TradeOriginationDate(TX_DATE));
    Group g1 = new Group(NoAllocs.FIELD, AllocAccount.FIELD);
    g1.setField(new AllocAccount("ABC"));
    g1.setField(new IndividualAllocID("PQR"));
    message.addGroup(g1);
    Group g2 = new Group(NoAllocs.FIELD, AllocAccount.FIELD);
    g2.setField(new AllocAccount("MNO"));
    g2.setField(new IndividualAllocID("XYZ"));
    message.addGroup(g2);
    message.getTrailer().setField(new CheckSum(CHECKSUM));
    MessageContext msgCtx = new MessageContext();
    FIXUtils.getInstance().setSOAPEnvelope(message, SEQ_NUM, SESSION_ID, msgCtx);
    String result = msgCtx.getEnvelope().getBody().getFirstElement().toString();
    String expected = "<message inSession=\"" + SESSION_ID + "\" counter=\"" + SEQ_NUM + "\">" + "<header>" + "<field id=\"" + BeginString.FIELD + "\">" + BEGIN_STRING + "</field>" + "<field id=\"" + MsgSeqNum.FIELD + "\">" + SEQ_NUM + "</field>" + "<field id=\"" + MsgType.FIELD + "\">" + NewOrderSingle.MSGTYPE + "</field>" + "<field id=\"" + SenderCompID.FIELD + "\">" + SENDER_ID + "</field>" + "<field id=\"" + TargetCompID.FIELD + "\">" + TARGET_ID + "</field>" + "</header>" + "<body>" + "<field id=\"" + ClOrdID.FIELD + "\">" + CLORD_ID + "</field>" + "<field id=\"" + Symbol.FIELD + "\">" + SYMBOL + "</field>" + "<field id=\"" + NoAllocs.FIELD + "\">2</field>" + "<field id=\"" + TradeOriginationDate.FIELD + "\">" + TX_DATE + "</field>" + "<groups id=\"" + NoAllocs.FIELD + "\">" + "<group>" + "<field id=\"" + AllocAccount.FIELD + "\">ABC</field>" + "<field id=\"" + IndividualAllocID.FIELD + "\">PQR</field>" + "</group>" + "<group>" + "<field id=\"" + AllocAccount.FIELD + "\">MNO</field>" + "<field id=\"" + IndividualAllocID.FIELD + "\">XYZ</field>" + "</group>" + "</groups>" + "</body>" + "<trailer>" + "<field id=\"" + CheckSum.FIELD + "\">" + CHECKSUM + "</field>" + "</trailer>" + "</message>";
    assertXMLEqual(expected, AXIOMUtil.stringToOM(result).toString());
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) Group(quickfix.Group) Message(quickfix.Message) MessageContext(org.apache.axis2.context.MessageContext)

Example 7 with NewOrderSingle

use of quickfix.fix41.NewOrderSingle in project wso2-synapse by wso2.

the class FIXIncomingMessageHandlerTest method testFromAdmin.

@Test
public void testFromAdmin() throws Exception {
    SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
    Message message = new NewOrderSingle();
    message.getHeader().setField(new BeginString("FIX.4.1"));
    message.getHeader().setField(new SenderCompID("SYNAPSE"));
    message.getHeader().setField(new TargetCompID("BANZAI"));
    message.getHeader().setField(new MsgSeqNum(1));
    message.getHeader().setField(new MsgType("A"));
    ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
    WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
    FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, service, true);
    handler.fromAdmin(message, id);
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Message(quickfix.Message) TargetCompID(quickfix.field.TargetCompID) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) SessionID(quickfix.SessionID) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 8 with NewOrderSingle

use of quickfix.fix41.NewOrderSingle in project wso2-synapse by wso2.

the class FIXIncomingMessageHandlerTest method testToAdmin.

@Test
public void testToAdmin() throws Exception {
    initMocks(this);
    SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
    Message message = new NewOrderSingle();
    message.getHeader().setField(new BeginString("FIX.4.1"));
    message.getHeader().setField(new SenderCompID("SYNAPSE"));
    message.getHeader().setField(new TargetCompID("BANZAI"));
    message.getHeader().setField(new MsgSeqNum(1));
    message.getHeader().setField(new MsgType("A"));
    PowerMockito.when(service.getParameter(FIXConstants.FIX_USERNAME)).thenReturn(new Parameter(FIXConstants.FIX_USERNAME, "wos2"));
    PowerMockito.when(service.getParameter(FIXConstants.FIX_PASSWORD)).thenReturn(new Parameter(FIXConstants.FIX_PASSWORD, "wos2"));
    ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
    WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
    FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, service, true);
    handler.toAdmin(message, id);
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Message(quickfix.Message) TargetCompID(quickfix.field.TargetCompID) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) Parameter(org.apache.axis2.description.Parameter) SessionID(quickfix.SessionID) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with NewOrderSingle

use of quickfix.fix41.NewOrderSingle in project wso2-synapse by wso2.

the class FIXIncomingMessageHandlerTest method testToApp.

@Test
public void testToApp() throws Exception {
    SessionID id = new SessionID(new BeginString("FIX.4.1"), new SenderCompID("SYNAPSE"), new TargetCompID("BANZAI"), "FIX.4.1:SYNAPSE->BANZAI");
    Message message = new NewOrderSingle();
    message.getHeader().setField(new BeginString("FIX.4.1"));
    message.getHeader().setField(new SenderCompID("SYNAPSE"));
    message.getHeader().setField(new TargetCompID("BANZAI"));
    message.getHeader().setField(new MsgSeqNum(1));
    message.getHeader().setField(new MsgType("A"));
    ConfigurationContext cfgCtx = new ConfigurationContext(new AxisConfiguration());
    WorkerPool pool = new NativeWorkerPool(3, 4, 10, 10, "name", "id");
    FIXIncomingMessageHandler handler = new FIXIncomingMessageHandler(cfgCtx, pool, service, true);
    handler.toApp(message, id);
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Message(quickfix.Message) TargetCompID(quickfix.field.TargetCompID) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum) WorkerPool(org.apache.axis2.transport.base.threads.WorkerPool) NativeWorkerPool(org.apache.axis2.transport.base.threads.NativeWorkerPool) SessionID(quickfix.SessionID) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

Message (quickfix.Message)7 NewOrderSingle (quickfix.fix41.NewOrderSingle)7 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 BeginString (quickfix.field.BeginString)5 SenderCompID (quickfix.field.SenderCompID)5 TargetCompID (quickfix.field.TargetCompID)5 MessageContext (org.apache.axis2.context.MessageContext)4 SessionID (quickfix.SessionID)4 MsgSeqNum (quickfix.field.MsgSeqNum)4 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)3 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)3 NativeWorkerPool (org.apache.axis2.transport.base.threads.NativeWorkerPool)3 WorkerPool (org.apache.axis2.transport.base.threads.WorkerPool)3 MsgType (quickfix.field.MsgType)3 Date (java.util.Date)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2 ClOrdID (quickfix.field.ClOrdID)2 Symbol (quickfix.field.Symbol)2 NewOrderSingle (quickfix.fix42.NewOrderSingle)2