JmsRealmFactory { public List<String> getRegisteredDatasourceRealmNamesAsList() { Iterator<String> it = getRegisteredRealmNames(); List<String> result = new ArrayList<String>(); while (it.hasNext()) { String jr = (String) it.next(); if (StringUtils.isNotEmpty(getJmsRealm(jr).getDatasourceName())) { result.add(jr); } } 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 readDatabaseRealmsInOrderOfAppearance() { List<String> list = jmsRealmFactory.getRegisteredDatasourceRealmNamesAsList(); assertEquals(2,list.size()); String sequence=list.get(0)+","+list.get(1); assertEquals("b,a",sequence); }