55import org .junit .jupiter .api .*;
66
77import java .io .IOException ;
8- import java .io .UncheckedIOException ;
98import java .util .concurrent .Executors ;
109
1110final class ThrottlerTests {
@@ -52,7 +51,7 @@ final class Exchange {
5251 @ Test
5352 final void testExchange0 (){
5453 server .createContext ("exchange/0" , new ThrottledHandler (ThrottlerTests .ExchangeThrottler (0 ), handler ));
55- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/exchange/0" ));
54+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/exchange/0" ));
5655 }
5756
5857 @ Test
@@ -62,7 +61,7 @@ final void testExchange1() throws InterruptedException{
6261 new Thread (() -> Requests .getCode ("http://localhost:8080/exchange/1" )).start ();
6362 Thread .sleep (250 );
6463
65- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/exchange/1" ));
64+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/exchange/1" ));
6665 }
6766
6867 @ Test
@@ -99,7 +98,7 @@ final class ServerExchange {
9998 @ Test
10099 final void testExchange0 (){
101100 server .createContext ("server/exchange/0" , new ThrottledHandler (ThrottlerTests .ServerExchangeThrottler (0 , -1 , false ), handler ));
102- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/exchange/0" ));
101+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/exchange/0" ));
103102 }
104103
105104 @ Test
@@ -109,7 +108,7 @@ final void testExchange1() throws InterruptedException{
109108 new Thread (() -> Requests .getCode ("http://localhost:8080/server/exchange/1" )).start ();
110109 Thread .sleep (250 );
111110
112- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/exchange/1" ));
111+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/exchange/1" ));
113112 }
114113
115114 @ Test
@@ -125,7 +124,7 @@ final void testExchangeU() throws InterruptedException{
125124 @ Test
126125 final void testServerExchange0 (){
127126 server .createContext ("server/exchange-server/0" , new ThrottledHandler (ThrottlerTests .ServerExchangeThrottler (-1 , 0 , false ), handler ));
128- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/exchange-server/0" ));
127+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/exchange-server/0" ));
129128 }
130129
131130 @ Test
@@ -135,7 +134,7 @@ final void testServerExchange1() throws InterruptedException{
135134 new Thread (() -> Requests .getCode ("http://localhost:8080/server/exchange-server/1" )).start ();
136135 Thread .sleep (250 );
137136
138- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/exchange-server/1" ));
137+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/exchange-server/1" ));
139138 }
140139
141140 @ Test
@@ -182,7 +181,7 @@ final void afterEach() throws InterruptedException{
182181 @ Test
183182 final void testSession0 (){
184183 server .createContext ("session/0" , new ThrottledHandler (ThrottlerTests .SessionThrottler (server .getSessionHandler (), 0 ), handler ));
185- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/session/0" ));
184+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/session/0" ));
186185 }
187186
188187 @ Test
@@ -195,7 +194,7 @@ final void testSession1() throws InterruptedException{
195194 new Thread (() -> Requests .getCode ("http://localhost:8080/session/1" )).start ();
196195 Thread .sleep (250 );
197196
198- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/session/1" ));
197+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/session/1" ));
199198 }
200199
201200 @ Test
@@ -240,7 +239,7 @@ final void afterEach() throws InterruptedException{
240239 @ Test
241240 final void testSession0 (){
242241 server .createContext ("server/session/0" , new ThrottledHandler (ThrottlerTests .ServerSessionThrottler (server .getSessionHandler (),0 , -1 , false ), handler ));
243- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/session/0" ));
242+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/session/0" ));
244243 }
245244
246245 @ Test
@@ -253,7 +252,7 @@ final void testSession1() throws InterruptedException{
253252 new Thread (() -> Requests .getCode ("http://localhost:8080/server/session/1" )).start ();
254253 Thread .sleep (250 );
255254
256- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/session/1" ));
255+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/session/1" ));
257256 }
258257
259258 @ Test
@@ -272,7 +271,7 @@ final void testSessionU() throws InterruptedException{
272271 @ Test
273272 final void testServerSession0 (){
274273 server .createContext ("server/session-server/0" , new ThrottledHandler (ThrottlerTests .ServerSessionThrottler (server .getSessionHandler (),-1 , 0 , false ), handler ));
275- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/session-server/0" ));
274+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/session-server/0" ));
276275 }
277276
278277 @ Test
@@ -285,7 +284,7 @@ final void testServerSession1() throws InterruptedException{
285284 new Thread (() -> Requests .getCode ("http://localhost:8080/server/session-server/1" )).start ();
286285 Thread .sleep (250 );
287286
288- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/server/session-server/1" ));
287+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/server/session-server/1" ));
289288 }
290289
291290 @ Test
0 commit comments