Fixes test to use new ContextRefreshedWithApplicationEvent

This commit is contained in:
spencergibb
2023-06-22 09:36:37 -04:00
parent 706d97f3a2
commit 17692c1253

View File

@@ -39,7 +39,6 @@ import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
@@ -49,6 +48,7 @@ import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.health.DiscoveryClientHealthIndicator;
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationProperties;
import org.springframework.cloud.commons.util.UtilAutoConfiguration;
import org.springframework.cloud.context.config.ContextRefreshedWithApplicationEvent;
import org.springframework.cloud.context.refresh.ContextRefresher;
import org.springframework.cloud.context.scope.GenericScope;
import org.springframework.cloud.netflix.eureka.config.DiscoveryClientOptionalArgsConfiguration;
@@ -471,9 +471,9 @@ class EurekaClientAutoConfigurationTests {
ContextRefresher refresher = this.context.getBean(ContextRefresher.class);
if (refresher instanceof ApplicationListener) {
ApplicationListener<ApplicationPreparedEvent> listener = (ApplicationListener) refresher;
listener.onApplicationEvent(
new ApplicationPreparedEvent(Mockito.mock(SpringApplication.class), new String[0], this.context));
ApplicationListener<ContextRefreshedWithApplicationEvent> listener = (ApplicationListener) refresher;
listener.onApplicationEvent(new ContextRefreshedWithApplicationEvent(Mockito.mock(SpringApplication.class),
new String[0], this.context));
}
refresher.refresh();