@Test
public void checkServiceListListBindings() throws NamingException
{

  BundleMock mock = new BundleMock("scooby.doo", new Properties());
  
  Thread.currentThread().setContextClassLoader(mock.getClassLoader());
  InitialContext ctx = new InitialContext();
  
  String className = Runnable.class.getName();
  
  MethodCall run = new MethodCall(Runnable.class, "run");
  
  Runnable t = Skeleton.newMock(Runnable.class);
  Runnable t2 = Skeleton.newMock(Runnable.class);
  
  // we don't want the default service
  reg.unregister();
  
  ServiceRegistration reg = bc.registerService(className, t, null);
  ServiceRegistration reg2 = bc.registerService(className, t2, null);
  
  NamingEnumeration<Binding> ne = ctx.listBindings("osgi:servicelist/" + className);
  
  assertTrue(ne.hasMoreElements());
  
  Binding bnd = ne.nextElement();
  
  assertEquals(String.valueOf(reg.getReference().getProperty(Constants.SERVICE_ID)), bnd.getName());
  assertTrue("Class name not correct. Was: " + bnd.getClassName(), bnd.getClassName().contains("Proxy") || bnd.getClassName().contains("EnhancerByCGLIB"));
  
  Runnable r = (Runnable) bnd.getObject();
  
  assertNotNull(r);
  
  r.run();
  
  Skeleton.getSkeleton(t).assertCalledExactNumberOfTimes(run, 1);
  Skeleton.getSkeleton(t2).assertNotCalled(run);
  
  assertTrue(ne.hasMoreElements());
  
  bnd = ne.nextElement();
  
  assertEquals(String.valueOf(reg2.getReference().getProperty(Constants.SERVICE_ID)), bnd.getName());
  assertTrue("Class name not correct. Was: " + bnd.getClassName(), bnd.getClassName().contains("Proxy") || bnd.getClassName().contains("EnhancerByCGLIB"));
  
  r = (Runnable) bnd.getObject();
  
  assertNotNull(r);
  
  r.run();
  
  Skeleton.getSkeleton(t).assertCalledExactNumberOfTimes(run, 1);
  Skeleton.getSkeleton(t2).assertCalledExactNumberOfTimes(run, 1);
  
  assertFalse(ne.hasMoreElements());
}