|
|
@ -18,16 +18,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
package com.tencent.cloud.polaris.config.listener;
|
|
|
|
package com.tencent.cloud.polaris.config.listener;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
|
|
import com.tencent.cloud.polaris.config.annotation.PolarisConfigKVFileChangeListener;
|
|
|
|
|
|
|
|
import com.tencent.polaris.configuration.api.core.ConfigPropertyChangeInfo;
|
|
|
|
|
|
|
|
import org.assertj.core.api.Assertions;
|
|
|
|
import org.assertj.core.api.Assertions;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
@ -38,7 +36,9 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
|
|
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.DEFINED_PORT;
|
|
|
|
import com.google.common.collect.Sets;
|
|
|
|
|
|
|
|
import com.tencent.cloud.polaris.config.annotation.PolarisConfigKVFileChangeListener;
|
|
|
|
|
|
|
|
import com.tencent.polaris.configuration.api.core.ConfigPropertyChangeInfo;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Integration testing for change listener.
|
|
|
|
* Integration testing for change listener.
|
|
|
@ -104,7 +104,7 @@ public class ConfigChangeListenerTest {
|
|
|
|
@PolarisConfigKVFileChangeListener(interestedKeys = {"timeout"})
|
|
|
|
@PolarisConfigKVFileChangeListener(interestedKeys = {"timeout"})
|
|
|
|
public void configChangedListener(ConfigChangeEvent event) {
|
|
|
|
public void configChangedListener(ConfigChangeEvent event) {
|
|
|
|
ConfigPropertyChangeInfo changeInfo = event.getChange("timeout");
|
|
|
|
ConfigPropertyChangeInfo changeInfo = event.getChange("timeout");
|
|
|
|
timeout = Integer.parseInt(changeInfo.getNewValue());
|
|
|
|
timeout = Integer.parseInt((String)changeInfo.getNewValue());
|
|
|
|
changeCnt++;
|
|
|
|
changeCnt++;
|
|
|
|
hits.countDown();
|
|
|
|
hits.countDown();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -112,7 +112,7 @@ public class ConfigChangeListenerTest {
|
|
|
|
@PolarisConfigKVFileChangeListener(interestedKeyPrefixes = {"timeout"})
|
|
|
|
@PolarisConfigKVFileChangeListener(interestedKeyPrefixes = {"timeout"})
|
|
|
|
public void configChangedListener2(ConfigChangeEvent event) {
|
|
|
|
public void configChangedListener2(ConfigChangeEvent event) {
|
|
|
|
ConfigPropertyChangeInfo changeInfo = event.getChange("timeout");
|
|
|
|
ConfigPropertyChangeInfo changeInfo = event.getChange("timeout");
|
|
|
|
timeout = Integer.parseInt(changeInfo.getNewValue());
|
|
|
|
timeout = Integer.parseInt((String)changeInfo.getNewValue());
|
|
|
|
changeCnt++;
|
|
|
|
changeCnt++;
|
|
|
|
hits.countDown();
|
|
|
|
hits.countDown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|