[FIX] StartLaunchServerTest теперь нормально работает.

This commit is contained in:
Zaxar163 2020-04-05 11:30:32 +03:00
parent 34e941ddfd
commit 68c06de23e
2 changed files with 12 additions and 3 deletions

View file

@ -23,6 +23,7 @@ public NettyServerSocketHandler(LaunchServer server) {
@Override @Override
public void close() { public void close() {
if (nettyServer == null) return;
nettyServer.close(); nettyServer.close();
nettyServer.service.channels.close(); nettyServer.service.channels.close();
} }

View file

@ -1,5 +1,6 @@
package pro.gravit.launchserver; package pro.gravit.launchserver;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir; import org.junit.jupiter.api.io.TempDir;
@ -28,7 +29,7 @@ public class StartLaunchServerTest {
public static LaunchServer launchServer; public static LaunchServer launchServer;
@BeforeAll @BeforeAll
public static void prepare() throws Exception { public static void prepare() throws Throwable {
LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(modulesDir, configDir, null); LaunchServerModulesManager modulesManager = new LaunchServerModulesManager(modulesDir, configDir, null);
LaunchServerConfig config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST); LaunchServerConfig config = LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST);
Launcher.gsonManager = new LaunchServerGsonManager(modulesManager); Launcher.gsonManager = new LaunchServerGsonManager(modulesManager);
@ -48,12 +49,14 @@ public static void prepare() throws Exception {
.setLaunchServerConfigManager(new LaunchServer.LaunchServerConfigManager() { .setLaunchServerConfigManager(new LaunchServer.LaunchServerConfigManager() {
@Override @Override
public LaunchServerConfig readConfig() { public LaunchServerConfig readConfig() {
return null; return LaunchServerConfig.getDefault(LaunchServer.LaunchServerEnv.TEST);
} }
@Override @Override
public LaunchServerRuntimeConfig readRuntimeConfig() { public LaunchServerRuntimeConfig readRuntimeConfig() {
return null; LaunchServerRuntimeConfig r = new LaunchServerRuntimeConfig();
r.reset();
return r;
} }
@Override @Override
@ -71,6 +74,11 @@ public void writeRuntimeConfig(LaunchServerRuntimeConfig config) {
launchServer = builder.build(); launchServer = builder.build();
} }
@AfterAll
public static void complete() throws Throwable {
launchServer.close();
}
@Test @Test
public void start() { public void start() {
launchServer.run(); launchServer.run();