Access to ApplicationContext via ServerWebExchange

Issue: SPR-16298
This commit is contained in:
Rossen Stoyanchev
2018-01-05 15:46:45 -05:00
parent 93a522f336
commit 37f0e8c6e5
6 changed files with 95 additions and 15 deletions

View File

@@ -38,10 +38,11 @@ import org.springframework.web.server.WebHandler;
import static java.time.Duration.ofMillis;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/**
* Unit tests for {@link WebHttpHandlerBuilder}.
*
* @author Rossen Stoyanchev
*/
public class WebHttpHandlerBuilderTests {
@@ -54,6 +55,9 @@ public class WebHttpHandlerBuilderTests {
HttpHandler httpHandler = WebHttpHandlerBuilder.applicationContext(context).build();
assertTrue(httpHandler instanceof HttpWebHandlerAdapter);
assertSame(context, ((HttpWebHandlerAdapter) httpHandler).getApplicationContext());
MockServerHttpRequest request = MockServerHttpRequest.get("/").build();
MockServerHttpResponse response = new MockServerHttpResponse();
httpHandler.handle(request, response).block(ofMillis(5000));