DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Testing New Bean Scopes With Spring 2.0 - Example
// scoped bean definition
<bean id="scopedBean" class="org.bla.ScopedBeanImpl" scope="session"> <aop:scoped-proxy /> </bean>
// an example test case
public class ScopedBeanTest extends AbstractRequestContextFilterTestBase {
protected String[] getConfigLocations() {
return new String[] { "classpath:applicationContext-with-scopedBean.xml" };
}
@Test
public void testScopedBean() throws Exception {
new FilterTest(new FilterChain() {
public void doFilter(ServletRequest arg0, ServletResponse arg1)
throws IOException, ServletException {
ScopedBean scopedBean = (ScopedBean) applicationContext
.getBean("scopedBean");
...
/*
* let the classses under test do something with your scopedBean
* and check if modifications are done correctly
*/
...
}
}).run();
}





