From 68c06de23ecd55eebe8afdb77b9bde2373b3d83a Mon Sep 17 00:00:00 2001 From: Zaxar163 Date: Sun, 5 Apr 2020 11:30:32 +0300 Subject: [PATCH] =?UTF-8?q?[FIX]=20StartLaunchServerTest=20=D1=82=D0=B5?= =?UTF-8?q?=D0=BF=D0=B5=D1=80=D1=8C=20=D0=BD=D0=BE=D1=80=D0=BC=D0=B0=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D0=BE=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5?= =?UTF-8?q?=D1=82.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../socket/handlers/NettyServerSocketHandler.java | 1 + .../gravit/launchserver/StartLaunchServerTest.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java index fc171501..79e78fb7 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/handlers/NettyServerSocketHandler.java @@ -23,6 +23,7 @@ public NettyServerSocketHandler(LaunchServer server) { @Override public void close() { + if (nettyServer == null) return; nettyServer.close(); nettyServer.service.channels.close(); } diff --git a/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java b/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java index a5dcfad1..bdebfc90 100644 --- a/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java +++ b/LaunchServer/src/test/java/pro/gravit/launchserver/StartLaunchServerTest.java @@ -1,5 +1,6 @@ package pro.gravit.launchserver; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; @@ -28,7 +29,7 @@ public class StartLaunchServerTest { public static LaunchServer launchServer; @BeforeAll - public static void prepare() throws Exception { + public static void prepare() throws Throwable { LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(modulesDir, configDir, null); LaunchServerConfig config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST); Launcher.gsonManager = new LaunchServerGsonManager(modulesManager); @@ -48,12 +49,14 @@ public static void prepare() throws Exception { .setLaunchServerConfigManager(new LaunchServer.LaunchServerConfigManager() { @Override public LaunchServerConfig readConfig() { - return null; + return LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST); } @Override public LaunchServerRuntimeConfig readRuntimeConfig() { - return null; + LaunchServerRuntimeConfig r = new LaunchServerRuntimeConfig(); + r.reset(); + return r; } @Override @@ -71,6 +74,11 @@ public void writeRuntimeConfig(LaunchServerRuntimeConfig config) { launchServer = builder.build(); } + @AfterAll + public static void complete() throws Throwable { + launchServer.close(); + } + @Test public void start() { launchServer.run();