use of org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration in project camel by apache.
the class CachingServiceDiscoveryTest method testCachingServiceDiscoveryConfiguration.
@Test
public void testCachingServiceDiscoveryConfiguration() throws Exception {
StaticServiceCallServiceDiscoveryConfiguration staticConf = new StaticServiceCallServiceDiscoveryConfiguration();
staticConf.setServers(Arrays.asList("no-name@localhost:1111"));
CachingServiceCallServiceDiscoveryConfiguration cachingConf = new CachingServiceCallServiceDiscoveryConfiguration();
cachingConf.setServiceDiscoveryConfiguration(staticConf);
cachingConf.setTimeout(1);
cachingConf.setUnits(TimeUnit.SECONDS);
CachingServiceDiscovery caching = (CachingServiceDiscovery) cachingConf.newInstance(context);
StaticServiceDiscovery delegate = (StaticServiceDiscovery) caching.getDelegate();
Assert.assertEquals(1, caching.getServices("no-name").size());
delegate.addServer("no-name@localhost:1112");
Assert.assertEquals(1, caching.getServices("no-name").size());
// Let the cache expire
Thread.sleep(1100);
Assert.assertEquals(2, caching.getServices("no-name").size());
}
use of org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration in project camel by apache.
the class ChainedServiceDiscoveryTest method testMultiServiceDiscoveryConfiguration.
@Test
public void testMultiServiceDiscoveryConfiguration() throws Exception {
StaticServiceCallServiceDiscoveryConfiguration staticConf1 = new StaticServiceCallServiceDiscoveryConfiguration();
staticConf1.setServers(Arrays.asList("discovery1@localhost:1111", "discovery1@localhost:1112"));
StaticServiceCallServiceDiscoveryConfiguration staticConf2 = new StaticServiceCallServiceDiscoveryConfiguration();
staticConf2.setServers(Arrays.asList("discovery1@localhost:1113", "discovery2@localhost:1114"));
ChainedServiceCallServiceDiscoveryConfiguration multiConf = new ChainedServiceCallServiceDiscoveryConfiguration();
multiConf.setServiceDiscoveryConfigurations(Arrays.asList(staticConf1, staticConf2));
ChainedServiceDiscovery discovery = (ChainedServiceDiscovery) multiConf.newInstance(context);
Assert.assertEquals(2, discovery.getDelegates().size());
Assert.assertEquals(3, discovery.getServices("discovery1").size());
Assert.assertEquals(1, discovery.getServices("discovery2").size());
}
use of org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration in project camel by apache.
the class ServiceCallConfigurationTest method testServiceDiscoveryConfiguration.
@Test
public void testServiceDiscoveryConfiguration() {
ServiceCallConfigurationDefinition conf1 = context.getServiceCallConfiguration("conf1");
assertNotNull("No ServiceCallConfiguration (1)", conf1);
assertNotNull("No ServiceDiscoveryConfiguration (1)", conf1.getServiceDiscoveryConfiguration());
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());
StaticServiceCallServiceDiscoveryConfiguration discovery2 = (StaticServiceCallServiceDiscoveryConfiguration) conf2.getServiceDiscoveryConfiguration();
assertEquals(2, discovery2.getServers().size());
assertEquals("localhost:9092", discovery2.getServers().get(0));
assertEquals("localhost:9093,localhost:9094", discovery2.getServers().get(1));
}
use of org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration 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);
}
use of org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration in project camel by apache.
the class XmlServiceCallConfigurationTest method testServiceDiscoveryConfiguration.
@Test
public void testServiceDiscoveryConfiguration() {
ServiceCallConfigurationDefinition conf1 = context.getServiceCallConfiguration("conf1");
assertNotNull("No ServiceCallConfiguration (1)", conf1);
assertNotNull("No ServiceDiscoveryConfiguration (1)", conf1.getServiceDiscoveryConfiguration());
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());
StaticServiceCallServiceDiscoveryConfiguration discovery2 = (StaticServiceCallServiceDiscoveryConfiguration) conf2.getServiceDiscoveryConfiguration();
assertEquals(2, discovery2.getServers().size());
assertEquals("localhost:9092", discovery2.getServers().get(0));
assertEquals("localhost:9093,localhost:9094", discovery2.getServers().get(1));
}
Aggregations