Code example for ServletWebRequest

0
	public void setUp() throws Exception { 
		resolver = new ServletResponseMethodArgumentResolver(); 
		method = getClass().getMethod("supportedParams", ServletResponse.class, OutputStream.class, Writer.class); 
		servletResponse = new MockHttpServletResponse(); 
		mavContainer = new ModelAndViewContainer(); 
		webRequest = new ServletWebRequest(new MockHttpServletRequest(), servletResponse); 
	} 
 
	@Test 
	public void servletResponse() throws Exception { 
		MethodParameter servletResponseParameter = new MethodParameter(method, 0); 
 
		assertTrue("ServletResponse not supported", resolver.supportsParameter(servletResponseParameter)); 
 
		Object result = resolver.resolveArgument(servletResponseParameter, mavContainer, webRequest, null); 
		assertSame("Invalid result", servletResponse, result); 
		assertTrue(mavContainer.isRequestHandled()); 
	} 
 
	// SPR-8983 
Experience pair programming with AI  Get Codota for Java