org.springframework.web.server.adapter.DefaultServerWebExchange Java Examples
The following examples show how to use
org.springframework.web.server.adapter.DefaultServerWebExchange.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NashornScriptTemplateTests.java From spring-analysis-note with MIT License | 6 votes |
@Test // gh-22754 public void subscribeWithoutDemand() throws Exception { ZeroDemandResponse response = new ZeroDemandResponse(); ServerWebExchange exchange = new DefaultServerWebExchange( MockServerHttpRequest.get("/path").build(), response, new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); Map<String, Object> model = new HashMap<>(); model.put("title", "Layout example"); model.put("body", "This is the body"); String viewUrl = "org/springframework/web/reactive/result/view/script/nashorn/template.html"; ScriptTemplateView view = createViewWithUrl(viewUrl, ScriptTemplatingConfiguration.class); view.render(model, null, exchange).subscribe(); response.cancelWrite(); response.checkForLeaks(); }
Example #2
Source File: FreeMarkerViewTests.java From spring-analysis-note with MIT License | 6 votes |
@Test // gh-22754 public void subscribeWithoutDemand() { ZeroDemandResponse response = new ZeroDemandResponse(); ServerWebExchange exchange = new DefaultServerWebExchange( MockServerHttpRequest.get("/path").build(), response, new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); FreeMarkerView view = new FreeMarkerView(); view.setConfiguration(this.freeMarkerConfig); view.setUrl("test.ftl"); ModelMap model = new ExtendedModelMap(); model.addAttribute("hello", "hi FreeMarker"); view.render(model, null, exchange).subscribe(); response.cancelWrite(); response.checkForLeaks(); }
Example #3
Source File: DefaultWebSessionManagerTests.java From spring-analysis-note with MIT License | 6 votes |
@Before public void setUp() throws Exception { given(this.createSession.save()).willReturn(Mono.empty()); given(this.createSession.getId()).willReturn("create-session-id"); given(this.updateSession.getId()).willReturn("update-session-id"); given(this.sessionStore.createWebSession()).willReturn(Mono.just(this.createSession)); given(this.sessionStore.retrieveSession(this.updateSession.getId())).willReturn(Mono.just(this.updateSession)); this.sessionManager = new DefaultWebSessionManager(); this.sessionManager.setSessionIdResolver(this.sessionIdResolver); this.sessionManager.setSessionStore(this.sessionStore); MockServerHttpRequest request = MockServerHttpRequest.get("/path").build(); MockServerHttpResponse response = new MockServerHttpResponse(); this.exchange = new DefaultServerWebExchange(request, response, this.sessionManager, ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); }
Example #4
Source File: DefaultWebSessionManagerTests.java From java-technology-stack with MIT License | 6 votes |
@Before public void setUp() throws Exception { when(this.createSession.save()).thenReturn(Mono.empty()); when(this.createSession.getId()).thenReturn("create-session-id"); when(this.updateSession.getId()).thenReturn("update-session-id"); when(this.sessionStore.createWebSession()).thenReturn(Mono.just(this.createSession)); when(this.sessionStore.retrieveSession(this.updateSession.getId())).thenReturn(Mono.just(this.updateSession)); this.sessionManager = new DefaultWebSessionManager(); this.sessionManager.setSessionIdResolver(this.sessionIdResolver); this.sessionManager.setSessionStore(this.sessionStore); MockServerHttpRequest request = MockServerHttpRequest.get("/path").build(); MockServerHttpResponse response = new MockServerHttpResponse(); this.exchange = new DefaultServerWebExchange(request, response, this.sessionManager, ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); }
Example #5
Source File: PathMatcherServerWebExchangeMatcherTests.java From spring-security-reactive with Apache License 2.0 | 5 votes |
@Before public void setup() { MockServerHttpRequest request = MockServerHttpRequest.post("/path").build(); MockServerHttpResponse response = new MockServerHttpResponse(); DefaultWebSessionManager sessionManager = new DefaultWebSessionManager(); exchange = new DefaultServerWebExchange(request, response, sessionManager); pattern = "/pattern"; path = "/path"; matcher = new PathMatcherServerWebExchangeMatcher(pattern); matcher.setPathMatcher(pathMatcher); }
Example #6
Source File: NettyRoutingFilterInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
public static EnhancedInstance getInstance(Object o) { EnhancedInstance instance = null; if (o instanceof DefaultServerWebExchange) { instance = (EnhancedInstance) o; } else if (o instanceof ServerWebExchangeDecorator) { ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate(); return getInstance(delegate); } return instance; }
Example #7
Source File: NettyRoutingFilterInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
public static EnhancedInstance getInstance(Object o) { EnhancedInstance instance = null; if (o instanceof DefaultServerWebExchange) { instance = (EnhancedInstance) o; } else if (o instanceof ServerWebExchangeDecorator) { ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate(); return getInstance(delegate); } return instance; }
Example #8
Source File: DispatcherHandlerHandleMethodInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
public static EnhancedInstance getInstance(Object o) { EnhancedInstance instance = null; if (o instanceof DefaultServerWebExchange) { instance = (EnhancedInstance) o; } else if (o instanceof ServerWebExchangeDecorator) { ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate(); return getInstance(delegate); } return instance; }
Example #9
Source File: WingtipsSpringWebfluxWebFilterTest.java From wingtips with Apache License 2.0 | 4 votes |
@Before public void beforeMethod() { resetTracing(); spanRecorder = new SpanRecorder(); Tracer.getInstance().addSpanLifecycleListener(spanRecorder); initialSpanNameFromStrategy = new AtomicReference<>("span-name-from-strategy-" + UUID.randomUUID().toString()); strategyInitialSpanNameMethodCalled = new AtomicBoolean(false); strategyRequestTaggingMethodCalled = new AtomicBoolean(false); strategyResponseTaggingAndFinalSpanNameMethodCalled = new AtomicBoolean(false); strategyInitialSpanNameArgs = new AtomicReference<>(null); strategyRequestTaggingArgs = new AtomicReference<>(null); strategyResponseTaggingArgs = new AtomicReference<>(null); tagAndNamingStrategy = new ArgCapturingHttpTagAndSpanNamingStrategy<>( initialSpanNameFromStrategy, strategyInitialSpanNameMethodCalled, strategyRequestTaggingMethodCalled, strategyResponseTaggingAndFinalSpanNameMethodCalled, strategyInitialSpanNameArgs, strategyRequestTaggingArgs, strategyResponseTaggingArgs ); //noinspection unchecked tagAndNamingAdapterMock = mock(HttpTagAndSpanNamingAdapter.class); userIdHeaderKeys = Arrays.asList("user-id", "alt-user-id"); filterSpy = spy( WingtipsSpringWebfluxWebFilter .newBuilder() .withTagAndNamingStrategy(tagAndNamingStrategy) .withTagAndNamingAdapter(tagAndNamingAdapterMock) .withUserIdHeaderKeys(userIdHeaderKeys) .build() ); requestMock = mock(ServerHttpRequest.class); requestHeadersMock = mock(HttpHeaders.class); responseMock = mock(ServerHttpResponse.class); responseHeadersMock = mock(HttpHeaders.class); doReturn("someRequestId").when(requestMock).getId(); doReturn(requestHeadersMock).when(requestMock).getHeaders(); doReturn(responseHeadersMock).when(responseMock).getHeaders(); exchange = new DefaultServerWebExchange( requestMock, responseMock, new DefaultWebSessionManager(), new DefaultServerCodecConfigurer(), new FixedLocaleContextResolver(Locale.US) ); chainMock = mock(WebFilterChain.class); expectedResultMonoDuration = Duration.ofMillis(50); webFilterChainResult = Mono.delay(expectedResultMonoDuration).flatMap(l -> Mono.empty()); doReturn(webFilterChainResult).when(chainMock).filter(any(ServerWebExchange.class)); }