File tree Expand file tree Collapse file tree
src/test/java/com/retailsvc/http Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -212,16 +212,25 @@ void preRequestFailureSkipsHooks() throws Exception {
212212 }
213213
214214 @ Test
215- void hookSeesScopedRequest () throws Exception {
215+ void hookSeesScopedRequestAndSameThreadAsHandler () throws Exception {
216216 AtomicReference <Request > hookScopedRequest = new AtomicReference <>();
217+ AtomicReference <Thread > handlerThread = new AtomicReference <>();
218+ AtomicReference <Thread > hookThread = new AtomicReference <>();
217219 CountDownLatch latch = new CountDownLatch (1 );
218220
219221 try (OpenApiServer server =
220222 baseBuilder ()
221- .handlers (Map .of (OK_OPERATION_ID , req -> Response .status (HTTP_NO_CONTENT )))
223+ .handlers (
224+ Map .of (
225+ OK_OPERATION_ID ,
226+ req -> {
227+ handlerThread .set (Thread .currentThread ());
228+ return Response .status (HTTP_NO_CONTENT );
229+ }))
222230 .afterResponseHook (
223231 (req , resp ) -> {
224232 hookScopedRequest .set (DispatchHandler .CURRENT .get ());
233+ hookThread .set (Thread .currentThread ());
225234 latch .countDown ();
226235 })
227236 .build ()) {
@@ -234,6 +243,7 @@ void hookSeesScopedRequest() throws Exception {
234243 assertThat (latch .await (5 , TimeUnit .SECONDS )).isTrue ();
235244 assertThat (hookScopedRequest .get ()).isNotNull ();
236245 assertThat (hookScopedRequest .get ().operationId ()).isEqualTo (OK_OPERATION_ID );
246+ assertThat (hookThread .get ()).isSameAs (handlerThread .get ());
237247 }
238248 }
239249}
You can’t perform that action at this time.
0 commit comments