Code example for ServletWebRequest

0
			} 
 
			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); 
			} 
		} 
	} 
 
}