OsgiDefaultConsumer extends ServiceSupport implements Consumer, SuspendableService, Processor { protected BundleContext getApplicationBundleContext() { return getEndpoint().getApplicationBundleContext(); } OsgiDefaultConsumer(OsgiDefaultEndpoint endpoint, Processor processor, Map<String, Object> props); @Override OsgiDefaultEndpoint getEndpoint(); @Override void process(final Exchange exchange);  }
@Test public void testDoStartTwice() throws Exception { BundleContext bundleContext = mock(BundleContext.class); OsgiDefaultEndpoint endpoint = mock(OsgiDefaultEndpoint.class); when(endpoint.getApplicationBundleContext()).thenReturn(bundleContext); Service processor = mock(Service.class, withSettings().extraInterfaces(Processor.class)); Map<String, Object> props = Collections.singletonMap("key", (Object) "value"); OsgiDefaultConsumer consumer = new OsgiDefaultConsumer(endpoint, (Processor) processor, props); ServiceHelper.startService(consumer); ServiceHelper.startService(consumer); verify(processor).start(); verify(bundleContext) .registerService(eq(OsgiComponent.OBJECT_CLASS), same(consumer), eq(new Hashtable<String, Object>(props))); }