Message extends FieldMap { public void fromString(String messageData, DataDictionary dd, boolean doValidation) throws InvalidMessage { parse(messageData, dd, dd, doValidation); } 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); static boolean InitializeXML(String url); @Override Object clone(); @Override String toString(); 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(); void reverseRoute(Header header); void fromString(String messageData, DataDictionary dd, boolean doValidation); void fromString(String messageData, DataDictionary sessionDictionary,
            DataDictionary applicationDictionary, boolean doValidation); void pushBack(StringField field); synchronized FieldException getException(); static MsgType identifyType(String message);  }
@Test public void testValidation() throws Exception { final String data = "8=FIX.4.49=30935=849=ASX56=CL1_FIX4434=452=20060324-01:05:58" + "17=X-B-WOW-1494E9A0:58BD3F9D-1109150=D39=011=18427138=200198=1494E9A0:58BD3F9D" + "526=432437=B-WOW-1494E9A0:58BD3F9D55=WOW54=1151=20014=040=244=1559=16=0" + "453=3448=AAA35791447=D452=3448=8447=D452=4448=FIX11447=D452=36" + "60=20060320-03:34:2910=169"; 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.49=30935=849=ASX56=CL1_FIX4434=452=20060324-01:05:58" + "17=X-B-WOW-1494E9A0:58BD3F9D-1109150=D39=011=18427138=200198=1494E9A0:58BD3F9D" + "526=432437=B-WOW-1494E9A0:58BD3F9D55=WOW54=1151=20014=040=244=1559=16=0" + "453=3448=AAA35791447=D452=3448=8447=D452=4448=FIX11447=D452=36" + "60=20060320-03:34:2910=169"; 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.19=23435=W34=249=ABFX52=20080722-16:37:11.23456=X2RV1" + "55=EUR/USD262=CAP0000011268=2269=0270=1.5784415=EUR271=500000272=20080724" + "269=1270=1.5786915=EUR271=500000272=2008072410=097"; 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.19=8435=A49=EXEC56=BANZAI34=152=20080811-13:26:12.409108=1" + "141=Y98=01137=710=102"; 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.49=22235=D49=SenderCompId56=TargetCompId34=3752=20070223-22:28:33" + "11=18333922=838=140=244=1248=BHP54=255=BHP59=1" + "60=20060223-22:38:33526=362078=079=AllocACC180=1010.1" + "79=AllocACC280=2020.2453=2448=8447=D452=4448=AAA35354447=D452=310=079"; 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")); } }