-
Notifications
You must be signed in to change notification settings - Fork 0
/
GreetingResourceTest.java
45 lines (36 loc) · 1.41 KB
/
GreetingResourceTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.acme;
import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.jupiter.api.Test;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.security.TestSecurity;
@QuarkusTest
class GreetingResourceTest {
@Test
@TestSecurity(user = "testUser", roles = {"admin", "user"})
void bruteForceContextNotActiveException() throws Exception {
//increase these values to load (and chance to "provoke" the issue)
int numberOfRequest = 100;
int numberOfParallelRequests = 10;
ExecutorService executorService = Executors.newFixedThreadPool(numberOfParallelRequests);
CountDownLatch countDownLatch = new CountDownLatch(numberOfRequest);
for (int i = 0; i < numberOfRequest; i++) {
executorService.execute(() -> {
try {
given()
.when().get("/hello")
.then()
.statusCode(200)
.body(is("Hello testUser. Greetings from RESTEasy Reactive"));
} finally {
countDownLatch.countDown();
}
});
}
countDownLatch.await();
executorService.shutdown();
}
}