testing new bean scopes with spring 2.0 - example
1 2 <bean id="scopedBean" 3 class="org.bla.ScopedBeanImpl" 4 scope="session"> 5 <aop:scoped-proxy /> 6 </bean>
// an example test case
1 2 public class ScopedBeanTest extends AbstractRequestContextFilterTestBase { 3 4 protected String[] getConfigLocations() { 5 return new String[] { "classpath:applicationContext-with-scopedBean.xml" }; 6 } 7 8 9 @Test 10 public void testScopedBean() throws Exception { 11 12 new FilterTest(new FilterChain() { 13 14 public void doFilter(ServletRequest arg0, ServletResponse arg1) 15 throws IOException, ServletException { 16 ScopedBean scopedBean = (ScopedBean) applicationContext 17 .getBean("scopedBean"); 18 ... 19 /* 20 * let the classses under test do something with your scopedBean 21 * and check if modifications are done correctly 22 */ 23 ... 24 } 25 26 }).run(); 27 28 }