public void tstTaskExecutor() throws Exception {
    Dictionary headers = new Hashtable();
    headers.put(Constants.BUNDLE_NAME, "Extender mock bundle");
    final EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(headers);
    aBundle.setEntryReturnOnNextCallToGetEntry(
        new ClassPathResource("META-INF/spring/moved-extender.xml").getURL());

    MockBundleContext ctx =
        new MockBundleContext() {

          public Bundle getBundle() {
            return aBundle;
          }
        };

    this.listener.start(ctx);

    Dictionary hdrs = new Hashtable();
    hdrs.put(ConfigUtils.SPRING_CONTEXT_HEADER, "bla bla");
    MockBundle anotherBundle = new MockBundle(hdrs);
    anotherBundle.setBundleId(1);

    BundleEvent event = new BundleEvent(BundleEvent.STARTED, anotherBundle);

    BundleListener listener = (BundleListener) ctx.getBundleListeners().iterator().next();

    TestTaskExecutor.called = false;

    listener.bundleChanged(event);
    assertTrue(
        "task executor should have been called if configured properly", TestTaskExecutor.called);
  }
  public void testStart() throws Exception {
    MockControl bundleContextControl = MockControl.createControl(BundleContext.class);
    BundleContext context = (BundleContext) bundleContextControl.getMock();
    // platform determination

    // extracting bundle id from bundle
    bundleContextControl.expectAndReturn(context.getBundle(), new MockBundle());

    // look for existing resolved bundles
    bundleContextControl.expectAndReturn(context.getBundles(), new Bundle[0], 2);

    // register namespace and entity resolving service
    // context.registerService((String[]) null, null, null);
    // bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
    // bundleContextControl.setReturnValue(null);

    // register context service
    context.registerService((String[]) null, null, null);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
    bundleContextControl.setReturnValue(null, MockControl.ONE_OR_MORE);

    // create task executor
    EntryLookupControllingMockBundle aBundle = new EntryLookupControllingMockBundle(null);
    aBundle.setEntryReturnOnNextCallToGetEntry(null);
    bundleContextControl.expectAndReturn(context.getBundle(), aBundle, MockControl.ONE_OR_MORE);

    // listen for bundle events
    context.addBundleListener(null);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);
    bundleContextControl.setVoidCallable(2);

    bundleContextControl.expectAndReturn(
        context.registerService(new String[0], null, new Properties()),
        new MockServiceRegistration(),
        MockControl.ONE_OR_MORE);
    bundleContextControl.setMatcher(MockControl.ALWAYS_MATCHER);

    bundleContextControl.replay();

    this.listener.start(context);
    bundleContextControl.verify();
  }