@Test
public void testBundleListener() {

    BundleContext bc = EasyMock.createMock(BundleContext.class);
    EasyMock.replay(bc);
    final List<String> called = new ArrayList<>();
    ServiceDecoratorImpl serviceDecorator = new ServiceDecoratorImpl() {
        @Override
        void addDecorations(Bundle bundle) {
            called.add("addDecorations");
        }
        @Override
        void removeDecorations(Bundle bundle) {
            called.add("removeDecorations");
        }
    };
    Bundle b = EasyMock.createMock(Bundle.class);
    EasyMock.replay(b);
    ServiceDecoratorBundleListener listener = new ServiceDecoratorBundleListener(serviceDecorator);
    assertEquals("Precondition failed", 0, called.size());
    listener.bundleChanged(new BundleEvent(BundleEvent.INSTALLED, b));
    assertEquals(0, called.size());
    listener.bundleChanged(new BundleEvent(BundleEvent.STARTED, b));
    assertEquals(Arrays.asList("addDecorations"), called);
    listener.bundleChanged(new BundleEvent(BundleEvent.STOPPING, b));
    assertEquals(Arrays.asList("addDecorations", "removeDecorations"), called);
}