JmsRealmFactory { public List<String> getRegisteredRealmNamesAsList() { Iterator<String> it = getRegisteredRealmNames(); List<String> result = new ArrayList<String>(); while (it.hasNext()) { result.add(it.next()); } return result; } 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 readInOrderOfAppearanceViaList() { List<String> list = jmsRealmFactory.getRegisteredRealmNamesAsList(); String sequence=list.get(0)+","+list.get(1)+","+list.get(2)+","+list.get(3); assertEquals(4, list.size()); assertEquals("c,b,d,a",sequence); }