⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 queryactiontest.java

📁 OBPM是一个开源
💻 JAVA
字号:
package cn.myapps.core.report.query.action;

import java.util.Collection;
import java.util.HashMap;

import junit.framework.TestCase;
import cn.myapps.base.action.BaseAction;
import cn.myapps.core.dynaform.dts.datasource.ejb.DataSource;
import cn.myapps.core.report.query.ejb.Query;

public class QueryActionTest extends TestCase {

	QueryAction action=null;
	Query vo=null;
	private String _paramsDefaultValue[];
	private String _paramsName[];
	String name=null;
	protected void setUp() throws Exception {
		super.setUp();
		action=new QueryAction();
		vo=new Query();
		_paramsDefaultValue=new String[2];
		_paramsName=new String[2];
	}

	protected void tearDown() throws Exception {
		super.tearDown();
	}

	/*
	 * Test method for 'cn.myapps.core.report.query.action.QueryAction.doSave()'
	 */
	public void testDoSave() throws Exception {
		QueryHelper helper=new QueryHelper();
		name="thrive";
		vo.setName(name);
		vo.setQueryString("select * from t_user where uesrname like $P{name} and  password  like $P{pwd}");
		action.setContent(vo);
        action.doSave();
		
        Collection params=helper.getParametersBySQL(vo.getQueryString());  
        _paramsName=new String[]{"name","pwd"};
        _paramsDefaultValue=new String[]{"peng","peng"};

    	HashMap mp = new HashMap();
        action.set_paramsDefaultValue(_paramsDefaultValue);
        action.set_paramsName(_paramsName);
        action.setContent(vo);
        action.doSave();
        doDelete();
	}

	/*
	 * 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.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();
		
	}

	/*
	 * Test method for 'cn.myapps.base.action.BaseAction.doList()'
	 */
	public void doDoList() throws Exception {
		HashMap mp = new HashMap();
		mp.put("s_name", name);
		action.getContext().setParameters(mp);
		action.doList();
		Collection data = action.getDatas().datas;
		assertNotNull(data);
		Query ds = (Query) data.iterator().next();
		assertEquals(ds.getName(), name);
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -