Main extends MainSupport { @Override protected Map<String, CamelContext> getCamelContextMap() { BeanManager manager = container.getBeanManager(); return manager.getBeans(CamelContext.class, Any.Literal.INSTANCE).stream() .map(bean -> getReference(manager, CamelContext.class, bean)) .collect(toMap(CamelContext::getName, identity())); }  static void main(String... args); static Main getInstance();  }
@Test public void testMainSupport() throws Exception { Main main = new Main(); main.start(); assertThat("Camel contexts are not deployed!", main.getCamelContextMap(), allOf(hasKey("default"), hasKey("foo"))); CamelContext context = main.getCamelContextMap().get("default"); assertThat("Default Camel context is not started", context.getStatus(), is(equalTo(ServiceStatus.Started))); assertThat("Foo Camel context is not started", main.getCamelContextMap().get("foo").getStatus(), is(equalTo(ServiceStatus.Started))); MockEndpoint outbound = context.getEndpoint("mock:outbound", MockEndpoint.class); outbound.expectedMessageCount(1); outbound.expectedBodiesReceived("message"); ProducerTemplate producer = main.getCamelTemplate(); producer.sendBody("direct:inbound", "message"); MockEndpoint.assertIsSatisfied(2L, TimeUnit.SECONDS, outbound); main.stop(); }