Search in sources :

Example 1 with ConfigClientProperties

use of org.springframework.cloud.config.client.ConfigClientProperties in project spring-cloud-netflix by spring-cloud.

the class DiscoveryClientConfigServiceAutoConfigurationTests method onWhenRequested.

@Test
public void onWhenRequested() throws Exception {
    setup("spring.cloud.config.discovery.enabled=true", "eureka.instance.metadataMap.foo:bar", "eureka.instance.nonSecurePort:7001", "eureka.instance.hostname:foo");
    assertEquals(1, this.context.getBeanNamesForType(EurekaDiscoveryClientConfigServiceAutoConfiguration.class).length);
    EurekaClient eurekaClient = this.context.getParent().getBean(EurekaClient.class);
    Mockito.verify(eurekaClient, times(2)).getInstancesByVipAddress(DEFAULT_CONFIG_SERVER, false);
    Mockito.verify(eurekaClient, times(1)).shutdown();
    ConfigClientProperties locator = this.context.getBean(ConfigClientProperties.class);
    assertEquals("http://foo:7001/", locator.getRawUri());
    ApplicationInfoManager infoManager = this.context.getBean(ApplicationInfoManager.class);
    assertEquals("bar", infoManager.getInfo().getMetadata().get("foo"));
}
Also used : EurekaClient(com.netflix.discovery.EurekaClient) CloudEurekaClient(org.springframework.cloud.netflix.eureka.CloudEurekaClient) ConfigClientProperties(org.springframework.cloud.config.client.ConfigClientProperties) ApplicationInfoManager(com.netflix.appinfo.ApplicationInfoManager) Test(org.junit.Test)

Example 2 with ConfigClientProperties

use of org.springframework.cloud.config.client.ConfigClientProperties in project spring-cloud-consul by spring-cloud.

the class DiscoveryClientConfigServiceAutoConfigurationTests method onWhenRequested.

@Test
public void onWhenRequested() throws Exception {
    ConsulTestcontainers.start();
    Integer port = ConsulTestcontainers.getPort();
    String host = ConsulTestcontainers.getHost();
    setup("server.port=0", "spring.cloud.config.discovery.enabled=true", "spring.cloud.consul.port=" + port, "spring.cloud.consul.host=" + host, "logging.level.org.springframework.cloud.config.client=DEBUG", "spring.cloud.consul.discovery.catalog-services-watch.enabled=false", "spring.cloud.consul.discovery.test.enabled:true", "spring.application.name=discoveryclientconfigservicetest", "spring.jmx.enabled=false", "spring.cloud.consul.discovery.port:7001", "spring.cloud.consul.discovery.hostname:foo", "spring.cloud.config.discovery.service-id:configserver");
    assertThat(this.context.getBeanNamesForType(ConsulConfigServerAutoConfiguration.class).length).isEqualTo(1);
    ConsulDiscoveryClient client = this.context.getParent().getBean(ConsulDiscoveryClient.class);
    verify(client, atLeast(2)).getInstances("configserver");
    ConfigClientProperties locator = this.context.getBean(ConfigClientProperties.class);
    assertThat(locator.getUri()[0]).isEqualTo("http://foo:7001/");
}
Also used : ConsulDiscoveryClient(org.springframework.cloud.consul.discovery.ConsulDiscoveryClient) ConfigClientProperties(org.springframework.cloud.config.client.ConfigClientProperties) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 ConfigClientProperties (org.springframework.cloud.config.client.ConfigClientProperties)2 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)1 EurekaClient (com.netflix.discovery.EurekaClient)1 ConsulDiscoveryClient (org.springframework.cloud.consul.discovery.ConsulDiscoveryClient)1 CloudEurekaClient (org.springframework.cloud.netflix.eureka.CloudEurekaClient)1