浏览 2925 次
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2008-05-21
例如: Struts2.0中的blank例子 中的 ConfigTest类 代码如下: package example; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.config.RuntimeConfiguration; import com.opensymphony.xwork2.config.entities.ActionConfig; import com.opensymphony.xwork2.config.entities.ResultConfig; import com.opensymphony.xwork2.config.providers.XmlConfigurationProvider; import java.util.Map; import java.util.List; import org.apache.struts2.StrutsTestCase; public class ConfigTest extends StrutsTestCase { protected void setUp() throws Exception { super.setUp(); XmlConfigurationProvider c = new XmlConfigurationProvider("struts.xml"); configurationManager.addConfigurationProvider(c); configurationManager.reload(); } protected void assertSuccess(String result) throws Exception { assertTrue("Expected a success result!", ActionSupport.SUCCESS.equals(result)); } protected void assertInput(String result) throws Exception { assertTrue("Expected an input result!", ActionSupport.INPUT.equals(result)); } protected Map assertFieldErrors(ActionSupport action) throws Exception { assertTrue(action.hasFieldErrors()); return action.getFieldErrors(); } protected void assertFieldError(Map field_errors, String field_name, String error_message) { List errors = (List) field_errors.get(field_name); assertNotNull("Expected errors for " + field_name, errors); assertTrue("Expected errors for " + field_name, errors.size()>0); // TODO: Should be a loop assertEquals(error_message,errors.get(0)); } protected ActionConfig assertClass(String namespace, String action_name, String class_name) { RuntimeConfiguration configuration = configurationManager.getConfiguration().getRuntimeConfiguration(); ActionConfig config = configuration.getActionConfig(namespace, action_name); assertNotNull("Mssing action", config); assertTrue("Wrong class name: [" + config.getClassName() + "]", class_name.equals(config.getClassName())); return config; } protected ActionConfig assertClass(String action_name, String class_name) { return assertClass("", action_name, class_name); } protected void assertResult(ActionConfig config, String result_name, String result_value) { Map results = config.getResults(); ResultConfig result = (ResultConfig) results.get(result_name); Map params = result.getParams(); String value = (String) params.get("actionName"); if (value == null) value = (String) params.get("location"); assertTrue("Wrong result value: [" + value + "]", result_value.equals(value)); } public void testConfig() throws Exception { assertNotNull(configurationManager); } } 当系统中包含struts2-spring-plugin-2.0.11.jar 后报 严重: ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ********** Looks like the Spring listener was not configured for your web app! Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext. You might need to add the following to web.xml: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> 尝试着修复这个问题 没能成功; 这是个bug么? 怎么做才能正常? 有人遇到和我一样的问题么? Strut2.0 + Spring + hibernate 用那种测试方法测试比较好? 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2008-07-23
SSH框架没有整合好 在web.xml中加入提示的代码
|
|
返回顶楼 | |
发表时间:2008-11-19
http://www.iteye.com/topic/194793
这上面能够解决你这个问题,但是ssh整合怎么测试,就没有回答了 |
|
返回顶楼 | |