Package org.apache.camel.spring

Examples of org.apache.camel.spring.SpringCamelContext


        System.setProperty("CxfEndpointTest.port1", Integer.toString(port1));
        System.setProperty("CxfEndpointTest.port2", Integer.toString(port2));

        ClassPathXmlApplicationContext ctx =
            new ClassPathXmlApplicationContext(new String[]{"org/apache/camel/component/cxf/CxfEndpointBeans.xml"});
        CxfComponent cxfComponent = new CxfComponent(new SpringCamelContext(ctx));
        CxfSpringEndpoint endpoint = (CxfSpringEndpoint)cxfComponent.createEndpoint("cxf://bean:serviceEndpoint");

        ServerFactoryBean svf = new ServerFactoryBean();
        endpoint.configure(svf);
        assertEquals("Got the wrong endpoint address", svf.getAddress(), "http://localhost:" + port2 + "/helloworld");
View Full Code Here


        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/errorHandler.xml");
    }

    public void testEndpointConfiguration() throws Exception {
        // must type cast to work with Spring 2.5.x
        SpringCamelContext context = (SpringCamelContext) applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
        List<Route> list = context.getRoutes();
        assertEquals("Number routes created" + list, 2, list.size());
        for (Route route : list) {
            EventDrivenConsumerRoute consumerRoute = assertIsInstanceOf(EventDrivenConsumerRoute.class, route);
            Channel channel = unwrapChannel(consumerRoute.getProcessor());
View Full Code Here

    }

    protected List<Route> getRoutesFromContext(String classpathConfigFile) {
        applicationContext = new ClassPathXmlApplicationContext(classpathConfigFile);
        // must type cast to work with Spring 2.5.x
        SpringCamelContext context = (SpringCamelContext) applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();
        assertNotNull("No Camel Context in file: " + classpathConfigFile, context);
        List<Route> routes = context.getRoutes();
        assertNotNull("No routes available for context: " + context.getName() + " in file: " + classpathConfigFile, routes);
        return routes;
    }
View Full Code Here

    public void testAutoStartupFalse() throws Exception {
        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteAutoStartupFalseTest.xml");

        // must type cast to work with Spring 2.5.x
        SpringCamelContext camel = (SpringCamelContext) ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();

        assertEquals(false, camel.getRouteStatus("foo").isStarted());

        // now starting route manually
        camel.startRoute("foo");
        assertEquals(true, camel.getRouteStatus("foo").isStarted());

        // and now we can send a message to the route and see that it works
        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);

        ProducerTemplate template = camel.createProducerTemplate();
        template.start();
        template.sendBody("direct:start", "Hello World");
        template.stop();

        mock.assertIsSatisfied();
View Full Code Here

        assertEquals("Hello World", reply);
       
        // test sending inOnly message
        MyProxySender anotherSender = (MyProxySender) ac.getBean("myAnotherProxySender");
        // must type cast to work with Spring 2.5.x
        SpringCamelContext context = (SpringCamelContext) ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
        MockEndpoint result = TestSupport.resolveMandatoryEndpoint(context, "mock:result", MockEndpoint.class);
        result.expectedBodiesReceived("Hello my friends!");
       
        anotherSender.greeting("Hello my friends!");
        result.assertIsSatisfied();
View Full Code Here

        return new ClassPathXmlApplicationContext("org/apache/camel/spring/config/SpringCamelContextCustomDefaultThreadPoolProfileTest.xml");
    }

    public void testDefaultThreadPoolProfile() throws Exception {
        // must type cast to work with Spring 2.5.x
        SpringCamelContext context = (SpringCamelContext) applicationContext.getBeansOfType(SpringCamelContext.class).values().iterator().next();

        ThreadPoolProfile profile = context.getExecutorServiceStrategy().getDefaultThreadPoolProfile();
        assertEquals(5, profile.getPoolSize().intValue());
        assertEquals(15, profile.getMaxPoolSize().intValue());
        assertEquals(25, profile.getKeepAliveTime().longValue());
        assertEquals(250, profile.getMaxQueueSize().intValue());
        assertEquals(ThreadPoolRejectedPolicy.Abort, profile.getRejectedPolicy());
View Full Code Here

    public void testAutoStartupTrue() throws Exception {
        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/RouteAutoStartupTrueTest.xml");

        // must type cast to work with Spring 2.5.x
        SpringCamelContext camel = (SpringCamelContext) ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();

        assertEquals(true, camel.getRouteStatus("bar").isStarted());

        // and now we can send a message to the route and see that it works
        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);

        ProducerTemplate template = camel.createProducerTemplate();
        template.start();
        template.sendBody("direct:start", "Hello World");
        template.stop();

        mock.assertIsSatisfied();
View Full Code Here

    public void testAutoStartupFalse() throws Exception {
        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestFalse.xml");

        // must type cast to work with Spring 2.5.x
        SpringCamelContext camel = (SpringCamelContext) ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
        assertNotNull(camel.getName());
        assertEquals(true, camel.isStarted());
        assertEquals(Boolean.FALSE, camel.isAutoStartup());
        assertEquals(1, camel.getRoutes().size());

        assertEquals(false, camel.getRouteStatus("foo").isStarted());

        // now starting route manually
        camel.startRoute("foo");

        assertEquals(Boolean.FALSE, camel.isAutoStartup());
        assertEquals(1, camel.getRoutes().size());
        assertEquals(true, camel.getRouteStatus("foo").isStarted());

        // and now we can send a message to the route and see that it works
        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);

        ProducerTemplate template = camel.createProducerTemplate();
        template.start();
        template.sendBody("direct:start", "Hello World");
        template.stop();

        mock.assertIsSatisfied();
View Full Code Here

    public void testAutoStartupTrue() throws Exception {
        ac = new ClassPathXmlApplicationContext("org/apache/camel/spring/config/CamelContextAutoStartupTestTrue.xml");

        // must type cast to work with Spring 2.5.x
        SpringCamelContext camel = (SpringCamelContext) ac.getBeansOfType(SpringCamelContext.class).values().iterator().next();
        assertNotNull(camel.getName());
        assertEquals(true, camel.isStarted());
        assertEquals(Boolean.TRUE, camel.isAutoStartup());
        assertEquals(1, camel.getRoutes().size());

        // send a message to the route and see that it works
        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);

        ProducerTemplate template = camel.createProducerTemplate();
        template.start();
        template.sendBody("direct:start", "Hello World");
        template.stop();

        mock.assertIsSatisfied();
View Full Code Here

    }

    public void testAutoStartup() throws Exception {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("org/apache/camel/spring/camelContextFactoryBean.xml");

        SpringCamelContext context = (SpringCamelContext) applicationContext.getBean("camel4");
        assertFalse(context.isAutoStartup());
        // there is 1 route but its not started
        assertEquals(1, context.getRoutes().size());

        context = (SpringCamelContext) applicationContext.getBean("camel3");
        assertTrue(context.isAutoStartup());
        // there is 1 route but and its started
        assertEquals(1, context.getRoutes().size());
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.spring.SpringCamelContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.