5
5
import org .junit .jupiter .api .*;
6
6
7
7
import java .io .IOException ;
8
- import java .io .UncheckedIOException ;
9
8
import java .util .concurrent .Executors ;
10
9
11
10
final class ThrottlerTests {
@@ -52,7 +51,7 @@ final class Exchange {
52
51
@ Test
53
52
final void testExchange0 (){
54
53
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" ));
56
55
}
57
56
58
57
@ Test
@@ -62,7 +61,7 @@ final void testExchange1() throws InterruptedException{
62
61
new Thread (() -> Requests .getCode ("http://localhost:8080/exchange/1" )).start ();
63
62
Thread .sleep (250 );
64
63
65
- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/exchange/1" ));
64
+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/exchange/1" ));
66
65
}
67
66
68
67
@ Test
@@ -99,7 +98,7 @@ final class ServerExchange {
99
98
@ Test
100
99
final void testExchange0 (){
101
100
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" ));
103
102
}
104
103
105
104
@ Test
@@ -109,7 +108,7 @@ final void testExchange1() throws InterruptedException{
109
108
new Thread (() -> Requests .getCode ("http://localhost:8080/server/exchange/1" )).start ();
110
109
Thread .sleep (250 );
111
110
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" ));
113
112
}
114
113
115
114
@ Test
@@ -125,7 +124,7 @@ final void testExchangeU() throws InterruptedException{
125
124
@ Test
126
125
final void testServerExchange0 (){
127
126
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" ));
129
128
}
130
129
131
130
@ Test
@@ -135,7 +134,7 @@ final void testServerExchange1() throws InterruptedException{
135
134
new Thread (() -> Requests .getCode ("http://localhost:8080/server/exchange-server/1" )).start ();
136
135
Thread .sleep (250 );
137
136
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" ));
139
138
}
140
139
141
140
@ Test
@@ -182,7 +181,7 @@ final void afterEach() throws InterruptedException{
182
181
@ Test
183
182
final void testSession0 (){
184
183
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" ));
186
185
}
187
186
188
187
@ Test
@@ -195,7 +194,7 @@ final void testSession1() throws InterruptedException{
195
194
new Thread (() -> Requests .getCode ("http://localhost:8080/session/1" )).start ();
196
195
Thread .sleep (250 );
197
196
198
- Assertions .assertThrows ( UncheckedIOException . class , () -> Requests .getCode ("http://localhost:8080/session/1" ));
197
+ Assertions .assertEquals ( 429 , Requests .getCode ("http://localhost:8080/session/1" ));
199
198
}
200
199
201
200
@ Test
@@ -240,7 +239,7 @@ final void afterEach() throws InterruptedException{
240
239
@ Test
241
240
final void testSession0 (){
242
241
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" ));
244
243
}
245
244
246
245
@ Test
@@ -253,7 +252,7 @@ final void testSession1() throws InterruptedException{
253
252
new Thread (() -> Requests .getCode ("http://localhost:8080/server/session/1" )).start ();
254
253
Thread .sleep (250 );
255
254
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" ));
257
256
}
258
257
259
258
@ Test
@@ -272,7 +271,7 @@ final void testSessionU() throws InterruptedException{
272
271
@ Test
273
272
final void testServerSession0 (){
274
273
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" ));
276
275
}
277
276
278
277
@ Test
@@ -285,7 +284,7 @@ final void testServerSession1() throws InterruptedException{
285
284
new Thread (() -> Requests .getCode ("http://localhost:8080/server/session-server/1" )).start ();
286
285
Thread .sleep (250 );
287
286
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" ));
289
288
}
290
289
291
290
@ Test
0 commit comments