use of org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration 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());
}
Aggregations