天天看点

写一个Junit类...在Spring中

public class AdminServiceTest extends TestCase {

	IAdminService adminService = null;

	protected ApplicationContext ac;
	@Override
         /**
          *开始时调用
            */
	public void setUp() throws IOException {
		ac = new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
		adminService = (IAdminService) ac.getBean("adminServiceBean");
	}

	@Override
         /**
          *结束时调用
            */
	protected void tearDown() throws Exception {

		ComboPooledDataSource dataSource = (com.mchange.v2.c3p0.ComboPooledDataSource) ac.getBean("dataSource");
		dataSource.close();

	}
	public void testAddUser () throws Exception{
               //写测试代码
	}