JavaEE之SSH2整合技术实现 下载本文

http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop

http://www.springframework.org/schema/aop/spring-aop-3.0.xsd\>

class=\ destroy-method=\>

value=\ncoding=UTF-8\/>

--> \>

class=\

cn/edu/bean/Employee.hbm.xml

\>

hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.hbm2ddl.auto=update hibernate.show_sql=false hibernate.format_sql=false

class=\

步骤6:单元测试

1.右单击src,选择【New】->【Other】 ,操作如图7-13所示,弹出如图7-14所示窗口。

图7-13

图7-14

2.在图7-14所示窗口上单击Next后,弹出图7-15所示窗口。

图7-15

EmployeeServiceTest.java内容如下:

package junit.test;

import java.util.List;

import org.junit.BeforeClass; import org.junit.Test;

import org.springframework.context.ApplicationContext;

import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.edu.EmployeeService; import cn.edu.bean.Employee; import cn.edu.bean.Gender;

public class EmployeeServiceTest { private static EmployeeService employeeService; @BeforeClass public static void setUpBeforeClass() throws Exception { try { ApplicationContext act = new ClassPathXmlApplicationContext(\

employeeService = (EmployeeService)act.getBean(\ } catch (RuntimeException e) { // TODO Auto-generated catch block e.printStackTrace(); } } @Test public void save(){ employeeService.save(new Employee(\ employeeService.save(new Employee(\ employeeService.save(new Employee(\ employeeService.save(new Employee(\ employeeService.save(new Employee(\ } @Test public void update(){ Employee employee = employeeService.find(\ employee.setGender(Gender.WOMAN); employeeService.update(employee); }