Skip to content

Commit 09d5ef2

Browse files
committed
test: Interceptor observes decorated response
1 parent 579c127 commit 09d5ef2

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/test/java/com/retailsvc/http/internal/DispatchHandlerTest.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,28 @@ void decoratorSeesInterceptorBoundScopedValue() throws Exception {
9999

100100
assertThat(rendered.get().headers()).containsEntry("X-Correlation-Id", "cid-123");
101101
}
102+
103+
@Test
104+
void interceptorObservesDecoratedResponse() throws Exception {
105+
RequestHandler ok = req -> Response.status(HTTP_OK);
106+
AtomicReference<Response> seen = new AtomicReference<>();
107+
RequestInterceptor capture =
108+
(request, next) -> {
109+
Response r = next.proceed();
110+
seen.set(r);
111+
return r;
112+
};
113+
ResponseDecorator stamp = (req, resp) -> resp.withHeader("X-Stamped", "yes");
114+
115+
HttpExchange ex = stubExchange();
116+
withRequest(
117+
"get-x",
118+
() -> {
119+
dispatcher(Map.of("get-x", ok), List.of(capture), List.of(stamp)).handle(ex);
120+
return null;
121+
});
122+
123+
assertThat(seen.get()).isNotNull();
124+
assertThat(seen.get().headers()).containsEntry("X-Stamped", "yes");
125+
}
102126
}

0 commit comments

Comments
 (0)