Skip to content

Instantly share code, notes, and snippets.

@thesurlydev
Created October 24, 2010 17:46
Show Gist options
  • Save thesurlydev/643712 to your computer and use it in GitHub Desktop.
Save thesurlydev/643712 to your computer and use it in GitHub Desktop.
*** package and imports omitted for brevity ***
@ContextConfiguration(locations = {
"file:src/main/webapp/WEB-INF/appContext.xml",
"classpath:appTestContext.xml"
})
public abstract class AppTransactionalStrutsTestCase extends StrutsSpringTransactionalTests {
@Before
public void onSetUp() throws Exception {
super.setUp();
setupAction();
}
protected abstract void setupAction() throws DataAccessException;
@Override
protected void setupBeforeInitDispatcher() throws Exception {
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, applicationContext);
}
protected ActionProxy initActionProxy(String uri) {
ActionProxy proxy = getActionProxy(uri);
ActionContext actionContext = proxy.getInvocation().getInvocationContext();
actionContext.setSession(new HashMap<String, Object>());
return proxy;
}
@Autowired
public void setDataSource(@Qualifier(value = "appDataSource") DataSource appDataSource) {
this.dataSource = appDataSource;
this.simpleJdbcTemplate = new SimpleJdbcTemplate(appDataSource);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment