JmsRealmFactory { public JmsRealm getJmsRealm(String jmsRealmName) { JmsRealm jmsRealm = jmsRealms.get(jmsRealmName); if (jmsRealm == null) { log.error("no JmsRealm found under name [" + jmsRealmName + "], factory contents [" + toString() + "]"); } return jmsRealm; } 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 registerAndRead() { JmsRealm a = jmsRealmFactory.getJmsRealm("a"); JmsRealm b = jmsRealmFactory.getJmsRealm("b"); JmsRealm c = jmsRealmFactory.getJmsRealm("c"); JmsRealm d = jmsRealmFactory.getJmsRealm("d"); JmsRealm e = jmsRealmFactory.getJmsRealm("e"); assertNotNull(a); assertNotNull(b); assertNotNull(c); assertNotNull(d); assertNull(e); assertTrue(StringUtils.isNotEmpty(a.getDatasourceName())); assertTrue(StringUtils.isNotEmpty(b.getDatasourceName())); assertFalse(StringUtils.isNotEmpty(c.getDatasourceName())); assertFalse(StringUtils.isNotEmpty(d.getDatasourceName())); }