feat:fix ut error.

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

@ -50,15 +50,13 @@ 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(PORT); serverSocket = new ServerSocket(8093);
serverSocket.accept(); serverSocket.accept();
} }
catch (IOException e) { catch (IOException e) {
@ -83,8 +81,7 @@ 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,15 +52,13 @@ 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(PORT); serverSocket = new ServerSocket(8093);
serverSocket.accept(); serverSocket.accept();
} }
catch (IOException e) { 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.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