Never been to DZone Snippets before?

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

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

testing new bean scopes with spring 2.0 - example

// scoped bean definition
   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  	}
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS