### Question:
BundleDisabler implements EventHandler { @Activate protected void activate(ComponentContext componentContext, Map<String, Object> properties) { this.bundleContext = componentContext.getBundleContext(); this.disabledBundles = getDisabledBundles(properties); disableBundles(); }  @Override void handleEvent(Event event);  }### Answer:
@Test public void testNullProperties() { disabler.activate(componentContext, Collections.<String, Object>emptyMap()); verifyNoMoreInteractions(bundleContext); }
@Test public void shouldNotDisableOwnBundle() { disabler.activate(componentContext, bundleProperties("my.own.bundle")); }
@Test public void shouldStopBundle() { Bundle targetBundle = mock(Bundle.class); bundles.add(targetBundle); when(targetBundle.getSymbolicName()).thenReturn("to.stop.bundle"); disabler.activate(componentContext, bundleProperties("to.stop.bundle")); try { verify(targetBundle).stop(); } catch (BundleException be) { } }
@Test public void shouldNotStopUninstalledBundle() { Bundle targetBundle = mock(Bundle.class); bundles.add(targetBundle); when(targetBundle.getState()).thenReturn(Bundle.UNINSTALLED); when(targetBundle.getSymbolicName()).thenReturn("to.stop.bundle"); disabler.activate(componentContext, bundleProperties("to.stop.bundle")); try { verify(targetBundle, never()).stop(); } catch (BundleException be) { } }