org.apache.camel.spring.boot.CamelAutoConfiguration Java Examples
The following examples show how to use
org.apache.camel.spring.boot.CamelAutoConfiguration.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CamelCloudNetflixServiceLoadBalancerAutoConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testAutoConfiguration() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class, CamelCloudNetflixServiceLoadBalancerAutoConfiguration.class, RibbonAutoConfiguration.class, RibbonClientConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "debug=true", "spring.main.banner-mode=off", "ribbon.client.name=test") .run( context -> { assertThat(context).hasSingleBean(LoadBalancerClient.class); assertThat(context).getBean(LoadBalancerClient.class).isInstanceOf(RibbonLoadBalancerClient.class); assertThat(context).hasSingleBean(CamelSpringCloudServiceLoadBalancer.LoadBalancerClientAdapter.class); LoadBalancerClient client = context.getBean(LoadBalancerClient.class); ServiceLoadBalancer balancer = context.getBean(CamelSpringCloudServiceLoadBalancer.LoadBalancerClientAdapter.class).adapt(client); assertThat(balancer).isInstanceOf(CamelCloudNetflixServiceLoadBalancer.class); } ); }
Example #2
Source File: CamelSpringCloudServiceRegistryTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testAutoConfiguration() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "spring.main.banner-mode=off", "ribbon.eureka.enabled=false", "ribbon.enabled=false") .run( context -> { // spring cloud registry assertThat(context).hasSingleBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class); assertThat(context).getBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class).isInstanceOf(MyServiceRegistry.class); // camel registry assertThat(context).hasSingleBean(org.apache.camel.cloud.ServiceRegistry.class); assertThat(context).getBean(org.apache.camel.cloud.ServiceRegistry.class).isInstanceOf(CamelSpringCloudServiceRegistry.class); assertThat(context).getBean(org.apache.camel.cloud.ServiceRegistry.class).hasFieldOrPropertyWithValue( "nativeServiceRegistry", context.getBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class) ); } ); }
Example #3
Source File: CamelSpringCloudServiceRegistryTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testDisabledCamelCloud() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "spring.main.banner-mode=off", "ribbon.eureka.enabled=false", "ribbon.enabled=false", "camel.cloud.enabled=false") .run( context -> { // spring cloud registry assertThat(context).hasSingleBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class); assertThat(context).getBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class).isInstanceOf(MyServiceRegistry.class); // camel registry assertThat(context).doesNotHaveBean(org.apache.camel.cloud.ServiceRegistry.class); } ); }
Example #4
Source File: CamelSpringCloudServiceRegistryTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testDisabledCamelServiceRegistry() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "spring.main.banner-mode=off", "ribbon.eureka.enabled=false", "ribbon.enabled=false", "camel.cloud.enabled=true", "camel.cloud.service-registry.enabled=false") .run( context -> { // spring cloud registry assertThat(context).hasSingleBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class); assertThat(context).getBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class).isInstanceOf(MyServiceRegistry.class); // camel registry assertThat(context).doesNotHaveBean(org.apache.camel.cloud.ServiceRegistry.class); } ); }
Example #5
Source File: CamelSpringCloudServiceRegistryTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testEnabledCamelServiceRegistry() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "spring.main.banner-mode=off", "ribbon.eureka.enabled=false", "ribbon.enabled=false", "camel.cloud.enabled=false", "camel.cloud.service-registry.enabled=true") .run( context -> { // spring cloud registry assertThat(context).hasSingleBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class); assertThat(context).getBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class).isInstanceOf(MyServiceRegistry.class); // camel registry assertThat(context).hasSingleBean(org.apache.camel.cloud.ServiceRegistry.class); assertThat(context).getBean(org.apache.camel.cloud.ServiceRegistry.class).isInstanceOf(CamelSpringCloudServiceRegistry.class); assertThat(context).getBean(org.apache.camel.cloud.ServiceRegistry.class).hasFieldOrPropertyWithValue( "nativeServiceRegistry", context.getBean(org.springframework.cloud.client.serviceregistry.ServiceRegistry.class) ); } ); }
Example #6
Source File: CamelSSLAutoConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void checkSSLPropertiesPresent() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelSSLAutoConfiguration.class, CamelAutoConfiguration.class ) ) .withPropertyValues( "camel.ssl.config.cert-alias=web", "camel.ssl.config.key-managers.key-password=changeit", "camel.ssl.config.key-managers.key-store.password=changeit", "camel.ssl.config.key-managers.key-store.type=PKCS12", "camel.ssl.config.trust-managers.key-store.password=changeit", "camel.ssl.config.trust-managers.key-store.type=jks" ) .run(context -> { GlobalSSLContextParametersSupplier supplier = context.getBean(GlobalSSLContextParametersSupplier.class); assertThat(context).hasSingleBean(CamelSSLAutoConfiguration.class); assertNotNull(supplier); assertNotNull(supplier.get()); assertEquals("web", supplier.get().getCertAlias()); assertNotNull(supplier.get().getKeyManagers()); assertEquals("changeit", supplier.get().getKeyManagers().getKeyPassword()); assertNotNull(supplier.get().getTrustManagers()); assertNotNull(supplier.get().getTrustManagers().getKeyStore()); assertEquals("jks", supplier.get().getTrustManagers().getKeyStore().getType()); } ); }
Example #7
Source File: CamelCloudServiceCallConfigurationTest.java From camel-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testConfiguration() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelCloudServiceChooserAutoConfiguration.class ) ) .withPropertyValues( "camel.cloud.enabled=false", "camel.cloud.service-discovery.enabled=false", "camel.cloud.service-filter.enabled=false", "camel.cloud.service-chooser.enabled=true", "camel.cloud.load-balancer.enabled=false", "debug=false" ) .run(context -> { Environment env = context.getEnvironment(); assertFalse(env.getProperty("camel.cloud.enabled", Boolean.class)); assertFalse(env.getProperty("camel.cloud.service-discovery.enabled", Boolean.class)); assertFalse(env.getProperty("camel.cloud.service-filter.enabled", Boolean.class)); assertTrue(env.getProperty("camel.cloud.service-chooser.enabled", Boolean.class)); assertFalse(env.getProperty("camel.cloud.load-balancer.enabled", Boolean.class)); assertTrue(context.getBeansOfType(ServiceDiscovery.class).isEmpty()); assertTrue(context.getBeansOfType(ServiceFilter.class).isEmpty()); assertTrue(context.getBeansOfType(ServiceChooser.class).isEmpty()); assertTrue(context.getBeansOfType(ServiceLoadBalancer.class).isEmpty()); } ); }
Example #8
Source File: CamelSpringCloudServiceRegistryTest.java From camel-spring-boot with Apache License 2.0 | 4 votes |
@Test public void testServiceRegistry() { new ApplicationContextRunner() .withConfiguration( AutoConfigurations.of( CamelAutoConfiguration.class, CamelCloudAutoConfiguration.class, CamelSpringCloudServiceRegistryAutoConfiguration.class )) .withUserConfiguration( TestConfiguration.class) .withPropertyValues( "spring.main.banner-mode=off", "ribbon.eureka.enabled=false", "ribbon.enabled=false") .run( context -> { CamelSpringCloudServiceRegistry camelRgistry = context.getBean(CamelSpringCloudServiceRegistry.class); final String serviceName = "my-.service"; final String serviceId = UUID.randomUUID().toString(); final int port = ThreadLocalRandom.current().nextInt(); camelRgistry.register( DefaultServiceDefinition.builder() .withHost("localhost") .withPort(port) .withName(serviceName) .withId(serviceId) .build() ); MyServiceRegistry cloudRegistry = camelRgistry.getNativeServiceRegistry(MyServiceRegistry.class); assertThat(cloudRegistry.registrations).hasSize(1); assertThat(cloudRegistry.registrations.get(0)).hasFieldOrPropertyWithValue("serviceId", serviceName); assertThat(cloudRegistry.registrations.get(0)).hasFieldOrPropertyWithValue("host", "localhost"); assertThat(cloudRegistry.registrations.get(0)).hasFieldOrPropertyWithValue("port", port); } ); }