Spring Framework ServletWebRequest - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ServletWebRequest class.

This code example shows how to use the following methods:
	 */ 
	@Test 
	@Verifies(value = "should work for an example", method = "handleSubmission(WebRequest,HttpSession,String,String,String,null,User,BindingResult)") 
	public void handleSubmission_shouldWorkForAnExample() throws Exception { 
		UserFormController controller = new UserFormController(); 
		WebRequest request = new ServletWebRequest(new MockHttpServletRequest()); 
		User user = controller.formBackingObject(request, null); 
		user.addName(new PersonName("This", "is", "Test")); 
		user.getPerson().setGender("F"); 
		controller.handleSubmission(request, new MockHttpSession(), new ModelMap(), "Save User", "pass123", "pass123", null, 
		    null, null, new String[0], "true", user, new BindException(user, "user")); 
	} 
	 
} 
7
CodeRank
This code example shows how to use the following methods:
public class NullBroadleafThemeResolver implements BroadleafThemeResolver { 
    private final Theme theme = new ThemeDTO(); 
 
    @Override 
    public Theme resolveTheme(HttpServletRequest request, Site site) { 
        return resolveTheme(new ServletWebRequest(request)); 
    } 
     
    @Override 
    public Theme resolveTheme(WebRequest request) { 
        return theme; 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
			} 
 
			MockServletContext mockServletContext = (MockServletContext) servletContext; 
			MockHttpServletRequest request = new MockHttpServletRequest(mockServletContext); 
			MockHttpServletResponse response = new MockHttpServletResponse(); 
			ServletWebRequest servletWebRequest = new ServletWebRequest(request, response); 
 
			RequestContextHolder.setRequestAttributes(servletWebRequest); 
			testContext.setAttribute(POPULATED_REQUEST_CONTEXT_HOLDER_ATTRIBUTE, Boolean.TRUE); 
			testContext.setAttribute(RESET_REQUEST_CONTEXT_HOLDER_ATTRIBUTE, Boolean.TRUE); 
 
			if (wac instanceof ConfigurableApplicationContext) { 
				@SuppressWarnings("resource") 
				ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) wac; 
				ConfigurableListableBeanFactory bf = configurableApplicationContext.getBeanFactory(); 
				bf.registerResolvableDependency(MockHttpServletResponse.class, response); 
				bf.registerResolvableDependency(ServletWebRequest.class, servletWebRequest); 
			} 
		} 
	} 

6
CodeRank
This code example shows how to use the following methods:
 */ 
public class NullBroadleafSiteResolver implements BroadleafSiteResolver { 
 
    @Override 
    public Site resolveSite(HttpServletRequest request) { 
        return resolveSite(new ServletWebRequest(request)); 
    } 
     
    @Override 
    public Site resolveSite(WebRequest request) { 
        return resolveSite(request, false); 
    } 
 
    @Override 
    public Site resolveSite(WebRequest request, boolean allowNullSite) throws SiteNotFoundException { 
        return null; 
    } 
     
} 
6
CodeRank
This code example shows how to use the following methods:
	@Override 
	protected NativeWebRequest getWebRequest() { 
		RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); 
		if (requestAttributes instanceof ServletRequestAttributes) { 
			ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes; 
			return new ServletWebRequest(servletRequestAttributes.getRequest()); 
		} 
		return null; 
	} 
} 
6
CodeRank
This code example shows how to use the following methods:
 
	@Before 
	public void setup() { 
		this.strategy = new HeaderContentNegotiationStrategy(); 
		this.servletRequest = new MockHttpServletRequest(); 
		this.webRequest = new ServletWebRequest(servletRequest ); 
	} 
 
	@Test 
	public void resolveMediaTypes() throws Exception { 
		this.servletRequest.addHeader("Accept", "text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c"); 
		List<MediaType> mediaTypes = this.strategy.resolveMediaTypes(this.webRequest); 
 
		assertEquals(4, mediaTypes.size()); 
		assertEquals("text/html", mediaTypes.get(0).toString()); 
		assertEquals("text/x-c", mediaTypes.get(1).toString()); 
		assertEquals("text/x-dvi;q=0.8", mediaTypes.get(2).toString()); 
		assertEquals("text/plain;q=0.5", mediaTypes.get(3).toString()); 
	} 
 
6
CodeRank
This code example shows how to use the following methods:
@Component("blStatelessSessionFilter") 
public class StatelessSessionFilter extends GenericFilterBean { 
 
    @Override 
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { 
        BLCRequestUtils.setOKtoUseSession(new ServletWebRequest((HttpServletRequest) request, (HttpServletResponse) response), Boolean.FALSE); 
        SessionlessHttpServletRequestWrapper wrapper = new SessionlessHttpServletRequestWrapper((HttpServletRequest) request); 
        filterChain.doFilter(wrapper, response); 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
		resolver.resolveArgument(tokenParameter, request); 
	} 
 
	@Test 
	public void resolveArgument_noCookies_unrequired() throws Exception { 
		NativeWebRequest request = new ServletWebRequest(new MockHttpServletRequest()); 
		Method method = FacebookArgumentResolverTest.class.getDeclaredMethod("unrequiredAnnotatedMethod", String.class, 
				String.class, String.class); 
 
		MethodParameter idParameter = new MethodParameter(method, 0); 
		assertEquals(null, resolver.resolveArgument(idParameter, request)); 
 
		MethodParameter tokenParameter = new MethodParameter(method, 1); 
		assertEquals(null, resolver.resolveArgument(tokenParameter, request)); 
	} 
 
	@Test(expected = IllegalStateException.class) 
	public void resolveFacebookUserIdArgument_noFacebookCookie_required() throws Exception { 
		MockHttpServletRequest httpServletRequest = new MockHttpServletRequest(); 
		httpServletRequest.setCookies(new Cookie("not_a_facebook_cookie", "doesn't matter")); 
6
CodeRank
This code example shows how to use the following methods:
    @Override 
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, 
            Authentication authentication) throws ServletException, IOException { 
         
        String targetUrl = request.getParameter(getTargetUrlParameter()); 
        if (BLCRequestUtils.isOKtoUseSession(new ServletWebRequest(request))) { 
            request.getSession().removeAttribute(SESSION_ATTR); 
        } 
        if (StringUtils.isNotBlank(targetUrl) && targetUrl.contains(":")) { 
            getRedirectStrategy().sendRedirect(request, response, getDefaultTargetUrl()); 
        } else { 
            super.onAuthenticationSuccess(request, response, authentication); 
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:
		Method method = getClass().getMethod("params", Cookie.class, String.class); 
		cookieParameter = new MethodParameter(method, 0); 
		cookieStringParameter = new MethodParameter(method, 1); 
 
		request = new MockHttpServletRequest(); 
		webRequest = new ServletWebRequest(request, new MockHttpServletResponse()); 
	} 
 
	@Test 
	public void resolveCookieArgument() throws Exception { 
		Cookie expected = new Cookie("name", "foo"); 
		request.setCookies(expected); 
 
		Cookie result = (Cookie) resolver.resolveArgument(cookieParameter, null, webRequest, null); 
		assertEquals("Invalid result", expected, result); 
	} 
 
	@Test 
	public void resolveCookieStringArgument() throws Exception { 
		Cookie cookie = new Cookie("name", "foo"); 
6
CodeRank