use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.
the class EurekaServiceRegistryTests method eurekaClientGetStatusNoInstance.
@Test
public void eurekaClientGetStatusNoInstance() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
config.setAppname("myapp");
config.setInstanceId("1234");
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
when(eurekaClient.getInstanceInfo("myapp", "1234")).thenReturn(null);
EurekaRegistration registration = EurekaRegistration.builder(config).with(eurekaClient).with(mock(ApplicationInfoManager.class)).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)).build();
Object status = registry.getStatus(registration);
assertThat(status).isInstanceOf(Map.class);
Map<Object, Object> map = (Map<Object, Object>) status;
assertThat(map).hasSize(1).containsEntry("status", UNKNOWN.toString());
}
use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.
the class EurekaServiceRegistryTests method eurekaClientNotShutdownInDeregister.
@Test
public void eurekaClientNotShutdownInDeregister() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
ApplicationInfoManager applicationInfoManager = mock(ApplicationInfoManager.class);
when(applicationInfoManager.getInfo()).thenReturn(mock(InstanceInfo.class));
EurekaRegistration registration = EurekaRegistration.builder(new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()))).with(eurekaClient).with(applicationInfoManager).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)).build();
registry.deregister(registration);
verifyZeroInteractions(eurekaClient);
}
use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.
the class EurekaServiceRegistryTests method eurekaClientGetStatus.
@Test
public void eurekaClientGetStatus() {
EurekaServiceRegistry registry = new EurekaServiceRegistry();
EurekaInstanceConfigBean config = new EurekaInstanceConfigBean(new InetUtils(new InetUtilsProperties()));
config.setAppname("myapp");
config.setInstanceId("1234");
CloudEurekaClient eurekaClient = mock(CloudEurekaClient.class);
InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder().setAppName("myapp").setInstanceId("1234").setStatus(DOWN).setOverriddenStatus(UNKNOWN).build();
when(eurekaClient.getInstanceInfo("myapp", "1234")).thenReturn(instanceInfo);
EurekaRegistration registration = EurekaRegistration.builder(config).with(eurekaClient).with(mock(ApplicationInfoManager.class)).with(new EurekaClientConfigBean(), mock(ApplicationEventPublisher.class)).build();
Object status = registry.getStatus(registration);
assertThat(status).isInstanceOf(Map.class);
Map<Object, Object> map = (Map<Object, Object>) status;
assertThat(map).hasSize(2).containsEntry("status", DOWN.toString()).containsEntry("overriddenStatus", UNKNOWN.toString());
}
use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.
the class EurekaRibbonClientConfigurationTests method testSetProp.
@Test
public void testSetProp() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
EurekaRibbonClientConfiguration preprocessor = new EurekaRibbonClientConfiguration(client, "myService", configBean, false);
String serviceId = "myService";
String suffix = "mySuffix";
String value = "myValue";
DynamicStringProperty property = getProperty(getRibbonKey(serviceId, suffix));
assertEquals("property doesn't have default value", VALUE_NOT_SET, property.get());
setRibbonProperty(serviceId, suffix, value);
assertEquals("property has wrong value", value, property.get());
setRibbonProperty(serviceId, suffix, value);
assertEquals("property has wrong value", value, property.get());
}
use of org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean in project spring-cloud-netflix by spring-cloud.
the class EurekaRibbonClientConfigurationTests method basicConfigurationCreatedForLoadBalancer.
@Test
@Ignore
public void basicConfigurationCreatedForLoadBalancer() {
EurekaClientConfigBean client = new EurekaClientConfigBean();
EurekaInstanceConfigBean configBean = getEurekaInstanceConfigBean();
client.getAvailabilityZones().put(client.getRegion(), "foo");
SpringClientFactory clientFactory = new SpringClientFactory();
EurekaRibbonClientConfiguration clientPreprocessor = new EurekaRibbonClientConfiguration(client, "service", configBean, false);
clientPreprocessor.preprocess();
ILoadBalancer balancer = clientFactory.getLoadBalancer("service");
assertNotNull(balancer);
@SuppressWarnings("unchecked") ZoneAwareLoadBalancer<DiscoveryEnabledServer> aware = (ZoneAwareLoadBalancer<DiscoveryEnabledServer>) balancer;
assertTrue(aware.getServerListImpl() instanceof DomainExtractingServerList);
assertEquals("foo", ConfigurationManager.getDeploymentContext().getValue(ContextKey.zone));
}
Aggregations