org.springframework.web.server.session.DefaultWebSessionManager Java Examples
The following examples show how to use
org.springframework.web.server.session.DefaultWebSessionManager.
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: 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 #4
Source File: SpringWebSessionConfiguration.java From spring-session with Apache License 2.0 | 5 votes |
/** * Configure a {@link WebSessionManager} using a provided * {@link ReactiveSessionRepository}. * @param repository a bean that implements {@link ReactiveSessionRepository}. * @return a configured {@link WebSessionManager} registered with a preconfigured * name. */ @Bean(WebHttpHandlerBuilder.WEB_SESSION_MANAGER_BEAN_NAME) public WebSessionManager webSessionManager(ReactiveSessionRepository<? extends Session> repository) { SpringSessionWebSessionStore<? extends Session> sessionStore = new SpringSessionWebSessionStore<>(repository); DefaultWebSessionManager manager = new DefaultWebSessionManager(); manager.setSessionStore(sessionStore); if (this.webSessionIdResolver != null) { manager.setSessionIdResolver(this.webSessionIdResolver); } return manager; }
Example #5
Source File: SpringWebSessionConfigurationTests.java From spring-session with Apache License 2.0 | 5 votes |
@Test void defaultSessionIdResolverShouldBeCookieBased() { this.context = new AnnotationConfigApplicationContext(); this.context.register(GoodConfig.class); this.context.refresh(); DefaultWebSessionManager manager = this.context.getBean(DefaultWebSessionManager.class); assertThat(manager.getSessionIdResolver().getClass()).isAssignableFrom(CookieWebSessionIdResolver.class); }
Example #6
Source File: SpringWebSessionConfigurationTests.java From spring-session with Apache License 2.0 | 5 votes |
@Test void providedSessionIdResolverShouldBePickedUpAutomatically() { this.context = new AnnotationConfigApplicationContext(); this.context.register(OverrideSessionIdResolver.class); this.context.refresh(); DefaultWebSessionManager manager = this.context.getBean(DefaultWebSessionManager.class); assertThat(manager.getSessionIdResolver().getClass()).isAssignableFrom(HeaderWebSessionIdResolver.class); }
Example #7
Source File: DefaultServerWebExchangeTests.java From spring-analysis-note with MIT License | 4 votes |
private DefaultServerWebExchange createExchange(MockServerHttpRequest request) { return new DefaultServerWebExchange(request, new MockServerHttpResponse(), new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); }
Example #8
Source File: MockServerWebExchange.java From spring-analysis-note with MIT License | 4 votes |
/** * Build the {@code MockServerWebExchange} instance. */ public MockServerWebExchange build() { return new MockServerWebExchange(this.request, this.sessionManager != null ? this.sessionManager : new DefaultWebSessionManager()); }
Example #9
Source File: MockServerWebExchange.java From spring-analysis-note with MIT License | 4 votes |
/** * Build the {@code MockServerWebExchange} instance. */ public MockServerWebExchange build() { return new MockServerWebExchange(this.request, this.sessionManager != null ? this.sessionManager : new DefaultWebSessionManager()); }
Example #10
Source File: AbstractMockServerSpec.java From spring-analysis-note with MIT License | 4 votes |
AbstractMockServerSpec() { // Default instance to be re-used across requests, unless one is configured explicitly this.sessionManager = new DefaultWebSessionManager(); }
Example #11
Source File: DefaultServerWebExchangeTests.java From java-technology-stack with MIT License | 4 votes |
private DefaultServerWebExchange createExchange(MockServerHttpRequest request) { return new DefaultServerWebExchange(request, new MockServerHttpResponse(), new DefaultWebSessionManager(), ServerCodecConfigurer.create(), new AcceptHeaderLocaleContextResolver()); }
Example #12
Source File: MockServerWebExchange.java From java-technology-stack with MIT License | 4 votes |
/** * Build the {@code MockServerWebExchange} instance. */ public MockServerWebExchange build() { return new MockServerWebExchange(this.request, this.sessionManager != null ? this.sessionManager : new DefaultWebSessionManager()); }
Example #13
Source File: MockServerWebExchange.java From java-technology-stack with MIT License | 4 votes |
/** * Build the {@code MockServerWebExchange} instance. */ public MockServerWebExchange build() { return new MockServerWebExchange(this.request, this.sessionManager != null ? this.sessionManager : new DefaultWebSessionManager()); }
Example #14
Source File: AbstractMockServerSpec.java From java-technology-stack with MIT License | 4 votes |
AbstractMockServerSpec() { // Default instance to be re-used across requests, unless one is configured explicitly this.sessionManager = new DefaultWebSessionManager(); }
Example #15
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)); }