appfuse一套结合STRUTS+SPRING+HIBERNATE的框架
源代码在线查看: userlisttest.java
package org.appfuse.webapp.action;
import org.apache.tapestry.engine.RequestCycle;
import org.appfuse.service.UserManager;
import java.util.HashMap;
import java.util.Map;
public class UserListTest extends BasePageTestCase {
private UserList page;
protected void onSetUp() throws Exception {
super.onSetUp();
// these can be mocked if you want a more "pure" unit test
Map map = new HashMap();
map.put("userManager", applicationContext.getBean("userManager"));
page = (UserList) getPage(UserList.class, map);
}
protected void onTearDown() throws Exception {
super.onTearDown();
page = null;
}
public void testEdit() throws Exception {
RequestCycle cycle = new MockRequestCycle();
cycle.setServiceParameters(new Object[] {"tomcat"});
page.edit(cycle);
assertFalse(page.hasErrors());
}
public void testSearch() throws Exception {
assertTrue(page.getUserManager().getUsers(null).size() >= 1);
}
}