Message extends FieldMap { public void fromString(String messageData, DataDictionary dd, boolean doValidation) throws InvalidMessage { parse(messageData, dd, dd, doValidation, true); } Message(); protected  Message(int[] fieldOrder);  Message(String string);  Message(String string, boolean validate);  Message(String string, DataDictionary dd);  Message(String string, DataDictionary dd, boolean validate);  Message(String string, DataDictionary sessionDictionary, DataDictionary applicationDictionary, boolean validate); static boolean InitializeXML(String url); @Override Object clone(); @Override String toString(); String toRawString(); int bodyLength(); void headerAddGroup(Group group); void headerReplaceGroup(int num, Group group); Group headerGetGroup(int num, Group group); void headerRemoveGroup(Group group); boolean headerHasGroup(int field); boolean headerHasGroup(int num, int field); boolean headerHasGroup(int num, Group group); boolean headerHasGroup(Group group); void trailerAddGroup(Group group); Group trailerGetGroup(int num, Group group); void trailerReplaceGroup(int num, Group group); void trailerRemoveGroup(Group group); boolean trailerHasGroup(int field); boolean trailerHasGroup(int num, int field); boolean trailerHasGroup(int num, Group group); boolean trailerHasGroup(Group group); String toXML(); String toXML(DataDictionary dataDictionary); final Header getHeader(); final Trailer getTrailer(); boolean isAdmin(); boolean isApp(); @Override boolean isEmpty(); @Override void clear(); @Override void reset(); void reverseRoute(Header header); void fromString(String messageData, DataDictionary dd, boolean doValidation); void fromString(String messageData, DataDictionary dd, boolean doValidation,
            boolean validateChecksum); void fromString(String messageData, DataDictionary sessionDictionary,
            DataDictionary applicationDictionary, boolean doValidation); void fromString(String messageData, DataDictionary sessionDictionary,
            DataDictionary applicationDictionary, boolean doValidation, boolean validateChecksum); void pushBack(StringField field); FieldException getException(); static MsgType identifyType(String message);  }
@Test public void testValidation() throws Exception { final String data = "8=FIX.4.4\0019=309\00135=8\00149=ASX\00156=CL1_FIX44\00134=4\001" + "52=20060324-01:05:58\00117=X-B-WOW-1494E9A0:58BD3F9D-1109\001150=D\00139=0\001" + "11=184271\00138=200\001198=1494E9A0:58BD3F9D\001526=4324\00137=B-WOW-1494E9A0:58BD3F9D\001" + "55=WOW\00154=1\001151=200\00114=0\00140=2\00144=15\00159=1\0016=0\001453=3\001448=AAA35791\001" + "447=D\001452=3\001448=8\001447=D\001452=4\001448=FIX11\001" + "447=D\001452=36\00160=20060320-03:34:29\00110=169\001"; final ExecutionReport executionReport = new ExecutionReport(); final DataDictionary dictionary = DataDictionaryTest.getDictionary(); assertNotNull(dictionary); executionReport.fromString(data, dictionary, true); dictionary.validate(executionReport); }
@Test public void testValidationWithHops() throws Exception { final String data = "8=FIX.4.4\0019=309\00135=8\00149=ASX\00156=CL1_FIX44\00134=4\001" + "52=20060324-01:05:58\00117=X-B-WOW-1494E9A0:58BD3F9D-1109\001150=D\00139=0\00111=184271\001" + "38=200\001198=1494E9A0:58BD3F9D\001526=4324\00137=B-WOW-1494E9A0:58BD3F9D\00155=WOW\00154=1\001" + "151=200\00114=0\00140=2\00144=15\00159=1\0016=0\001453=3\001448=AAA35791\001447=D\001452=3\001" + "448=8\001447=D\001452=4\001448=FIX11\001447=D\001452=36\00160=20060320-03:34:29\00110=169\001"; final ExecutionReport executionReport = new ExecutionReport(); final DataDictionary dictionary = DataDictionaryTest.getDictionary(); assertNotNull(dictionary); executionReport.fromString(data, dictionary, true); final Header.NoHops hops = new Header.NoHops(); hops.set(new HopCompID("FOO")); executionReport.header.addGroup(hops); dictionary.validate(executionReport); }
@Test public void testAppMessageValidation() throws Exception { final String data = "8=FIXT.1.1\0019=234\00135=W\00134=2\00149=ABFX\00152=20080722-16:37:11.234\001" + "56=X2RV1\00155=EUR/USD\001262=CAP0000011\001268=2\001269=0\001270=1.57844\00115=EUR\001" + "271=500000\001272=20080724\001269=1\001270=1.57869\00115=EUR\001271=500000\001272=20080724\00110=097\001"; final MarketDataSnapshotFullRefresh mdsfr = new MarketDataSnapshotFullRefresh(); final DataDictionary sessDictionary = DataDictionaryTest.getDictionary("FIXT11.xml"); final DataDictionary appDictionary = DataDictionaryTest.getDictionary("FIX50.xml"); assertNotNull(sessDictionary); assertNotNull(appDictionary); mdsfr.fromString(data, sessDictionary, appDictionary, true); DataDictionary.validate(mdsfr, sessDictionary, appDictionary); }
@Test public void testAdminMessageValidation() throws Exception { final String data = "8=FIXT.1.1\0019=84\00135=A\00149=EXEC\00156=BANZAI\00134=1\001" + "52=20080811-13:26:12.409\001108=1\001141=Y\00198=0\0011137=7\00110=102\001"; final Logon logon = new Logon(); final DataDictionary sessionDictionary = DataDictionaryTest.getDictionary("FIXT11.xml"); final DataDictionary appDictionary = DataDictionaryTest.getDictionary("FIX50.xml"); assertNotNull(sessionDictionary); assertNotNull(appDictionary); logon.fromString(data, sessionDictionary, appDictionary, true); DataDictionary.validate(logon, sessionDictionary, sessionDictionary); }
@Test public void testMessageGroupCountValidation() throws Exception { final String data = "8=FIX.4.4\0019=222\00135=D\00149=SenderCompId\00156=TargetCompId\00134=37\001" + "52=20070223-22:28:33\00111=183339\00122=8\00138=1\00140=2\00144=12\00148=BHP\00154=2\001" + "55=BHP\00159=1\00160=20060223-22:38:33\001526=3620\00178=0\00179=AllocACC1\00180=1010.1\001" + "79=AllocACC2\00180=2020.2\001453=2\001448=8\001447=D\001452=4\001448=AAA35354\001447=D\001452=3\00110=079\001"; final Message message = new Message(); final DataDictionary dd = DataDictionaryTest.getDictionary(); message.fromString(data, dd, true); try { dd.validate(message); fail("No exception thrown"); } catch (final FieldException e) { final String emsg = e.getMessage(); assertNotNull("No exception message", emsg); assertTrue(emsg.startsWith("Incorrect NumInGroup")); } }
@Test public void testMessageWithMissingChecksumField() throws Exception { String badMessage = "8=FIX.4.4\0019=275\00135=D\00134=3\00149=441000-XXXXX-X-XXXX-001\001" + "52=20131113-10:22:31.567\00156=XXXXX\0011=A1\00111=9fef3663330e209e1bce\00118=H\001" + "22=4\00138=200\00140=M\00148=XX0005519XXXX\00154=1\00155=[N/A]\00158=MassTest\00159=0\001" + "60=20131113-10:22:31.567\001100=XXXX\001526=9fef3663330e209e1bce\001453=1\001" + "448=XXXXXXXX030\001447=D\001452=3610=016\001"; Message msg = new Message(); try { msg.fromString(badMessage, DataDictionaryTest.getDictionary(), true); fail(); } catch (final InvalidMessage e) { final String emsg = e.getMessage(); assertNotNull("No exception message", emsg); assertTrue(emsg.startsWith("Field not found")); } }
@Test public void testRepeatingGroupCountWithUnknownFields() throws Exception { String test = "8=FIX.4.4|9=431|35=d|49=1|34=2|52=20140117-18:20:26.629|56=3|57=21|322=388721|" + "323=4|320=1|393=42|82=1|67=1|711=1|311=780508|309=text|305=8|463=FXXXXX|307=text|542=20140716|" + "436=10.0|9013=1.0|9014=1.0|9017=10|9022=1|9024=1.0|9025=Y|916=20140701|917=20150731|9201=23974|" + "9200=17|9202=text|9300=727|9301=text|9302=text|9303=text|998=text|9100=text|9101=text|9085=text|" + "9083=0|9084=0|9061=579|9062=text|9063=text|9032=10.0|9002=F|9004=780415|9005=780503|10=223|"; DataDictionary dictionary = new DataDictionary(DataDictionaryTest.getDictionary()); Message message = new Message(); message.fromString(test.replaceAll("\\|", "\001"), dictionary, true); Group group = message.getGroup(1, 711); String underlyingSymbol = group.getString(311); assertEquals("780508", underlyingSymbol); }