Message extends FieldMap { public final Header getHeader() { return header; } 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 testHeaderGroupParsing() throws Exception { final Message message = new Message("8=FIX.4.2\0019=40\00135=A\001" + "627=2\001628=FOO\001628=BAR\001" + "98=0\001384=2\001372=D\001385=R\001372=8\001385=S\00110=228\001", DataDictionaryTest.getDictionary()); final quickfix.fix44.Message.Header.NoHops hops = new quickfix.fix44.Message.Header.NoHops(); message.getHeader().getGroup(1, hops); assertEquals("FOO", hops.getString(HopCompID.FIELD)); message.getHeader().getGroup(2, hops); assertEquals("BAR", hops.getString(HopCompID.FIELD)); }
@Test public void testParsing() throws Exception { final Message message = new Message("8=FIX.4.2\0019=40\00135=A\001" + "98=0\001384=2\001372=D\001385=R\001372=8\001385=S\00110=96\001", DataDictionaryTest.getDictionary()); assertHeaderField(message, "FIX.4.2", BeginString.FIELD); assertHeaderField(message, "40", BodyLength.FIELD); assertEquals("wrong field value", 40, message.getHeader().getInt(BodyLength.FIELD)); assertHeaderField(message, "A", MsgType.FIELD); assertBodyField(message, "0", EncryptMethod.FIELD); assertTrailerField(message, "96", CheckSum.FIELD); final NoMsgTypes valueMessageType = new Logon.NoMsgTypes(); message.getGroup(1, valueMessageType); assertEquals("wrong value", "D", valueMessageType.getString(RefMsgType.FIELD)); assertEquals("wrong value", "R", valueMessageType.getString(MsgDirection.FIELD)); message.getGroup(2, valueMessageType); assertEquals("wrong value", "8", valueMessageType.getString(RefMsgType.FIELD)); assertEquals("wrong value", "S", valueMessageType.getString(MsgDirection.FIELD)); }
@Test public void testHeaderDataField() throws Exception { final Message m = new Message("8=FIX.4.2\0019=53\00135=A\00190=4\00191=ABCD\001" + "98=0\001384=2\001372=D\001385=R\001372=8\001385=S\00110=241\001", DataDictionaryTest.getDictionary()); assertEquals("ABCD", m.getHeader().getString(SecureData.FIELD)); }
@Test public void testMessageIterator() { Message message = new Message(); java.util.Iterator<Field<?>> i = message.iterator(); assertEquals(false, i.hasNext()); try { assertNull(i.next()); fail("exception not thrown"); } catch (final java.util.NoSuchElementException e) { } try { message = new Message("8=FIX.4.2\0019=12\00135=A\001108=30\00110=026\001"); i = message.iterator(); assertTrue(i.hasNext()); StringField field = (StringField) i.next(); assertEquals(108, field.getField()); assertEquals("30", field.getValue()); assertEquals(false, i.hasNext()); try { assertNull(i.next()); fail("exception not thrown"); } catch (final java.util.NoSuchElementException e) { } final java.util.Iterator<Field<?>> j = message.getHeader().iterator(); assertTrue(j.hasNext()); field = (StringField) j.next(); assertEquals(8, field.getField()); assertEquals("FIX.4.2", field.getValue()); field = (StringField) j.next(); assertEquals(9, field.getField()); assertEquals("12", field.getValue()); field = (StringField) j.next(); assertEquals(35, field.getField()); assertEquals("A", field.getValue()); assertEquals(false, j.hasNext()); try { assertNull(j.next()); fail("exception not thrown"); } catch (final java.util.NoSuchElementException e) { } } catch (final InvalidMessage e) { fail("exception thrown"); } }