@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // simulate ftp/http using mocks context.addComponent("ftp", new MockComponent()); context.addComponent("http", new MockComponent()); interceptSendToEndpoint("(ftp|http):.*") .to("log:intercept") .to("mock:intercept"); from("direct:start") .recipientList(header("foo")).parallelProcessing() .to("mock:end"); } }; }
@Test public void testGuice() throws Exception { Hashtable<String, Object> env = new Hashtable<String, Object>(); env.put(Context.PROVIDER_URL, GuiceInitialContextFactory.class.getName()); env.put(Injectors.MODULE_CLASS_NAMES, MyModule.class.getName()); InitialContext context = new InitialContext(env); Injector injector = (Injector) context.lookup(Injector.class.getName()); assertNotNull("Found injector", injector); Object value = context.lookup("foo"); assertNotNull("Should have found a value for foo!", value); CamelContext camelContext = injector.getInstance(CamelContext.class); Component component = camelContext.getComponent("foo"); assertThat(component, is(MockComponent.class)); Endpoint endpoint = camelContext.getEndpoint("foo:cheese"); assertThat(endpoint, is(MockEndpoint.class)); }
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { context.addComponent("foo", new MockComponent()); from("direct:start") .to("foo:foo") .to("mock:result"); } }; }
@Provides @JndiBind("foo") MockComponent foo() { return new MockComponent(); }
@Before public void startUp() { _camelContext = new SwitchYardCamelContextImpl(false); _camelContext.addComponent("switchyard", new MockComponent()); _configuration = mock(Configuration.class); }