@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");
    }
}