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
	<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();

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