@Test
public void checkServiceListLookup() 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);
  
  // we don't want the default service
  reg.unregister();
  
  ServiceRegistration reg = bc.registerService(className, t, null);
  ServiceRegistration reg2 = bc.registerService("java.lang.Thread", new Thread(), null);
  
  Context ctx2 = (Context) ctx.lookup("osgi:servicelist/java.lang.Runnable");
  
  Runnable r = (Runnable) ctx2.lookup(String.valueOf(reg.getReference().getProperty(Constants.SERVICE_ID)));
  r.run();
  
  Skeleton.getSkeleton(t).assertCalled(new MethodCall(Runnable.class, "run"));
  
  reg.unregister();
  
  try {
    r.run();
    fail("Should have received a ServiceException");
  } catch (ServiceException e) {
    assertEquals("service exception has the wrong type", ServiceException.UNREGISTERED, e.getType());
  }
  
  try {
    ctx2.lookup(String.valueOf(reg2.getReference().getProperty(Constants.SERVICE_ID)));
    fail("Expected a NameNotFoundException");
  } catch (NameNotFoundException e) {
  }
}