use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project spring-cloud-netflix by spring-cloud.
the class RefreshablePeerEurekaNodesTests method notUpdatedForRelaxedKeys.
@Test
public void notUpdatedForRelaxedKeys() {
changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", // to force defaultZone
"eureka.client.region=unavailable-region", "eureka.client.service-url.defaultZone=http://defaul-host6:8678/eureka/");
this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton("eureka.client.serviceUrl.defaultZone")));
assertFalse("PeerEurekaNodes' are updated for keys with relaxed binding", serviceUrlMatches("http://defaul-host6:8678/eureka/"));
}
use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project spring-cloud-netflix by spring-cloud.
the class RefreshablePeerEurekaNodesTests method updatedWhenRegionChanged.
@Test
// FIXME 2.0.0
@Ignore
public void updatedWhenRegionChanged() {
changeProperty("eureka.client.use-dns-for-fetching-service-urls=false", "eureka.client.region=region1", "eureka.client.availability-zones.region1=region1-zone", "eureka.client.availability-zones.region2=region2-zone", "eureka.client.service-url.region1-zone=http://region1-zone-host:8678/eureka/", "eureka.client.service-url.region2-zone=http://region2-zone-host:8678/eureka/");
this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton(REGION)));
assertTrue("PeerEurekaNodes' are not updated when eureka.client.region is changed", serviceUrlMatches("http://region1-zone-host:8678/eureka/"));
changeProperty("eureka.client.region=region2");
this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton(REGION)));
assertTrue("PeerEurekaNodes' are not updated when eureka.client.region is changed", serviceUrlMatches("http://region2-zone-host:8678/eureka/"));
}
use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project cas by apereo.
the class RegisteredServicesEventListenerTests method verifyServiceExpirationWithRemovalEvent.
@Test
public void verifyServiceExpirationWithRemovalEvent() {
val registeredService = RegisteredServiceTestUtils.getRegisteredService();
val contact = new DefaultRegisteredServiceContact();
contact.setName("Test");
contact.setEmail("casuser@example.org");
contact.setPhone("13477465421");
registeredService.getContacts().add(contact);
val listener = new DefaultRegisteredServicesEventListener(this.servicesManager, casProperties, communicationsManager);
listener.handleRefreshEvent(new CasRegisteredServicesRefreshEvent(this));
listener.handleEnvironmentChangeEvent(new EnvironmentChangeEvent(Set.of()));
val event = new CasRegisteredServiceExpiredEvent(this, registeredService, true);
listener.handleRegisteredServiceExpiredEvent(event);
}
use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project cas by apereo.
the class DefaultServiceRegistryInitializerEventListenerTests method verifyOperation.
@Test
public void verifyOperation() {
val listener = new DefaultServiceRegistryInitializerEventListener(mock(ServiceRegistryInitializer.class));
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
listener.handleConfigurationModifiedEvent(new CasConfigurationModifiedEvent(this, true));
}
});
assertDoesNotThrow(new Executable() {
@Override
public void execute() {
listener.handleRefreshEvent(new EnvironmentChangeEvent(Set.of()));
}
});
}
use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project spring-cloud-netflix by spring-cloud.
the class ArchaiusAutoConfigurationTests method environmentChangeEventPropagated.
@Test
public void environmentChangeEventPropagated() {
this.context = new AnnotationConfigApplicationContext(ArchaiusAutoConfiguration.class);
ConfigurationManager.getConfigInstance().addConfigurationListener(new ConfigurationListener() {
@Override
public void configurationChanged(ConfigurationEvent event) {
if (event.getPropertyName().equals("my.prop")) {
ArchaiusAutoConfigurationTests.this.propertyValue = event.getPropertyValue();
}
}
});
EnvironmentTestUtils.addEnvironment(this.context, "my.prop=my.newval");
this.context.publishEvent(new EnvironmentChangeEvent(Collections.singleton("my.prop")));
assertEquals("my.newval", this.propertyValue);
}
Aggregations