Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockFilterChain


        new MockHttpServletRequest( "GET",
            "http://localhost:9080/pentaho-di/kettle/executeTrans/?rep=dev&userid=admin&password=password&trans=/home/admin/Trans1" );
    request.addParameter( "userid", "admin" );
    request.addParameter( "password", "password" );

    filter.doFilter( request, new MockHttpServletResponse(), new MockFilterChain() );
    UsernamePasswordAuthenticationToken authRequest = new UsernamePasswordAuthenticationToken( "admin", "password" );
    authRequest.setDetails( new WebAuthenticationDetails( request ) );
    verify( authManagerMock ).authenticate( Mockito.eq( authRequest ) );

  }
View Full Code Here


    device.setDeviceType(DeviceType.NORMAL);
    Servlet servlet = createMock(Servlet.class);
    servlet.service(this.request, this.response);
    replay(servlet);
    MockFilter otherFilter = new MockFilter(servlet);
    MockFilterChain chain = new MockFilterChain(servlet, siteSwitcher, otherFilter);
    chain.doFilter(this.request, this.response);
    assertNull(response.getRedirectedUrl());
    assertTrue(otherFilter.invoked);
    verify(servlet);
  }
View Full Code Here

  public void doFilterWithRedirect() throws Exception {
    device.setDeviceType(DeviceType.MOBILE);
    Servlet servlet = createMock(Servlet.class);
    replay(servlet);
    MockFilter otherFilter = new MockFilter(servlet);
    MockFilterChain chain = new MockFilterChain(servlet, siteSwitcher, otherFilter);
    chain.doFilter(this.request, this.response);
    assertEquals("http://m.app.com", response.getRedirectedUrl());
    assertFalse(otherFilter.invoked);
    verify(servlet);
  }
View Full Code Here

        initMocks(this);
    }

    @BeforeMethod
    public void refresh() throws Exception{
        filterChain = new MockFilterChain();
        response = new MockHttpServletResponse();
        request = new MockHttpServletRequest();
        when(parser1.replaceTagByContent(any(TaggedResponseWrapper.class))).thenReturn(new byte[0]);
        when(parser2.replaceTagByContent(any(TaggedResponseWrapper.class))).thenReturn(new byte[0]);
    }
View Full Code Here

    }
   
    @Test
    public void passedRememberMeTokenInCookieShouldBeChecked() throws IOException, ServletException {
        HttpServletRequest request = new MockHttpServletRequest();
        FilterChain filterChain = new MockFilterChain();
        String rememberMeCookieValue = "cookie value";
        String series = "series";
        String token = "token";
        String[] seriesAndToken = new String[] { series, token };
        when(rememberMeCookieDecoder.exctractRememberMeCookieValue(request))
View Full Code Here

    }
   
    @Test
    public void passedIncorrectRememberMeTokenInCookieShouldNotBeChecked() throws IOException, ServletException {
        HttpServletRequest request = new MockHttpServletRequest();
        FilterChain filterChain = new MockFilterChain();
        String rememberMeCookieValue = "cookie value";
        String[] seriesAndToken = {"it contains only series"};
        when(rememberMeCookieDecoder.exctractRememberMeCookieValue(request))
            .thenReturn(rememberMeCookieValue);
        when(rememberMeCookieDecoder.extractSeriesAndToken(rememberMeCookieValue))
View Full Code Here

    }
   
    @Test
    public void notPassedRememberMeTokenInShouldNotBeChecked() throws IOException, ServletException {
        HttpServletRequest request = new MockHttpServletRequest();
        FilterChain filterChain = new MockFilterChain();
        when(rememberMeCookieDecoder.exctractRememberMeCookieValue(request))
            .thenReturn(null);

        filter.doFilter(request, new MockHttpServletResponse(), filterChain);
View Full Code Here

    @Test
    public void userShouldBeRegisteredAndUnregisteredWhenChainEnded() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();

        MockFilterChain filterChain = new MockFilterChain();
        String userName = "Shogun";
        when(securityService.getCurrentUserUsername()).thenReturn(userName);

        loggingConfigurationFilter.doFilter(request, response, filterChain);
View Full Code Here

    public void anonymousUserRegisteredAndUnregistered() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockHttpSession httpSession = spy(new MockHttpSession());
        request.setSession(httpSession);
        MockFilterChain filterChain = new MockFilterChain();

        String userName = "";
        when(securityService.getCurrentUserUsername()).thenReturn(userName);
        when(httpSession.getId()).thenReturn("AF7823");
View Full Code Here

    public void anonymousUserWithoutSessionIdShouldNotRegister() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        MockHttpServletResponse response = new MockHttpServletResponse();
        MockHttpSession httpSession = spy(new MockHttpSession());
        request.setSession(httpSession);
        MockFilterChain filterChain = new MockFilterChain();

        when(securityService.getCurrentUserUsername()).thenReturn("");
        when(httpSession.getId()).thenReturn("");

        loggingConfigurationFilter.doFilter(request, response, filterChain);
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.MockFilterChain

Copyright © 2018 www.massapicom. 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.