From f4d146c25984123d51ce36ef0a9f10dd3224de62 Mon Sep 17 00:00:00 2001 From: hantsy Date: Tue, 31 Oct 2023 19:52:00 +0800 Subject: [PATCH] chore: clean codes --- .../src/main/java/com/example/demo/Application.java | 10 ++-------- .../test/java/com/example/demo/IntegrationTests.java | 4 +--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/integration/src/main/java/com/example/demo/Application.java b/integration/src/main/java/com/example/demo/Application.java index cc5ed82c7..61361a281 100644 --- a/integration/src/main/java/com/example/demo/Application.java +++ b/integration/src/main/java/com/example/demo/Application.java @@ -2,15 +2,9 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.AnnotationConfigApplicationContext; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.context.annotation.PropertySource; +import org.springframework.context.annotation.*; import org.springframework.http.server.reactive.HttpHandler; import org.springframework.http.server.reactive.ReactorHttpHandlerAdapter; -import org.springframework.web.reactive.config.EnableWebFlux; import org.springframework.web.server.adapter.WebHttpHandlerBuilder; import reactor.netty.http.server.HttpServer; @@ -24,7 +18,7 @@ public class Application { public static void main(String[] args) throws Exception { try (AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext( - Application.class)) { + Application.class)) { context.getBean(HttpServer.class).bindNow().onDispose().block(); } } diff --git a/integration/src/test/java/com/example/demo/IntegrationTests.java b/integration/src/test/java/com/example/demo/IntegrationTests.java index d5bdc5057..8872e9a98 100644 --- a/integration/src/test/java/com/example/demo/IntegrationTests.java +++ b/integration/src/test/java/com/example/demo/IntegrationTests.java @@ -40,9 +40,7 @@ public void setup() { @AfterEach public void tearDown() { - if (this.disposableServer != null && !this.disposableServer.isDisposed()) { - this.disposableServer.dispose(); - } + this.disposableServer.disposeNow(); } @Test