📄 resourceactiontest.java
字号:
package cn.myapps.core.resource.action;
import java.util.Collection;
import java.util.HashMap;
import junit.framework.TestCase;
import cn.myapps.core.resource.ejb.ResourceVO;
public class ResourceActionTest extends TestCase {
private ResourceAction action;
private ResourceVO vo=new ResourceVO();
private String description=null;
protected void setUp() throws Exception {
super.setUp();
action=new ResourceAction();
}
protected void tearDown() throws Exception {
super.tearDown();
}
/*
* Test method for 'cn.myapps.base.action.BaseAction.doEdit()'
*/
public void doEdit() throws Exception {
String id = action.getContent().getId();
HashMap mp = new HashMap();
mp.put("id", new String[] { id });
action.getContext().setParameters(mp);
action.doEdit();
}
/*
* Test method for 'cn.myapps.base.action.BaseAction.doSave()'
*/
public void testDoSave() throws Exception {
description="testxx11";
vo.setDescription(description);
action.setContent(vo);
action.doSave();
doView();
doList();
doEdit();
doDelete();
}
/*
* Test method for 'cn.myapps.base.action.BaseAction.doView()'
*/
public void doView() throws Exception {
String id = action.getContent().getId();
HashMap mp = new HashMap();
mp.put("id", new String[] { id });
action.getContext().setParameters(mp);
action.doView();
String afterViewId = action.getContent().getId();
assertEquals(afterViewId, id);
}
/*
* Test method for 'cn.myapps.base.action.BaseAction.doDelete()'
*/
public void doDelete() throws Exception {
String id = action.getContent().getId();
action.set_selects(new String[] { id });
action.doDelete();
ResourceVO r1=new ResourceVO();
ResourceVO r2=new ResourceVO();
action.setContent(r1);
action.doSave();
r2.setSuperior(r1);
action.setContent(r2);
action.doSave();
boolean flag=false;
try {
action.set_selects(new String[] { r1.getId() });
action.doDelete();
} catch (Exception e) {
flag=true;
}
assertTrue(flag);
boolean flag1=false;
try {
action.set_selects(new String[] { r2.getId() });
action.doDelete();
} catch (Exception e) {
flag1=true;
}
assertTrue(!flag1);
action.set_selects(new String[] { r1.getId() });
action.doDelete();
}
/*
* Test method for 'cn.myapps.base.action.BaseAction.doList()'
*/
public void doList() throws Exception {
HashMap mp = new HashMap();
mp.put("s_description", description);
action.getContext().setParameters(mp);
action.doList();
Collection data = action.getDatas().datas;
assertNotNull(data);
ResourceVO vo = (ResourceVO) data.iterator().next();
assertEquals(vo.getDescription(), description);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -