JmsRealmFactory { public Iterator<String> getRegisteredRealmNames() { return jmsRealms.keySet().iterator(); } private  JmsRealmFactory(); static synchronized JmsRealmFactory getInstance(); void clear(); JmsRealm getJmsRealm(String jmsRealmName); Iterator<String> getRegisteredRealmNames(); List<String> getRegisteredRealmNamesAsList(); void registerJmsRealm(JmsRealm jmsRealm); @Override String toString(); String getFirstDatasourceJmsRealm(); List<String> getRegisteredDatasourceRealmNamesAsList();  }
@Test public void readInOrderOfAppearance() { Iterator<String> it = jmsRealmFactory.getRegisteredRealmNames(); String sequence=it.next()+","+it.next()+","+it.next()+","+it.next(); assertEquals("c,b,d,a",sequence); assertFalse(it.hasNext()); }