zl程序教程

您现在的位置是:首页 >  后端

当前栏目

Spring测试类代码编写(二)

2023-09-14 09:02:02 时间
package test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.zxl.aop.IOrderService;
import com.zxl.aop.OrderServiceImpl;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations="classpath:applicationContext.xml")
public class Aop1Test {
	@Autowired
//	@Qualifier("orderServiceProxy") //aop1.xml
	private IOrderService orderService;
	@Test
	public void test1(){
		orderService.updateOrder();
//		ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
//		OrderServiceImpl orderService = (OrderServiceImpl) applicationContext.getBean("orderService");
//		orderService.addOrder();
	}
}