Search in sources :

Example 1 with CachingServiceCallServiceDiscoveryConfiguration

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());
}
Also used : CachingServiceCallServiceDiscoveryConfiguration(org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration) StaticServiceCallServiceDiscoveryConfiguration(org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration) Test(org.junit.Test)

Aggregations

CachingServiceCallServiceDiscoveryConfiguration (org.apache.camel.model.cloud.CachingServiceCallServiceDiscoveryConfiguration)1 StaticServiceCallServiceDiscoveryConfiguration (org.apache.camel.model.cloud.StaticServiceCallServiceDiscoveryConfiguration)1 Test (org.junit.Test)1