• R7_141988
    了解作者
  • 40.3KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-08 02:47
    上传日期
NULL 博文链接:https://ylxy3058.iteye.com/blog/2225863
cygoattest.zip
内容介绍
package com.test; import java.lang.reflect.Proxy; import org.junit.Test; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; import org.springframework.core.io.ClassPathResource; import com.test.aop.Manager; import com.test.aware.ApplicationUtil; import com.test.bean.Person; import com.test.designermodel.proxymodel.AbstractRole; import com.test.designermodel.proxymodel.DynamicProxyRole; import com.test.designermodel.proxymodel.ProxyRole; import com.test.designermodel.proxymodel.RealRole; import com.test.designermodel.singletonmodel.Singleton; import com.test.jdkproxy.Action; import com.test.jdkproxy.ActionImp; import com.test.jdkproxy.HandlerImp; import com.test.proxy.SqlManager; public class JunitTest { /** * 测试BeanFactory */ // @Test public void testBeanFactory(){ ClassPathResource resource = new ClassPathResource("bean.xml"); DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(bf); reader.loadBeanDefinitions(resource); Person p = bf.getBean("person", Person.class); p.info(); } /** * 测试ApplicationContext */ // @Test public void testApplicationContext(){ ApplicationContext ctx = new FileSystemXmlApplicationContext("H:\\workspaceST\\cygoattest\\src\\test\\resources\\bean.xml"); Person p = (Person) ctx.getBean("person"); p.info(); } /** * 测试jdk动态代理 */ // @Test public void testJdkProxy(){ Action obj = (Action) Proxy.newProxyInstance(ActionImp.class.getClassLoader(), ActionImp.class.getInterfaces(), new HandlerImp(new ActionImp())); obj.action(); } /** * 测试Spring动态代理 */ // @Test public void testProxyFactoryBean(){ ApplicationContext bf = new FileSystemXmlApplicationContext("H:\\workspaceST\\cygoattest\\src\\test\\resources\\bean.xml"); SqlManager manager = (SqlManager) bf.getBean("factoryBean"); manager.insert(""); } /** * 测试Aware感知特性 */ // @Test public void testAware(){ ApplicationContext ctx = new FileSystemXmlApplicationContext("H:\\workspaceST\\cygoattest\\src\\test\\resources\\bean.xml"); ApplicationUtil util = (ApplicationUtil) ctx.getBean("applicationUtil",ApplicationUtil.class); System.out.println(util.getApplicationContext()); System.out.println(util.getBeanName()); } /** * 测试Spring Aop */ // @Test public void testSpringAop(){ ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml"); Manager manager = (Manager) ctx.getBean("manager"); System.out.println("------------------------测试插入方法---------------------------"); manager.insert("insert into sp_user(1,2,'1111')"); System.out.println("------------------------测试查询所有数据的查询方法---------------------------"); manager.findAll(); System.out.println("------------------------测试查询方法---------------------------"); manager.find("select * from sp_user"); } }
评论
    相关推荐
    • 单例模式
      NULL 博文链接:https://andydufresneone.iteye.com/blog/1156641
    • 单例模式
      NULL 博文链接:https://songjianyong.iteye.com/blog/1970689
    • 工厂模式与单例模式
      NULL 博文链接:https://zhaohong.iteye.com/blog/483396
    • 单例模式
      NULL 博文链接:https://terryjs.iteye.com/blog/716036
    • 几种单例模式
      NULL 博文链接:https://maozhetao.iteye.com/blog/2319348
    • Singleton 单例模式
      NULL 博文链接:https://walson.iteye.com/blog/392190
    • C#单例模式
      这里给的是C#里面一个单例模式的应用案例,面向对象过程中不可避免的需要用到单例模式,我在博客园中有详细说明单例模式怎么应用的,链接地址:https://www.cnblogs.com/yinxuejunfeng/p/9600633.html
    • 单例模式学习笔记
      NULL 博文链接:https://xiandaoyan.iteye.com/blog/663348
    • 单例模式详解
      NULL 博文链接:https://funine.iteye.com/blog/2426270
    • SIM800C_MQTT.rar
      使用SIM800C模块,使用MQTT协议,连接中国移动onenet平台,能实现数据的订阅、发布、存储等