OsgiMulticastProducer extends OsgiDefaultProducer { @Override protected void doShutdown() throws Exception { if (defaultExecutorService) { getEndpoint().getCamelContext().getExecutorServiceManager().shutdownNow(executorService); } super.doShutdown(); } OsgiMulticastProducer(OsgiDefaultEndpoint endpoint, Map<String, Object> props,
        AggregationStrategy aggregationStrategy, boolean parallelProcessing, ExecutorService executorService,
        boolean shutdownExecutorService, boolean streaming, boolean stopOnException, long timeout,
        Processor onPrepare); AggregationStrategy getAggregationStrategy(); boolean isParallelProcessing(); ExecutorService getExecutorService(); boolean isStreaming(); boolean isStopOnException(); long getTimeout(); Processor getOnPrepare(); boolean isDefaultExecutorService();  }
@Test public void testDoShutdown() throws Exception { ExecutorServiceManager executorManager = mock(ExecutorServiceManager.class); CamelContext camelContext = mock(CamelContext.class); when(camelContext.getExecutorServiceManager()).thenReturn(executorManager); OsgiDefaultEndpoint endpoint = mock(OsgiDefaultEndpoint.class); when(endpoint.getCamelContext()).thenReturn(camelContext); ExecutorService executor = mock(ExecutorService.class); when(executorManager.newDefaultThreadPool(anyObject(), anyString())).thenReturn(executor); OsgiMulticastProducer producer = new OsgiMulticastProducer( endpoint, Collections.<String, Object>emptyMap(), null, true, null, false, false, false, 0, null); producer.doShutdown(); verify(executorManager).shutdownNow(same(executor)); }