 <p><strong>Spring 3.2 and newer provides support for session/request scoped beans for integration testing</strong></p> <pre><code>@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = TestConfig.class) @WebAppConfiguration public class SampleTest { @Autowired WebApplicationContext wac; @Autowired MockHttpServletRequest request; @Autowired MockHttpSession session; @Autowired MySessionBean mySessionBean; @Autowired MyRequestBean myRequestBean; @Test public void requestScope() throws Exception { assertThat(myRequestBean) .isSameAs(request.getAttribute("myRequestBean")); assertThat(myRequestBean) .isSameAs(wac.getBean("myRequestBean", MyRequestBean.class)); } @Test public void sessionScope() throws Exception { assertThat(mySessionBean) .isSameAs(session.getAttribute("mySessionBean")); assertThat(mySessionBean) .isSameAs(wac.getBean("mySessionBean", MySessionBean.class)); } } </code></pre> <p>References: </p> <ul> <li><a href="http://spring.io/blog/2012/11/07/spring-framework-3-2-rc1-new-testing-features/#request-and-session-scoped-beans">Request and Session Scoped Beans</a></li> <li><a href="https://jira.springsource.org/browse/SPR-4588">(SPR-4588)</a></li> <li><a href="http://stackoverflow.com/questions/2411343/request-scoped-beans-in-spring-testing">request scoped beans in spring testing</a></li> </ul>