Search in sources :

Example 1 with RibbonResourceFactory

use of com.netflix.ribbon.RibbonResourceFactory in project ribbon by Netflix.

the class ClientPropertiesTest method testAnnotation.

@Test
public void testAnnotation() {
    MyTransportFactory transportFactory = new MyTransportFactory(ClientConfigFactory.DEFAULT);
    RibbonResourceFactory resourceFactory = new DefaultResourceFactory(ClientConfigFactory.DEFAULT, transportFactory);
    RibbonDynamicProxy.newInstance(SampleMovieService.class, resourceFactory, ClientConfigFactory.DEFAULT, transportFactory);
    IClientConfig clientConfig = transportFactory.getClientConfig();
    assertEquals(1000, clientConfig.get(Keys.ConnectTimeout).longValue());
    assertEquals(2000, clientConfig.get(Keys.ReadTimeout).longValue());
    Configuration config = ConfigurationManager.getConfigInstance();
    assertEquals("2000", config.getProperty("SampleMovieService.ribbon.ReadTimeout"));
    assertEquals("1000", config.getProperty("SampleMovieService.ribbon.ConnectTimeout"));
    config.setProperty("SampleMovieService.ribbon.ReadTimeout", "5000");
    assertEquals(5000, clientConfig.get(Keys.ReadTimeout).longValue());
}
Also used : Configuration(org.apache.commons.configuration.Configuration) DefaultResourceFactory(com.netflix.ribbon.DefaultResourceFactory) IClientConfig(com.netflix.client.config.IClientConfig) RibbonResourceFactory(com.netflix.ribbon.RibbonResourceFactory) Test(org.junit.Test)

Example 2 with RibbonResourceFactory

use of com.netflix.ribbon.RibbonResourceFactory in project ribbon by Netflix.

the class ClientPropertiesTest method testNoExportToArchaius.

@Test
public void testNoExportToArchaius() {
    MyTransportFactory transportFactory = new MyTransportFactory(ClientConfigFactory.DEFAULT);
    RibbonResourceFactory resourceFactory = new DefaultResourceFactory(ClientConfigFactory.DEFAULT, transportFactory);
    RibbonDynamicProxy.newInstance(MovieService.class, resourceFactory, ClientConfigFactory.DEFAULT, transportFactory);
    IClientConfig clientConfig = transportFactory.getClientConfig();
    assertEquals(1000, clientConfig.get(Keys.ConnectTimeout).longValue());
    assertEquals(3000, clientConfig.get(Keys.ReadTimeout).longValue());
    assertEquals(0, clientConfig.get(Keys.MaxAutoRetriesNextServer).longValue());
    Configuration config = ConfigurationManager.getConfigInstance();
    assertNull(config.getProperty("MovieService.ribbon.ReadTimeout"));
    config.setProperty("MovieService.ribbon.ReadTimeout", "5000");
    assertEquals(5000, clientConfig.get(Keys.ReadTimeout).longValue());
}
Also used : Configuration(org.apache.commons.configuration.Configuration) DefaultResourceFactory(com.netflix.ribbon.DefaultResourceFactory) IClientConfig(com.netflix.client.config.IClientConfig) RibbonResourceFactory(com.netflix.ribbon.RibbonResourceFactory) Test(org.junit.Test)

Aggregations

IClientConfig (com.netflix.client.config.IClientConfig)2 DefaultResourceFactory (com.netflix.ribbon.DefaultResourceFactory)2 RibbonResourceFactory (com.netflix.ribbon.RibbonResourceFactory)2 Configuration (org.apache.commons.configuration.Configuration)2 Test (org.junit.Test)2