ServiceRegistryContext extends AbstractServiceRegistryContext implements Context { public NamingEnumeration<NameClassPair> list(final Name name) throws NamingException { return new ServiceRegistryListContext(callerContext, env, convert(name)).list(""); } ServiceRegistryContext(BundleContext callerContext, Hashtable<?, ?> environment);  ServiceRegistryContext(BundleContext callerContext, OsgiName validName, Map<String, Object> env); NamingEnumeration<NameClassPair> list(final Name name); NamingEnumeration<NameClassPair> list(String name); NamingEnumeration<Binding> listBindings(final Name name); NamingEnumeration<Binding> listBindings(String name); Object lookup(Name name); Object lookup(String name);  }
@Test public void checkServiceListList() throws NamingException { BundleMock mock = new BundleMock("scooby.doo", new Properties()); Thread.currentThread().setContextClassLoader(mock.getClassLoader()); InitialContext ctx = new InitialContext(); String className = Runnable.class.getName(); Runnable t = Skeleton.newMock(Runnable.class); reg.unregister(); ServiceRegistration reg = bc.registerService(className, t, null); ServiceRegistration reg2 = bc.registerService(className, new Thread(), null); NamingEnumeration<NameClassPair> ne = ctx.list("osgi:servicelist/" + className); assertTrue(ne.hasMoreElements()); NameClassPair ncp = ne.nextElement(); assertEquals(String.valueOf(reg.getReference().getProperty(Constants.SERVICE_ID)), ncp.getName()); assertTrue("Class name not correct. Was: " + ncp.getClassName(), ncp.getClassName().contains("Proxy")); assertTrue(ne.hasMoreElements()); ncp = ne.nextElement(); assertEquals(String.valueOf(reg2.getReference().getProperty(Constants.SERVICE_ID)), ncp.getName()); assertEquals("Class name not correct.", Thread.class.getName(), ncp.getClassName()); assertFalse(ne.hasMoreElements()); }