From 251baca8e2c2464dfdb233b29b29eadcddfd3ec3 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Wed, 2 Feb 2022 02:09:25 +0100 Subject: [PATCH] Fix the test run. --- pom.xml | 5 +++-- .../ch/fritteli/labyrinth/server/LabyrinthServer.java | 11 +++++++++-- .../fritteli/labyrinth/server/ServerConfigTest.java | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index e5a2d62..9be4803 100644 --- a/pom.xml +++ b/pom.xml @@ -15,6 +15,7 @@ 0.0.1-SNAPSHOT + 1.2.10 1.7.35 @@ -22,7 +23,7 @@ ch.fritteli.labyrinth labyrinth-generator - 0.0.2-SNAPSHOT + 0.0.2 io.vavr @@ -44,7 +45,7 @@ ch.qos.logback logback-classic - 1.2.10 + ${logback.version} org.junit.jupiter diff --git a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java b/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java index 6360325..a3a3790 100644 --- a/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java +++ b/src/main/java/ch/fritteli/labyrinth/server/LabyrinthServer.java @@ -27,7 +27,8 @@ import java.net.InetSocketAddress; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; +import java.util.concurrent.SynchronousQueue; +import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Function; @@ -37,7 +38,13 @@ public class LabyrinthServer { @NonNull private final HttpServer httpServer; @NonNull - private final ExecutorService executorService = Executors.newCachedThreadPool(); + private final ExecutorService executorService = new ThreadPoolExecutor( + 0, + 1_000, + 5, + TimeUnit.SECONDS, + new SynchronousQueue<>() + ); public LabyrinthServer(@NonNull final ServerConfig config) throws IOException, URISyntaxException { this.httpServer = HttpServer.create(new InetSocketAddress(config.getAddress(), config.getPort()), 5); diff --git a/src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java b/src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java index 277abd3..23e31d7 100644 --- a/src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java +++ b/src/test/java/ch/fritteli/labyrinth/server/ServerConfigTest.java @@ -4,7 +4,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.net.UnknownHostException; -import java.util.Properties; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -12,7 +11,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows; class ServerConfigTest { @BeforeEach void clearSysProperties() { - System.setProperties(new Properties()); + System.clearProperty(ServerConfig.SYSPROP_HOST); + System.clearProperty(ServerConfig.SYSPROP_PORT); } @Test