diff --git a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/condition/ConditionalOnReflectRefreshTypeTest.java b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/condition/ConditionalOnReflectRefreshTypeTest.java index c12be139b..b5c896bf1 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/condition/ConditionalOnReflectRefreshTypeTest.java +++ b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/condition/ConditionalOnReflectRefreshTypeTest.java @@ -50,13 +50,15 @@ import static org.assertj.core.api.Assertions.assertThat; */ public class ConditionalOnReflectRefreshTypeTest { + private static final int PORT = 18093; + private static ServerSocket serverSocket; @BeforeClass public static void before() { new Thread(() -> { try { - serverSocket = new ServerSocket(18093); + serverSocket = new ServerSocket(PORT); serverSocket.accept(); } catch (IOException e) { @@ -81,7 +83,8 @@ public class ConditionalOnReflectRefreshTypeTest { .withPropertyValues("server.port=" + 8080) .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.enabled=true"); + .withPropertyValues("spring.cloud.polaris.config.enabled=true") + .withPropertyValues("spring.cloud.polaris.config.port=" + PORT); contextRunner.run(context -> { assertThat(context).hasSingleBean(PlaceholderHelper.class); assertThat(context).hasSingleBean(SpringValueRegistry.class); diff --git a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java index f474faeb2..c9b49cbae 100644 --- a/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java +++ b/spring-cloud-starter-tencent-polaris-config/src/test/java/com/tencent/cloud/polaris/config/spring/annotation/SpringValueProcessorTest.java @@ -52,13 +52,15 @@ import org.springframework.stereotype.Component; */ public class SpringValueProcessorTest { + private static final int PORT = 18093; + private static ServerSocket serverSocket; @BeforeClass public static void before() { new Thread(() -> { try { - serverSocket = new ServerSocket(18093); + serverSocket = new ServerSocket(PORT); serverSocket.accept(); } 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.config.refresh-type=" + RefreshType.REFLECT) .withPropertyValues("spring.cloud.polaris.config.enabled=true") + .withPropertyValues("spring.cloud.polaris.config.port=" + PORT) .withPropertyValues("timeout=10000"); contextRunner.run(context -> { SpringValueRegistry springValueRegistry = context.getBean(SpringValueRegistry.class);