Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 165dbeb

Browse files
authored
Fix throttler tests (#114)
Throttler tests do not work unless the server is actually multithreaded
1 parent fea80c4 commit 165dbeb

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

src/test/java/com/kttdevelopment/simplehttpserver/handlers/throttler/ExchangeThrottlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import java.net.URI;
1313
import java.net.http.*;
1414
import java.time.Duration;
15-
import java.util.concurrent.ExecutionException;
16-
import java.util.concurrent.TimeUnit;
15+
import java.util.concurrent.*;
1716

1817
public final class ExchangeThrottlerTest {
1918

@@ -22,6 +21,7 @@ public void exchangeThrottler() throws IOException{
2221
final int port = 8080;
2322

2423
final SimpleHttpServer server = SimpleHttpServer.create(port);
24+
server.setExecutor(Executors.newCachedThreadPool());
2525

2626
final String context = "";
2727
server.createContext(

src/test/java/com/kttdevelopment/simplehttpserver/handlers/throttler/ServerExchangeThrottlerTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public final void serverExchangeThrottler() throws IOException{
1919
final int port = 8080;
2020

2121
final SimpleHttpServer server = SimpleHttpServer.create(port);
22+
server.setExecutor(Executors.newCachedThreadPool());
2223

2324
final String context = "";
2425
server.createContext(

src/test/java/com/kttdevelopment/simplehttpserver/handlers/throttler/ServerSessionThrottlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import java.net.URI;
1212
import java.net.http.*;
1313
import java.time.Duration;
14-
import java.util.concurrent.ExecutionException;
15-
import java.util.concurrent.TimeUnit;
14+
import java.util.concurrent.*;
1615

1716
public final class ServerSessionThrottlerTest {
1817

@@ -21,6 +20,7 @@ public final void serverSessionThrottler() throws IOException{
2120
final int port = 8080;
2221

2322
final SimpleHttpServer server = SimpleHttpServer.create(port);
23+
server.setExecutor(Executors.newCachedThreadPool());
2424
final HttpSessionHandler sessionHandler = new HttpSessionHandler();
2525
server.setHttpSessionHandler(sessionHandler);
2626

src/test/java/com/kttdevelopment/simplehttpserver/handlers/throttler/SessionThrottlerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import java.net.URI;
1212
import java.net.http.*;
1313
import java.time.Duration;
14-
import java.util.concurrent.ExecutionException;
15-
import java.util.concurrent.TimeUnit;
14+
import java.util.concurrent.*;
1615

1716
public final class SessionThrottlerTest {
1817

@@ -21,6 +20,7 @@ public final void sessionThrottler() throws IOException{
2120
final int port = 8080;
2221

2322
final SimpleHttpServer server = SimpleHttpServer.create(port);
23+
server.setExecutor(Executors.newCachedThreadPool());
2424
final HttpSessionHandler sessionHandler = new HttpSessionHandler();
2525
server.setHttpSessionHandler(sessionHandler);
2626

0 commit comments

Comments
 (0)