Search in sources :

Example 6 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXTransportSenderTest method testFIXTransportSenderSendMessage.

@Test()
public void testFIXTransportSenderSendMessage() throws Exception {
    String BEGIN_STRING = "FIX.4.1";
    String SENDER_ID = "BANZAI";
    String TARGET_ID = "SYNAPSE";
    int SEQ_NUM = 5;
    String SYMBOL = "APACHE";
    String CLORD_ID = "12345";
    String CHECKSUM = "67890";
    String TX_DATE = new Date().toString();
    String SESSION_ID = "FIX.4.1:BANZAI->SYNAPSE";
    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));
    message.getTrailer().setField(new CheckSum(CHECKSUM));
    MessageContext msgCtx = new MessageContext();
    msgCtx.setProperty(FIXConstants.FIX_SERVICE_NAME, "sampleService");
    Map trpHeaders = new HashMap();
    trpHeaders.put(FIXConstants.FIX_MESSAGE_APPLICATION, "sampleApplication");
    msgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, trpHeaders);
    FIXUtils.getInstance().setSOAPEnvelope(message, SEQ_NUM, SESSION_ID, msgCtx);
    OutTransportInfo info = new FIXOutTransportInfo("fix://dummyEPR");
    FIXTransportSender spy = PowerMockito.spy(new FIXTransportSender());
    PowerMockito.doReturn(true).when(spy, "sendUsingEPR", anyString(), anyString(), any(), anyString(), anyInt(), any());
    spy.sendMessage(msgCtx, "fix://dummyEPR", info);
    PowerMockito.verifyPrivate(spy, times(1)).invoke("sendUsingEPR", anyString(), anyString(), any(), anyString(), anyInt(), any());
}
Also used : NewOrderSingle(quickfix.fix41.NewOrderSingle) BeginString(quickfix.field.BeginString) SenderCompID(quickfix.field.SenderCompID) Message(quickfix.Message) HashMap(java.util.HashMap) Symbol(quickfix.field.Symbol) TargetCompID(quickfix.field.TargetCompID) ClOrdID(quickfix.field.ClOrdID) TradeOriginationDate(quickfix.field.TradeOriginationDate) BeginString(quickfix.field.BeginString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) MsgSeqNum(quickfix.field.MsgSeqNum) Date(java.util.Date) TradeOriginationDate(quickfix.field.TradeOriginationDate) OutTransportInfo(org.apache.axis2.transport.OutTransportInfo) CheckSum(quickfix.field.CheckSum) MessageContext(org.apache.axis2.context.MessageContext) HashMap(java.util.HashMap) Map(java.util.Map) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with SenderCompID

use of quickfix.field.SenderCompID 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 SenderCompID

use of quickfix.field.SenderCompID 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 SenderCompID

use of quickfix.field.SenderCompID 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)

Example 10 with SenderCompID

use of quickfix.field.SenderCompID in project wso2-synapse by wso2.

the class FIXIncomingMessageHandler method toAdmin.

/**
 * This callback provides Synapse with a peek at the administrative messages
 * that are being sent from your FIX engine to the counter party. This is
 * normally not useful for an application however it is provided for any
 * logging one may wish to do.
 *
 * @param message   QuickFIX message
 * @param sessionID QuickFIX session ID
 */
public void toAdmin(Message message, SessionID sessionID) {
    if (log.isDebugEnabled()) {
        StringBuffer sb = new StringBuffer();
        try {
            sb.append("Sending admin level FIX message to ").append(message.getHeader().getField(new TargetCompID()).getValue());
            sb.append("\nMessage Type: ").append(message.getHeader().getField(new MsgType()).getValue());
            sb.append("\nMessage Sequence Number: ").append(message.getHeader().getField(new MsgSeqNum()).getValue());
            sb.append("\nSender ID: ").append(message.getHeader().getField(new SenderCompID()).getValue());
        } catch (FieldNotFound e) {
            sb.append("Sending admin level FIX message...");
            log.warn("One or more required fields are not found in the response message", e);
        }
        log.debug(sb.toString());
        if (log.isTraceEnabled()) {
            log.trace("Message: " + message.toString());
        }
    }
    try {
        // Before FIX server sends (35=A) admin login message get username/password values from proxy configuration
        if (message.getHeader().getField(new StringField(FIXConstants.FIX_MESSAGE_TYPE)).getValue().equals(FIXConstants.LOGON)) {
            Parameter userName = service.getParameter(FIXConstants.FIX_USERNAME);
            Parameter passWord = service.getParameter(FIXConstants.FIX_PASSWORD);
            if (userName != null && passWord != null) {
                message.setString(FIXConstants.USERNAME_TAG, userName.getValue().toString());
                message.setString(FIXConstants.PASSWORD_TAG, passWord.getValue().toString());
            }
            if (log.isDebugEnabled()) {
                log.debug("Username:" + userName + " or password:" + passWord + "from proxy configuration..");
            }
        }
    } catch (FieldNotFound e) {
        log.error("One or more required fields are not found in the response message", e);
    }
    if (eventHandler != null) {
        eventHandler.toAdmin(this, message, sessionID);
    }
}
Also used : SenderCompID(quickfix.field.SenderCompID) TargetCompID(quickfix.field.TargetCompID) Parameter(org.apache.axis2.description.Parameter) MsgType(quickfix.field.MsgType) MsgSeqNum(quickfix.field.MsgSeqNum)

Aggregations

SenderCompID (quickfix.field.SenderCompID)10 TargetCompID (quickfix.field.TargetCompID)10 MsgSeqNum (quickfix.field.MsgSeqNum)8 Test (org.junit.Test)6 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)6 BeginString (quickfix.field.BeginString)6 MsgType (quickfix.field.MsgType)6 Message (quickfix.Message)5 SessionID (quickfix.SessionID)5 NewOrderSingle (quickfix.fix41.NewOrderSingle)5 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 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)3 HashMap (java.util.HashMap)2 MessageContext (org.apache.axis2.context.MessageContext)2 Parameter (org.apache.axis2.description.Parameter)2 Method (java.lang.reflect.Method)1 Date (java.util.Date)1