Search in sources :

Example 31 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class ServiceCallConfigurationTest method testServiceDiscoveryConfiguration.

@Test
public void testServiceDiscoveryConfiguration() {
    SpringCamelContext context = createContext("org/apache/camel/spring/cloud/ServiceCallConfigurationTest.xml");
    ServiceCallConfigurationDefinition conf1 = context.getServiceCallConfiguration("conf1");
    assertNotNull("No ServiceCallConfiguration (1)", conf1);
    assertNotNull("No ServiceDiscoveryConfiguration (1)", conf1.getServiceDiscoveryConfiguration());
    assertNotNull("No ServiceCallLoadBalancerConfiguration (1)", conf1.getLoadBalancerConfiguration());
    assertTrue(conf1.getLoadBalancerConfiguration() instanceof DefaultServiceCallLoadBalancerConfiguration);
    StaticServiceCallServiceDiscoveryConfiguration discovery1 = (StaticServiceCallServiceDiscoveryConfiguration) conf1.getServiceDiscoveryConfiguration();
    assertEquals(1, discovery1.getServers().size());
    assertEquals("localhost:9091", discovery1.getServers().get(0));
    ServiceCallConfigurationDefinition conf2 = context.getServiceCallConfiguration("conf2");
    assertNotNull("No ServiceCallConfiguration (2)", conf2);
    assertNotNull("No ServiceDiscoveryConfiguration (2)", conf2.getServiceDiscoveryConfiguration());
    assertNull(conf2.getLoadBalancerConfiguration());
    ChainedServiceCallServiceDiscoveryConfiguration discovery2 = (ChainedServiceCallServiceDiscoveryConfiguration) conf2.getServiceDiscoveryConfiguration();
    assertEquals(2, discovery2.getServiceDiscoveryConfigurations().size());
    assertTrue(discovery2.getServiceDiscoveryConfigurations().get(0) instanceof StaticServiceCallServiceDiscoveryConfiguration);
    assertTrue(discovery2.getServiceDiscoveryConfigurations().get(1) instanceof StaticServiceCallServiceDiscoveryConfiguration);
    StaticServiceCallServiceDiscoveryConfiguration sconf1 = (StaticServiceCallServiceDiscoveryConfiguration) discovery2.getServiceDiscoveryConfigurations().get(0);
    assertEquals(1, sconf1.getServers().size());
    assertEquals("localhost:9092", sconf1.getServers().get(0));
    StaticServiceCallServiceDiscoveryConfiguration sconf2 = (StaticServiceCallServiceDiscoveryConfiguration) discovery2.getServiceDiscoveryConfigurations().get(1);
    assertEquals(1, sconf2.getServers().size());
    assertEquals("localhost:9093,localhost:9094,localhost:9095,localhost:9096", sconf2.getServers().get(0));
    ChainedServiceCallServiceFilterConfiguration filter = (ChainedServiceCallServiceFilterConfiguration) conf2.getServiceFilterConfiguration();
    assertEquals(2, filter.getServiceFilterConfigurations().size());
    assertTrue(filter.getServiceFilterConfigurations().get(0) instanceof HealthyServiceCallServiceFilterConfiguration);
    assertTrue(filter.getServiceFilterConfigurations().get(1) instanceof BlacklistServiceCallServiceFilterConfiguration);
}
Also used : DefaultServiceCallLoadBalancerConfiguration(org.apache.camel.model.cloud.DefaultServiceCallLoadBalancerConfiguration) ChainedServiceCallServiceFilterConfiguration(org.apache.camel.model.cloud.ChainedServiceCallServiceFilterConfiguration) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) BlacklistServiceCallServiceFilterConfiguration(org.apache.camel.model.cloud.BlacklistServiceCallServiceFilterConfiguration) HealthyServiceCallServiceFilterConfiguration(org.apache.camel.model.cloud.HealthyServiceCallServiceFilterConfiguration) ServiceCallConfigurationDefinition(org.apache.camel.model.cloud.ServiceCallConfigurationDefinition) StaticServiceCallServiceDiscoveryConfiguration(org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration) ChainedServiceCallServiceDiscoveryConfiguration(org.apache.camel.model.cloud.ChainedServiceCallServiceDiscoveryConfiguration) Test(org.junit.Test)

Example 32 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class ErrorHandlerTest method testEndpointConfiguration.

public void testEndpointConfiguration() throws Exception {
    SpringCamelContext context = 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());
        DeadLetterChannel deadLetterChannel = assertIsInstanceOf(DeadLetterChannel.class, channel.getErrorHandler());
        RedeliveryPolicy redeliveryPolicy = deadLetterChannel.getRedeliveryPolicy();
        assertEquals("getMaximumRedeliveries()", 1, redeliveryPolicy.getMaximumRedeliveries());
        assertEquals("isUseExponentialBackOff()", true, redeliveryPolicy.isUseExponentialBackOff());
    }
}
Also used : DeadLetterChannel(org.apache.camel.processor.DeadLetterChannel) Channel(org.apache.camel.Channel) DeadLetterChannel(org.apache.camel.processor.DeadLetterChannel) SpringCamelContext(org.apache.camel.spring.SpringCamelContext) RedeliveryPolicy(org.apache.camel.processor.RedeliveryPolicy) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute) Route(org.apache.camel.Route) EventDrivenConsumerRoute(org.apache.camel.impl.EventDrivenConsumerRoute)

Example 33 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class PojoCallable method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    spring = new ClassPathXmlApplicationContext("org/apache/camel/component/javaspace/spring.xml");
    SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
    return ctx;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext)

Example 34 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class JavaSpaceSendReceiveTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    spring = new ClassPathXmlApplicationContext("org/apache/camel/component/javaspace/spring.xml");
    SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
    return ctx;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext)

Example 35 with SpringCamelContext

use of org.apache.camel.spring.SpringCamelContext in project camel by apache.

the class JavaSpaceTransportSendReceiveTest method createCamelContext.

@Override
protected CamelContext createCamelContext() throws Exception {
    spring = new ClassPathXmlApplicationContext("org/apache/camel/component/javaspace/spring.xml");
    SpringCamelContext ctx = SpringCamelContext.springCamelContext(spring);
    return ctx;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SpringCamelContext(org.apache.camel.spring.SpringCamelContext)

Aggregations

SpringCamelContext (org.apache.camel.spring.SpringCamelContext)49 CamelContext (org.apache.camel.CamelContext)21 Test (org.junit.Test)21 RouteBuilder (org.apache.camel.builder.RouteBuilder)17 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)16 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)15 ProducerTemplate (org.apache.camel.ProducerTemplate)15 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)14 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)12 RouteDefinition (org.apache.camel.model.RouteDefinition)7 StepAction (io.syndesis.common.model.action.StepAction)6 Step (io.syndesis.common.model.integration.Step)6 DoToSpringCamelContextsStrategy (org.apache.camel.test.spring.CamelSpringTestHelper.DoToSpringCamelContextsStrategy)5 Method (java.lang.reflect.Method)4 LinkedList (java.util.LinkedList)4 PropertiesComponent (org.apache.camel.component.properties.PropertiesComponent)4 ProcessorDefinition (org.apache.camel.model.ProcessorDefinition)4 Breakpoint (org.apache.camel.spi.Breakpoint)4 Exchange (org.apache.camel.Exchange)3 ConnectorDescriptor (io.syndesis.common.model.action.ConnectorDescriptor)2