日期:2014-05-20 浏览次数:20896 次
package com.spring.service; import org.junit.Test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import com.spring.model.User; import com.spring.service.UserService; public class UserServiceTest { @Test public void testAddUser(){ System.out.println("--test---"); ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); UserService us =(UserService)ctx.getBean("userService", UserService.class); User u = new User(); u.setName("张三"); u.setAge(11); us.addUser(u); } }