trainintentactiontest.java

来自「人力资源管理系统」· Java 代码 · 共 52 行

JAVA
52
字号
package org.HumResManSys.action;

import static org.junit.Assert.*;

import java.io.File;

import javax.servlet.http.HttpSession;

import org.HumResManSys.actionForm.Emp_trainForm;
import org.HumResManSys.service.EmployeeService;
import org.HumResManSys.vo.Employee;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import servletunit.struts.MockStrutsTestCase;

public class TrainIntentActionTest extends MockStrutsTestCase{

	@Before
	public void setUp() throws Exception {
		super.setUp();
		this.setContextDirectory(new File("WebRoot"));
	}

	@Test
	public void testAddTrainIntent() {
		setRequestPathInfo("/TrainIntentAction");
		addRequestParameter("method","addTrainIntent");
		
        Emp_trainForm train_intent = new Emp_trainForm();
		
        train_intent.setDept_name("人事部");
        train_intent.setAttitude("我想参加编程培训");
        this.setActionForm(train_intent);
        
        ApplicationContext ac=
			new ClassPathXmlApplicationContext("/applicationContext.xml");
		
		EmployeeService emp=(EmployeeService)ac.getBean("EmployeeService");
		Employee oneEmpInfo = emp.showSelfInfos("王春来");
		
		HttpSession session=this.getSession();
		session.setAttribute("oneEmpInfo",oneEmpInfo);
		
		actionPerform();
		verifyForward("YXSuccess");
	}

}

⌨️ 快捷键说明

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