@Test
public void simpleJNDILookup() throws NamingException
{

  System.setProperty(Context.URL_PKG_PREFIXES, "helloMatey");
      
  InitialContext ctx = new InitialContext(new Hashtable<Object, Object>());
  
  BundleMock mock = new BundleMock("scooby.doo.1", new Properties());
  
  Thread.currentThread().setContextClassLoader(mock.getClassLoader());
  
  Runnable s = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
  
  assertNotNull("We didn't get a service back from our lookup :(", s);
  
  s.run();
  
  Skeleton.getSkeleton(service).assertCalledExactNumberOfTimes(new MethodCall(Runnable.class, "run"), 1);
  
  Skeleton skel = Skeleton.getSkeleton(mock.getBundleContext());
  
  skel.assertCalled(new MethodCall(BundleContext.class, "getServiceReferences", "java.lang.Runnable", null));
  ctx = new InitialContext(new Hashtable<Object, Object>());
  
  mock = new BundleMock("scooby.doo.2", new Properties());
  
  Thread.currentThread().setContextClassLoader(mock.getClassLoader());
  s = (Runnable) ctx.lookup("osgi:service/java.lang.Runnable");
  
  // Check we have the packages set correctly
  
  String packages = System.getProperty(Context.URL_PKG_PREFIXES, null);
  
  assertTrue(ctx.getEnvironment().containsValue(packages));
  assertNotNull("We didn't get a service back from our lookup :(", s);
  s.run();
  
  Skeleton.getSkeleton(service).assertCalledExactNumberOfTimes(new MethodCall(Runnable.class, "run"), 2);
     
  skel = Skeleton.getSkeleton(mock.getBundleContext());
  skel.assertCalled(new MethodCall(BundleContext.class, "getServiceReferences", "java.lang.Runnable", null));
}