import ioc.ClassPathXmlApplicationContext;
import module.model.User;
import module.service.UserService;
import module.serviceImpl.UserServiceImpl;

import org.junit.Test;

public class UserServiceImplJunit {
	
	/**
	 * 普通调用
	 * @methodName: test
	 * @description:
	 * @param 
	 * @return void
	 * @throws
	 # @eg:
	 */
	//@Test
	public void test() {
		User user = new User(1,"张三");
		
		UserService userService = new UserServiceImpl();
		
		userService.addUser(user);
	}
	
	/**
	 * 模拟ioc
	 * @methodName: test2
	 * @description:
	 * @param 
	 * @return void
	 * @throws
	 # @eg:
	 */
	
	@Test
	public void test2() {
		User user = new User();
		
		String xmlPath = "WebRoot/userBean.xml";
		UserService userService = (UserService) new ClassPathXmlApplicationContext(xmlPath).getBeanById("UserService");
		//验证反射生成的类是不是属于 Userservice
		boolean flg = userService instanceof UserServiceImpl;
		boolean flg2 = userService instanceof UserService;
		System.out.println("两个类是相同类型吗:"+flg);
		System.out.println("两个类2是相同类型吗:"+flg2);
		userService.addUser(user);
	}

}
最近下载更多
fuyouou  LV5 2023年7月7日
我睡觉时不困  LV7 2022年11月13日
快来救救胡桃  LV6 2022年1月6日
jwfadacai  LV8 2022年1月4日
jimshao289015254  LV9 2022年1月3日
懒得起  LV8 2020年8月31日
liuwenlong  LV20 2019年12月28日
13734993  LV7 2019年8月7日
freedom2017  LV14 2019年7月17日
Justnoolb  LV1 2019年6月27日
最近浏览更多
fuyouou  LV5 2023年7月7日
xuthus  LV1 2023年6月29日
GGadmin 2023年2月3日
暂无贡献等级
我睡觉时不困  LV7 2022年11月13日
QQ353251504 2022年2月24日
暂无贡献等级
快来救救胡桃  LV6 2022年1月6日
cuberbread  LV6 2022年1月6日
jwfadacai  LV8 2022年1月4日
jimshao289015254  LV9 2021年12月31日
WYH1346 2021年6月12日
暂无贡献等级
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友