日期:2014-05-19  浏览次数:20773 次

在SSH环境下使用Junit的问题
使用Junit测试Action对象,Action对象有一个属性People使用了依赖注入,于是测试出现了了如下的错误,求解。

本意是想打印出“Hello World”,但是控制台出现如下的错误

WARNING:  [12:27.926] Couldn't determine real path of resource class path resource [org/apache/struts2/dispatcher/error_zh_CN.ftl]
WARNING:  [12:27.926] Couldn't determine real path of resource class path resource [org/apache/struts2/dispatcher/error_zh.ftl]
WARNING:  [12:27.926] Couldn't determine real path of resource class path resource [org/apache/struts2/dispatcher/error.ftl]


测试类

public class HelloActionTest extends StrutsSpringTestCase{

@Test
public void testExecute() throws Exception{
executeAction("/hello");
}

}


Action类

public class HelloAction extends ActionSupport {

private People people;

public String execute(){
people.hello();
return SUCCESS;
}

public void setPeople(People people) {
this.people = people;
}

}


People类

public class People {

private Long id;
private String name;

public void hello(){
System.out.println("Hello World!");
}

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

}

------解决方案--------------------
spring test!
------解决方案--------------------
谁知道为什么?求解
------解决方案--------------------
自己搞定了~