Search in sources :

Example 11 with EnvironmentChangeEvent

use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project spring-cloud-netflix by spring-cloud.

the class GZIPCompression method zuulHostKeysUpdateHttpClient.

@Test
public void zuulHostKeysUpdateHttpClient() {
    setupContext();
    SimpleHostRoutingFilter filter = getFilter();
    CloseableHttpClient httpClient = (CloseableHttpClient) ReflectionTestUtils.getField(filter, "httpClient");
    EnvironmentChangeEvent event = new EnvironmentChangeEvent(Collections.singleton("zuul.host.mykey"));
    filter.onPropertyChange(event);
    CloseableHttpClient newhttpClient = (CloseableHttpClient) ReflectionTestUtils.getField(filter, "httpClient");
    Assertions.assertThat(httpClient).isNotEqualTo(newhttpClient);
}
Also used : CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) EnvironmentChangeEvent(org.springframework.cloud.context.environment.EnvironmentChangeEvent) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Example 12 with EnvironmentChangeEvent

use of org.springframework.cloud.context.environment.EnvironmentChangeEvent in project logging-log4j2 by apache.

the class Log4j2EventListenerTest method test.

@Test
public void test() throws Exception {
    AtomicInteger count = new AtomicInteger(0);
    Source source = new Source(new File("test.java"));
    loggerContextRule.getLoggerContext().getConfiguration().getWatchManager().watch(source, new TestWatcher(count));
    publisher.publishEvent(new EnvironmentChangeEvent(new HashSet<>()));
    assertTrue(count.get() > 0);
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EnvironmentChangeEvent(org.springframework.cloud.context.environment.EnvironmentChangeEvent) File(java.io.File) Source(org.apache.logging.log4j.core.util.Source) HashSet(java.util.HashSet) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

EnvironmentChangeEvent (org.springframework.cloud.context.environment.EnvironmentChangeEvent)12 Test (org.junit.Test)9 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)9 HashSet (java.util.HashSet)3 lombok.val (lombok.val)2 Ignore (org.junit.Ignore)2 Test (org.junit.jupiter.api.Test)2 ApplicationInfoManager (com.netflix.appinfo.ApplicationInfoManager)1 EurekaClientConfig (com.netflix.discovery.EurekaClientConfig)1 EurekaServerConfig (com.netflix.eureka.EurekaServerConfig)1 PeerAwareInstanceRegistry (com.netflix.eureka.registry.PeerAwareInstanceRegistry)1 ServerCodecs (com.netflix.eureka.resources.ServerCodecs)1 File (java.io.File)1 List (java.util.List)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ConfigurationEvent (org.apache.commons.configuration.event.ConfigurationEvent)1 ConfigurationListener (org.apache.commons.configuration.event.ConfigurationListener)1 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)1 Source (org.apache.logging.log4j.core.util.Source)1 CasConfigurationModifiedEvent (org.apereo.cas.support.events.config.CasConfigurationModifiedEvent)1