📄 formactiontest.java
字号:
package cn.myapps.core.dynaform.form.action;
import java.io.File;
import java.io.PrintStream;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import javax.xml.registry.infomodel.User;
import junit.framework.TestCase;
import cn.myapps.base.action.ParamsTable;
import cn.myapps.base.dao.PersistenceUtils;
import cn.myapps.core.dynaform.document.ejb.Document;
import cn.myapps.core.dynaform.form.ejb.Form;
import cn.myapps.core.dynaform.form.ejb.TemplateParser;
import cn.myapps.core.user.action.WebUser;
import cn.myapps.core.user.ejb.UserVO;
public class FormActionTest extends TestCase {
FormAction action;
String name=null;
public static void main(String[] args) {
junit.textui.TestRunner.run(FormActionTest.class);
}
protected void setUp() throws Exception {
super.setUp();
action = new FormAction();
}
public void doList() throws Exception {
HashMap mp = new HashMap();
mp.put("s_name",name);
action.getContext().setParameters(mp);
action.doList();
Collection data = action.getDatas().datas;
assertNotNull(data);
}
public void testView() throws Exception {
name="formname1";
Form form = (Form)action.getContent();
form.setName(name);
form = TemplateParser.parseTemplate(form, form.getTemplatecontext());
action.setContent(form);
action.doSave();
String id = action.getContent().getId();
HashMap mp = new HashMap();
mp.put("id", new String[] { id });
action.getContext().setParameters(mp);
action.doView();
doList();
doDelete();
/*Collection errors=new HashSet();
ParamsTable params=new ParamsTable();
Document doc=new Document();
UserVO vo = new UserVO();
WebUser u=new WebUser(vo);
String s=form.toHtml(doc, params, u, errors);*/
String newHtmlfile = "test.html";
File htmlFile = new File("c:\\java\\"+newHtmlfile);
PrintStream ps = new PrintStream(htmlFile);
ps.print(form.getTemplatecontext());
ps.flush();
}
public void doDelete() throws Exception {
// //PersistenceUtils.getSessionSignal().sessionSignal++;
String id = action.getContent().getId();
action.set_selects(new String[] { id});
action.doDelete();
// //PersistenceUtils.getSessionSignal().sessionSignal--;
PersistenceUtils.closeSession();
}
public void testCreateDoc() {
}
protected void tearDown() throws Exception {
super.tearDown();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -