@@ -6,10 +6,12 @@ import jakarta.enterprise.context.RequestScoped
6
6
import jakarta.inject.Inject
7
7
import kotlinx.coroutines.CompletableDeferred
8
8
import kotlinx.coroutines.Dispatchers
9
+ import kotlinx.coroutines.async
9
10
import kotlinx.coroutines.coroutineScope
10
11
import kotlinx.coroutines.delay
11
12
import kotlinx.coroutines.launch
12
13
import kotlinx.coroutines.test.runTest
14
+ import kotlinx.coroutines.withContext
13
15
import org.jboss.shrinkwrap.api.spec.JavaArchive
14
16
import org.junit.jupiter.api.AfterEach
15
17
import org.junit.jupiter.api.Assertions
@@ -60,7 +62,7 @@ class RequestContextCoroutineContextTest {
60
62
61
63
// WHEN we run a block
62
64
runTest {
63
- withPropagatedContext (Dispatchers .IO ) {
65
+ withContext (Dispatchers .IO .withCdiContext() ) {
64
66
// THEN the request context should not be active
65
67
Assertions .assertFalse(
66
68
Arc .container().requestContext().isActive,
@@ -83,7 +85,7 @@ class RequestContextCoroutineContextTest {
83
85
// WHEN we run a block with async
84
86
runTest {
85
87
coroutineScope {
86
- asyncWithPropagatedContext (Dispatchers .IO ) {
88
+ async (Dispatchers .IO .withCdiContext() ) {
87
89
// THEN the request context should not be active
88
90
Assertions .assertFalse(
89
91
Arc .container().requestContext().isActive,
@@ -115,7 +117,7 @@ class RequestContextCoroutineContextTest {
115
117
116
118
// WHEN we run a block with the request context
117
119
runTest {
118
- withPropagatedContext (Dispatchers .IO ) {
120
+ withContext (Dispatchers .IO .withCdiContext() ) {
119
121
// THEN the request context should be active
120
122
Assertions .assertTrue(
121
123
Arc .container().requestContext().isActive,
@@ -169,7 +171,7 @@ class RequestContextCoroutineContextTest {
169
171
// WHEN we run a block with async
170
172
runTest {
171
173
coroutineScope {
172
- asyncWithPropagatedContext (Dispatchers .IO ) {
174
+ async (Dispatchers .IO .withCdiContext() ) {
173
175
// THEN the request context should be active
174
176
Assertions .assertTrue(
175
177
Arc .container().requestContext().isActive,
@@ -225,7 +227,7 @@ class RequestContextCoroutineContextTest {
225
227
// WHEN we run a block with async
226
228
runTest {
227
229
coroutineScope {
228
- asyncWithPropagatedContext (Dispatchers .IO ) {
230
+ async (Dispatchers .IO .withCdiContext() ) {
229
231
coroutineScope {
230
232
// THEN the request context should be active
231
233
Assertions .assertTrue(
@@ -289,7 +291,7 @@ class RequestContextCoroutineContextTest {
289
291
// WHEN we run a block with async
290
292
runTest {
291
293
val job = launch {
292
- asyncWithPropagatedContext (Dispatchers .IO ) {
294
+ async (Dispatchers .IO .withCdiContext() ) {
293
295
// THEN the request context should be active
294
296
Assertions .assertTrue(
295
297
Arc .container().requestContext().isActive,
@@ -368,7 +370,7 @@ class RequestContextCoroutineContextTest {
368
370
runTest {
369
371
val jobFirstRequest = launch {
370
372
Arc .container().requestContext().activate(firstRequestState)
371
- asyncWithPropagatedContext (Dispatchers .IO ) {
373
+ async (Dispatchers .IO .withCdiContext() ) {
372
374
// THEN the request context should be active
373
375
Assertions .assertTrue(
374
376
Arc .container().requestContext().isActive,
@@ -402,7 +404,7 @@ class RequestContextCoroutineContextTest {
402
404
403
405
val jobSecondRequest = launch {
404
406
Arc .container().requestContext().activate(secondRequestState)
405
- asyncWithPropagatedContext (Dispatchers .IO ) {
407
+ async (Dispatchers .IO .withCdiContext() ) {
406
408
// THEN the request context should be active
407
409
Assertions .assertTrue(
408
410
Arc .container().requestContext().isActive,
0 commit comments