sturts2+spring+hibernate组合下对Action进行 容器依赖测试:
class BaseStruts2ActionTestentends StrutsTestCase {
protected void setUp() throws Exception {
super.setUp();
//
/**
* 关键是调用这个方法,使用在StrutsTestCase里被装入的所有provider来初始化XWorkTestCase下的
* ConfigurationManager configurationManager;
* Configuration configuration;
* Container container;
* ActionProxyFactory actionProxyFactory;
* 如果不调用这个方法重新构建configurationManager,将抛出java.lang.UnsupportedOperationException异常
*
*/
this.loadConfigurationProviders((ConfigurationProvider[]) this.configurationManager.getConfigurationProviders()
.toArray(new ConfigurationProvider[0]));
}
public void testXXXXXX(){
......
}
}
class BaseStruts2ActionTestentends StrutsTestCase {
protected void setUp() throws Exception {
super.setUp();
//
/**
* 关键是调用这个方法,使用在StrutsTestCase里被装入的所有provider来初始化XWorkTestCase下的
* ConfigurationManager configurationManager;
* Configuration configuration;
* Container container;
* ActionProxyFactory actionProxyFactory;
* 如果不调用这个方法重新构建configurationManager,将抛出java.lang.UnsupportedOperationException异常
*
*/
this.loadConfigurationProviders((ConfigurationProvider[]) this.configurationManager.getConfigurationProviders()
.toArray(new ConfigurationProvider[0]));
}
public void testXXXXXX(){
......
}
}
本文介绍如何在Struts2+Spring+Hibernate框架组合中,利用StrutsTestCase进行Action的容器依赖测试。通过加载配置提供者来初始化ConfigurationManager,确保测试环境正确设置。

1482

被折叠的 条评论
为什么被折叠?



