JndiContextFactory implements InitialContextFactory { protected static Hashtable<String, Object> addAdapterSchemePackage(Hashtable<String, Object> hashtable) { String property = (String) hashtable.get(Context.URL_PKG_PREFIXES); if(property == null) hashtable.put(Context.URL_PKG_PREFIXES, SystemPropertiesUtil.NAMING_PACKAGE); else if (!property.contains(SystemPropertiesUtil.NAMING_PACKAGE)) hashtable.put(Context.URL_PKG_PREFIXES, property + ":" + SystemPropertiesUtil.NAMING_PACKAGE); return hashtable; } JndiContextFactory();  JndiContextFactory(Hashtable environment); @Override Context getInitialContext(Hashtable environment);  }
@Test public void testAddAdapterScheme() throws Exception { Hashtable<String, Object> env1 = new Hashtable<>(); Hashtable<String, Object> result = JndiContextFactory.addAdapterSchemePackage(env1); assertTrue(result.containsKey(Context.URL_PKG_PREFIXES)); Hashtable<String, Object> env2 = new Hashtable<>(); env2.put(Context.URL_PKG_PREFIXES, "com.adaptris.alt.naming"); result = JndiContextFactory.addAdapterSchemePackage(env2); String pkgs = (String) result.get(Context.URL_PKG_PREFIXES); assertEquals("com.adaptris.alt.naming:com.adaptris.naming", pkgs); Hashtable<String, Object> env3 = new Hashtable<>(); env3.put(Context.URL_PKG_PREFIXES, "com.adaptris.naming"); result = JndiContextFactory.addAdapterSchemePackage(env3); pkgs = (String) result.get(Context.URL_PKG_PREFIXES); assertEquals("com.adaptris.naming", pkgs); }