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());
}
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);
}
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);
}
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);
}
Aggregations