01: /*
02: * Created on 22 Jun 2007
03: */
04: package uk.org.ponder.rsac.test;
05:
06: import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
07: import org.springframework.context.ConfigurableApplicationContext;
08: import org.springframework.context.support.ClassPathXmlApplicationContext;
09: import org.springframework.test.AbstractDependencyInjectionSpringContextTests;
10:
11: import uk.org.ponder.rsac.RSACBeanLocator;
12:
13: public abstract class AbstractRSACTests extends
14: AbstractDependencyInjectionSpringContextTests {
15: private RSACBeanLocator rsacbl;
16:
17: public abstract String[] getRequestConfigLocations();
18:
19: protected ConfigurableApplicationContext loadContextLocations(
20: String[] locations) {
21: final LocalRSACResourceLocator resourceLocator = new LocalRSACResourceLocator();
22: resourceLocator.setConfigLocations(getRequestConfigLocations());
23:
24: final ConfigurableApplicationContext cac = new ClassPathXmlApplicationContext(
25: locations, false) {
26: protected void postProcessBeanFactory(
27: ConfigurableListableBeanFactory beanFactory) {
28: resourceLocator.setApplicationContext(this );
29: beanFactory.registerSingleton("RSACResourceLocator",
30: resourceLocator);
31: }
32: };
33:
34: cac.refresh();
35: return cac;
36: }
37:
38: public RSACBeanLocator getRSACBeanLocator() {
39: return rsacbl;
40: }
41:
42: protected void onSetUp() throws Exception {
43: rsacbl = (RSACBeanLocator) applicationContext
44: .getBean("RSACBeanLocator");
45: rsacbl.startRequest();
46: }
47:
48: protected void onTearDown() throws Exception {
49: rsacbl.endRequest();
50: }
51: }
|