关闭

fix协议封装挑战-测试代码

1045人阅读 评论(0) 收藏 举报
分类:

初步测试工具采用香港证券交易所的一个离线测试工具,测试数据包正确性。

工具名称叫做OCG Simulator 1.2.1。

测试代码比如:

TC_QM_03测试案例:

package cs.test;

import java.text.SimpleDateFormat;
import java.util.Date;

import cs.mina.SeqenceNum;
import cs.mina.codec.msg.BaseMsg;
import cs.mina.codec.msg.InstrumentTag;
import cs.mina.codec.msg.PartiesTag;
import cs.mina.codec.msg.Party;
import cs.mina.codec.msg.QuotCxlEntriesGrp;
import cs.mina.codec.msg.QuotCxlEntriesGrpTag;
import cs.mina.codec.msg.QuoteCancelMsg;
import cs.mina.codec.msg.QuoteMsg;
import cs.mina.codec.msg.ValueChecksGrp;
import cs.mina.codec.msg.ValueChecksGrpTag;

/*
 *@author(huangxiaoping)
 *@date 2013-12-2
 */
public class TC_QM_03Test {
	public static BaseMsg createMsg1(){
		QuoteMsg msg=new QuoteMsg();
		msg.getHeadEntity().getMsgSeqNum().setTagValue(SeqenceNum.getSeqence()+"");
		msg.getParties().setTagValue("1");
	   	 Party party=new Party();
	   	 party.getPartyID().setTagValue("1200");
	   	 party.getPartyIDSource().setTagValue("D");
	   	 party.getPartyRole().setTagValue("1");
	   	 ((PartiesTag)msg.getParties()).getChildren().add(party);
	   	((InstrumentTag)msg.getInstrument()).getSecurityID().setTagValue("40");
	   	 ((InstrumentTag)msg.getInstrument()).getSecurityIDSource().setTagValue("8");
	   	 ((InstrumentTag)msg.getInstrument()).getSecurityExchange().setTagValue("XHKG");
	   	 msg.getBidID().setTagValue("94");
	   	 msg.getOfferID().setTagValue("95");
	   	 msg.getQuoteType().setTagValue("1");
	   	 //msg.getSide().setTagValue("1");
	   	 msg.getBidSize().setTagValue("5000");
	   	 msg.getOfferSize().setTagValue("6000");
	   	 msg.getBidPx().setTagValue("15");
	   	 msg.getOfferPx().setTagValue("15.1");
	   	 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HH:mm:ss.SSS"); 
	   	 msg.getTransactTime().setTagValue(sdf.format(new Date()));
	   	 msg.getValueChecksGrp().setTagValue("2");
	     ValueChecksGrp valueChecksGrp=new ValueChecksGrp();
	     valueChecksGrp.getValueCheckType().setTagValue("1");
	     valueChecksGrp.getValueCheckAction().setTagValue("0");
	     ((ValueChecksGrpTag)msg.getValueChecksGrp()).getChildren().add(valueChecksGrp);
	     ValueChecksGrp valueChecksGrp2=new ValueChecksGrp();
	     valueChecksGrp2.getValueCheckType().setTagValue("2");
	     valueChecksGrp2.getValueCheckAction().setTagValue("0");
	     ((ValueChecksGrpTag)msg.getValueChecksGrp()).getChildren().add(valueChecksGrp2);
	     return msg;
	 }
	
	public static BaseMsg createMsg2(){
		QuoteCancelMsg msg=new QuoteCancelMsg();
		msg.getHeadEntity().getMsgSeqNum().setTagValue(SeqenceNum.getSeqence()+"");
		msg.getQuoteMsgID().setTagValue("96");
		msg.getQuoteCancelType().setTagValue("1");
		msg.getParties().setTagValue("1");
	   	 Party party=new Party();
	   	 party.getPartyID().setTagValue("1200");
	   	 party.getPartyIDSource().setTagValue("D");
	   	 party.getPartyRole().setTagValue("1");
	   	 ((PartiesTag)msg.getParties()).getChildren().add(party);
	   	 ((QuotCxlEntriesGrpTag)msg.getQuotCxlEntriesGrp()).setTagValue("1");
	   	QuotCxlEntriesGrp quotCxlEntriesGrp=new QuotCxlEntriesGrp();
	   	((InstrumentTag)quotCxlEntriesGrp.getInstrument()).getSecurityID().setTagValue("40");
	   	((InstrumentTag)quotCxlEntriesGrp.getInstrument()).getSecurityIDSource().setTagValue("8");
	   	((InstrumentTag)quotCxlEntriesGrp.getInstrument()).getSecurityExchange().setTagValue("XHKG");
	   	((QuotCxlEntriesGrpTag)msg.getQuotCxlEntriesGrp()).getChildren().add(quotCxlEntriesGrp);
	     return msg;
	 }
}
测试数据1;
发送1:
8=FIXT.1.1_9=221_35=S_49=CO99999901_56=HKEXCO_34=2_52=20131202-10:34:51.156_453=1_448=1200_447=D_452=1_48=40_22=8_207=XHKG_390=94_1867=95_537=1_134=5000_135=6000_132=15_133=15.1_60=20131202-10:34:51.157_1868=2_1869=1_1870=0_1869=2_1870=0_10=057_
响应1:
8=FIXT.1.1_9=236_35=8_49=HKEXCO_56=CO99999901_34=2_52=20131202-02:34:51.568_1128=9_11=94_14=0_17=23451564_150=0_151=5000_1093=2_1090=1_453=1_448=1200_447=D_452=1_37=33451464_38=5000_39=0_40=2_44=15_207=XHKG_48=40_22=8_54=1_59=0_60=20131202-02:34:51.565_10=152_

8=FIXT.1.1_9=238_35=8_49=HKEXCO_56=CO99999901_34=3_52=20131202-02:34:51.777_1128=9_11=95_14=0_17=23451772_150=0_151=6000_1093=2_1090=1_453=1_448=1200_447=D_452=1_37=33451670_38=6000_39=0_40=2_44=15.1_207=XHKG_48=40_22=8_54=2_59=0_60=20131202-02:34:51.773_10=001_
发送2:
8=FIXT.1.1_9=126_35=Z_49=CO99999901_56=HKEXCO_34=3_52=20131202-10:35:11.577_1166=96_298=1_453=1_448=1200_447=D_452=1_295=1_48=40_22=8_207=XHKG_10=231_
响应2:
8=FIXT.1.1_9=232_35=8_49=HKEXCO_56=CO99999901_34=5_52=20131202-02:35:11.906_1128=9_11=96_14=0_17=23511901_150=4_151=0_1090=1_453=1_448=1200_447=D_452=1_37=33451464_38=5000_39=4_40=2_41=94_44=15_207=XHKG_48=40_22=8_54=1_59=0_60=20131202-02:35:11.902_10=200_
8=FIXT.1.1_9=234_35=8_49=HKEXCO_56=CO99999901_34=6_52=20131202-02:35:12.012_1128=9_11=96_14=0_17=23512007_150=4_151=0_1090=1_453=1_448=1200_447=D_452=1_37=33451670_38=6000_39=4_40=2_41=95_44=15.1_207=XHKG_48=40_22=8_54=2_59=0_60=20131202-02:35:12.008_10=029_



0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:599115次
    • 积分:8626
    • 等级:
    • 排名:第2212名
    • 原创:289篇
    • 转载:332篇
    • 译文:1篇
    • 评论:122条
    博客专栏
    文章分类
    最新评论