fix: fix ConfigChangeListener ut bug (#1660)

2022
Fishtail 2 months ago committed by GitHub
parent 4894ab83c0
commit d69052b72d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -4,3 +4,4 @@
- [fix:fix PolarisContextProperties instantiated twice causing NPE.](https://github.com/Tencent/spring-cloud-tencent/pull/1640) - [fix:fix PolarisContextProperties instantiated twice causing NPE.](https://github.com/Tencent/spring-cloud-tencent/pull/1640)
- [fix: fix ConfigChangeListener and unit test](https://github.com/Tencent/spring-cloud-tencent/pull/1655) - [fix: fix ConfigChangeListener and unit test](https://github.com/Tencent/spring-cloud-tencent/pull/1655)
- [feat: support spring-retry and feign config refresh and feign eager load support schema](https://github.com/Tencent/spring-cloud-tencent/pull/1650) - [feat: support spring-retry and feign config refresh and feign eager load support schema](https://github.com/Tencent/spring-cloud-tencent/pull/1650)
- [fix: fix ConfigChangeListener ut bug](https://github.com/Tencent/spring-cloud-tencent/pull/1660)

@ -57,7 +57,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
}) })
public class ConfigChangeListenerTest { public class ConfigChangeListenerTest {
private static final CountDownLatch hits = new CountDownLatch(2); private static CountDownLatch hits = new CountDownLatch(2);
@Autowired @Autowired
private ApplicationEventPublisher applicationEventPublisher; private ApplicationEventPublisher applicationEventPublisher;
@Autowired @Autowired
@ -90,8 +90,10 @@ public class ConfigChangeListenerTest {
EnvironmentChangeEvent event = new EnvironmentChangeEvent(applicationContext, ketSet); EnvironmentChangeEvent event = new EnvironmentChangeEvent(applicationContext, ketSet);
applicationEventPublisher.publishEvent(event); applicationEventPublisher.publishEvent(event);
//after change //after change
//Reset hits for each iteration
boolean ret = hits.await(2, TimeUnit.SECONDS); boolean ret = hits.await(2, TimeUnit.SECONDS);
Assertions.assertThat(ret).isEqualTo(true); Assertions.assertThat(ret).isEqualTo(true);
hits = new CountDownLatch(2);
Assertions.assertThat(testConfig.getChangeCnt()).isEqualTo(2 * i - 2); Assertions.assertThat(testConfig.getChangeCnt()).isEqualTo(2 * i - 2);
Assertions.assertThat(testConfig.getSyncChangeCnt()).isEqualTo(2 * i - 2); Assertions.assertThat(testConfig.getSyncChangeCnt()).isEqualTo(2 * i - 2);
Assertions.assertThat(testConfig.getTimeout()).isEqualTo(i * 1000); Assertions.assertThat(testConfig.getTimeout()).isEqualTo(i * 1000);

Loading…
Cancel
Save