feat:fix ut error.

pull/567/head
Haotian Zhang 3 years ago
parent 4d7f2f95ca
commit 0e9aaf2e8c

@ -50,13 +50,15 @@ import static org.assertj.core.api.Assertions.assertThat;
*/ */
public class ConditionalOnReflectRefreshTypeTest { public class ConditionalOnReflectRefreshTypeTest {
private static final int PORT = 18093;
private static ServerSocket serverSocket; private static ServerSocket serverSocket;
@BeforeClass @BeforeClass
public static void before() { public static void before() {
new Thread(() -> { new Thread(() -> {
try { try {
serverSocket = new ServerSocket(18093); serverSocket = new ServerSocket(PORT);
serverSocket.accept(); serverSocket.accept();
} }
catch (IOException e) { catch (IOException e) {
@ -81,7 +83,8 @@ public class ConditionalOnReflectRefreshTypeTest {
.withPropertyValues("server.port=" + 8080) .withPropertyValues("server.port=" + 8080)
.withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081") .withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081")
.withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT) .withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT)
.withPropertyValues("spring.cloud.polaris.config.enabled=true"); .withPropertyValues("spring.cloud.polaris.config.enabled=true")
.withPropertyValues("spring.cloud.polaris.config.port=" + PORT);
contextRunner.run(context -> { contextRunner.run(context -> {
assertThat(context).hasSingleBean(PlaceholderHelper.class); assertThat(context).hasSingleBean(PlaceholderHelper.class);
assertThat(context).hasSingleBean(SpringValueRegistry.class); assertThat(context).hasSingleBean(SpringValueRegistry.class);

@ -52,13 +52,15 @@ import org.springframework.stereotype.Component;
*/ */
public class SpringValueProcessorTest { public class SpringValueProcessorTest {
private static final int PORT = 18093;
private static ServerSocket serverSocket; private static ServerSocket serverSocket;
@BeforeClass @BeforeClass
public static void before() { public static void before() {
new Thread(() -> { new Thread(() -> {
try { try {
serverSocket = new ServerSocket(18093); serverSocket = new ServerSocket(PORT);
serverSocket.accept(); serverSocket.accept();
} }
catch (IOException e) { catch (IOException e) {
@ -83,6 +85,7 @@ public class SpringValueProcessorTest {
.withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081") .withPropertyValues("spring.cloud.polaris.address=grpc://127.0.0.1:10081")
.withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT) .withPropertyValues("spring.cloud.polaris.config.refresh-type=" + RefreshType.REFLECT)
.withPropertyValues("spring.cloud.polaris.config.enabled=true") .withPropertyValues("spring.cloud.polaris.config.enabled=true")
.withPropertyValues("spring.cloud.polaris.config.port=" + PORT)
.withPropertyValues("timeout=10000"); .withPropertyValues("timeout=10000");
contextRunner.run(context -> { contextRunner.run(context -> {
SpringValueRegistry springValueRegistry = context.getBean(SpringValueRegistry.class); SpringValueRegistry springValueRegistry = context.getBean(SpringValueRegistry.class);

Loading…
Cancel
Save