BlueprintURLContext implements Context { @Override public NamingEnumeration<NameClassPair> list(Name name) throws NamingException { return list(name.toString()); } @SuppressWarnings("unchecked")  BlueprintURLContext(Bundle callersBundle, Hashtable<?, ?> env); private  BlueprintURLContext(Bundle callersBundle, BlueprintName parentName, Map<String, Object> env); static int getGracePeriod(Bundle b); @Override Object addToEnvironment(String propName, Object propVal); @Override void bind(Name n, Object o); @Override void bind(String s, Object o); @Override void close(); @Override Name composeName(Name name, Name prefix); @Override String composeName(String name, String prefix); @Override Context createSubcontext(Name n); @Override Context createSubcontext(String s); @Override void destroySubcontext(Name n); @Override void destroySubcontext(String s); @Override Hashtable<?, ?> getEnvironment(); @Override String getNameInNamespace(); @Override NameParser getNameParser(Name n); @Override NameParser getNameParser(String s); @Override NamingEnumeration<NameClassPair> list(Name name); @Override NamingEnumeration<NameClassPair> list(String s); @Override NamingEnumeration<Binding> listBindings(Name name); @Override NamingEnumeration<Binding> listBindings(String name); @Override Object lookup(Name name); @Override Object lookup(String name); @Override Object lookupLink(Name n); @Override Object lookupLink(String s); @Override void rebind(Name n, Object o); @Override void rebind(String s, Object o); @Override Object removeFromEnvironment(String propName); @Override void rename(Name nOld, Name nNew); @Override void rename(String sOld, String sNew); @Override void unbind(Name n); @Override void unbind(String s);  }
@Test public void testList() throws Exception { InitialContext ctx = new InitialContext(); NamingEnumeration<NameClassPair> compList = ctx.list("blueprint:comp"); Set<String> expectedCompIds = new BlueprintContainerStub().getComponentIds(); while (compList.hasMore()) { NameClassPair ncp = compList.next(); String compId = ncp.getName(); String compClass = ncp.getClassName(); if (compId.equals("comp1")) { assertEquals ("comp1 class wrong in list", SimpleComponent.class.getName(), compClass); } else if (compId.equals("comp2")) { assertEquals ("comp2 class wrong in list", AnotherComponent.class.getName(), compClass); } expectedCompIds.remove(compId); } assertEquals ("Not all expected components were found", expectedCompIds.size(), 0); }