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();