Examples of MockHttpSession


Examples of org.springframework.mock.web.MockHttpSession

        // no exception
    }

    @Test
    public void maxSessionsSameSessionId() {
        MockHttpSession session = new MockHttpSession(new MockServletContext(), sessionInformation.getSessionId());
        request.setSession(session);
        when(sessionRegistry.getAllSessions(any(), anyBoolean())).thenReturn(Collections.<SessionInformation>singletonList(sessionInformation));
        strategy.setMaximumSessions(1);
        strategy.setExceptionIfMaximumExceeded(true);
View Full Code Here

Examples of org.springframework.mock.web.MockHttpSession

    public void testInvalidBasicAuthorizationTokenIsIgnored() throws Exception {
        String token = "NOT_A_VALID_TOKEN_AS_MISSING_COLON";
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
        request.setServletPath("/some_file.html");
        request.setSession(new MockHttpSession());
        final MockHttpServletResponse response = new MockHttpServletResponse();

        FilterChain chain = mock(FilterChain.class);
        filter.doFilter(request, response, chain);
View Full Code Here

Examples of org.springframework.mock.web.MockHttpSession

    @Test
    public void invalidBase64IsIgnored() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addHeader("Authorization", "Basic NOT_VALID_BASE64");
        request.setServletPath("/some_file.html");
        request.setSession(new MockHttpSession());
        final MockHttpServletResponse response = new MockHttpServletResponse();

        FilterChain chain = mock(FilterChain.class);
        filter.doFilter(request, response, chain);
        // The filter chain shouldn't proceed
View Full Code Here

Examples of org.springframework.mock.web.MockHttpSession

    public void testWrongPasswordContinuesFilterChainIfIgnoreFailureIsTrue() throws Exception {
        String token = "rod:WRONG_PASSWORD";
        MockHttpServletRequest request = new MockHttpServletRequest();
        request.addHeader("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
        request.setServletPath("/some_file.html");
        request.setSession(new MockHttpSession());

        filter.setIgnoreFailure(true);
        assertTrue(filter.isIgnoreFailure());
        FilterChain chain = mock(FilterChain.class);
        filter.doFilter(request, new MockHttpServletResponse(), chain);
View Full Code Here

Examples of org.springframework.mock.web.test.MockHttpSession

  @Test
  public void defaultConstructor() throws Exception {
    Map<String, Object> attributes = new HashMap<String, Object>();
    WebSocketHandler wsHandler = Mockito.mock(WebSocketHandler.class);

    this.servletRequest.setSession(new MockHttpSession(null, "123"));
    this.servletRequest.getSession().setAttribute("foo", "bar");
    this.servletRequest.getSession().setAttribute("bar", "baz");

    HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
    interceptor.beforeHandshake(this.request, this.response, wsHandler, attributes);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.