fix: fix ConfigChangeListener ut bug (#1661)

pull/1676/head
Fishtail 2 months ago committed by GitHub
parent 25bc8120b7
commit db29d774d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -7,3 +7,4 @@
- [feat:Add log output and test scenarios in the FaultToleranceService file.](https://github.com/Tencent/spring-cloud-tencent/pull/1652)
- [fix: fix ConfigChangeListener and unit test](https://github.com/Tencent/spring-cloud-tencent/pull/1656)
- [feat: support spring-retry and feign config refresh and feign eager load support schema](https://github.com/Tencent/spring-cloud-tencent/pull/1651)
- [fix: fix ConfigChangeListener ut bug](https://github.com/Tencent/spring-cloud-tencent/pull/1661)

@ -57,7 +57,7 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
})
public class ConfigChangeListenerTest {
private static final CountDownLatch hits = new CountDownLatch(2);
private static CountDownLatch hits = new CountDownLatch(2);
@Autowired
private ApplicationEventPublisher applicationEventPublisher;
@Autowired
@ -85,13 +85,16 @@ public class ConfigChangeListenerTest {
Set<String> ketSet = new HashSet<>();
ketSet.add("timeout");
for (int i = 2; i <= 1000; i++) {
// Reset hits for each iteration
//submit change event
System.setProperty("timeout", String.valueOf(i * 1000));
EnvironmentChangeEvent event = new EnvironmentChangeEvent(applicationContext, ketSet);
applicationEventPublisher.publishEvent(event);
//after change
boolean ret = hits.await(2, TimeUnit.SECONDS);
Assertions.assertThat(ret).isEqualTo(true);
hits = new CountDownLatch(2);
Assertions.assertThat(testConfig.getChangeCnt()).isEqualTo(2 * i - 2);
Assertions.assertThat(testConfig.getSyncChangeCnt()).isEqualTo(2 * i - 2);
Assertions.assertThat(testConfig.getTimeout()).isEqualTo(i * 1000);

Loading…
Cancel
Save