From afe89e0f6d009d4da7a4787aa980f243e2027355 Mon Sep 17 00:00:00 2001 From: Haotian Zhang <928016560@qq.com> Date: Wed, 7 Sep 2022 13:38:40 +0800 Subject: [PATCH] feat:fix ut error. --- .../condition/ConditionalOnReflectRefreshTypeTest.java | 7 ++----- .../config/spring/annotation/SpringValueProcessorTest.java | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-) 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 b5c896bf1..182883ab2 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,15 +50,13 @@ 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(PORT); + serverSocket = new ServerSocket(8093); serverSocket.accept(); } catch (IOException e) { @@ -83,8 +81,7 @@ 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.port=" + PORT); + .withPropertyValues("spring.cloud.polaris.config.enabled=true"); 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 c9b49cbae..99f1b9b14 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,15 +52,13 @@ 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(PORT); + serverSocket = new ServerSocket(8093); serverSocket.accept(); } catch (IOException e) { @@ -85,7 +83,6 @@ 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);