List of usage examples for org.springframework.mock.web MockHttpServletRequest getServletPath
@Override
public String getServletPath()
From source file:ar.com.zauber.commons.web.proxy.HttpClientRequestProxyTest.java
/** test */ public final void noNullPathInfo() throws Exception { final HttpClientRequestProxy p = new HttpClientRequestProxy( new InmutableURLRequestMapper(new InmutableURLResult(new URL("http://www.zauber.com.ar/"))), new HttpClient()); final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/foo"); request.setPathInfo(null);/*from w w w. ja va 2 s .c o m*/ assertNotNull(request.getServletPath()); request.setPathInfo("/test/landing.html"); final MockHttpServletResponse response = new MockHttpServletResponse(); p.handleRequestInternal(request, response); System.out.println(response.getContentAsString()); }
From source file:org.mitre.openid.connect.filter.AuthorizationRequestFilterTest.java
@Test() public void testDoFilter_RootServletPath() throws Exception { // given/* www. ja v a 2 s.c o m*/ // Values Taken from spec sample: http://openid.net/specs/openid-connect-core-1_0.html String baseUrl = "https://server.example.com/authorize"; MockHttpServletRequestBuilder requestBuilder = MockMvcRequestBuilders.get(baseUrl); requestBuilder.servletPath("/authorize").param("response_type", "code").param("scope", "openid") .param("redirect_uri", "https://client.example.org/"); MockHttpServletRequest request = requestBuilder.buildRequest(null); //when authorizationRequestFilter.doFilter(request, null, springSecurityFilterChain); //then assertThat(request.getServletPath(), is(equalTo("/authorize"))); Mockito.verify(oAuth2RequestFactory, times(1)).createAuthorizationRequest(any(Map.class)); Mockito.verify(springSecurityFilterChain, times(1)).doFilter(any(ServletRequest.class), any(ServletResponse.class)); }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTest.java
@Test public void buildRequestServletPath() throws Exception { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getServletPath()).isEqualTo("/this/here"); }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTests.java
@Test public void buildRequestServletPath() throws Exception { MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); assertThat(actualRequest.getServletPath(), equalTo("/this/here")); }
From source file:org.springframework.test.web.servlet.htmlunit.HtmlUnitRequestBuilderTests.java
@Test public void buildRequestAndAntPathRequestMatcher() throws Exception { webRequest.setUrl(new URL("http://example.com/app/login/authenticate")); MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext); // verify it is going to work with Spring Security's AntPathRequestMatcher assertThat(actualRequest.getPathInfo(), nullValue()); assertThat(actualRequest.getServletPath(), equalTo("/login/authenticate")); }