• spring-test测试demo


    如果是maven项目,pom中增加如下依赖:

    <dependency>
                <groupId>org.springframework</groupId>
                <artifactId>spring-test</artifactId>
                <version>3.1.1.RELEASE</version>
    </dependency>

    import org.apache.log4j.Logger;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

    import com.alibaba.fastjson.JSON;
    import com.joey.model.InfoCfg;
    import com.joey.model.UrUser;
    import com.joey.service.InfoCfgServiceI;
    import com.joey.service.UrUserServiceI;

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "classpath:spring.xml", "classpath:spring-mybatis.xml" })
    public class TestMybatis {

        //public ApplicationContext ac;
        private static final Logger logger = Logger.getLogger(TestMybatis.class);

        private InfoCfgServiceI infoService;
        private UrUserServiceI uruserService;

    /*    @Before
        public void before(){
            ac=new ClassPathXmlApplicationContext(new String[]{"spring.xml","spring-mybatis.xml"});
            uruserService = (UrUserServiceI)ac.getBean("uruserService");
            infoService = (InfoCfgServiceI)ac.getBean("infoService");

        }*/
        
        @Test
        public void test1() {
            InfoCfg u = infoService.get****(2985l); //相关业务方法
            logger.info(JSON.toJSONStringWithDateFormat(u, "yyyy-MM-dd HH:mm:ss"));
        }
        
        @Test
        public void testUser() {
            UrUser u = uruserService.******(285l);  //相关业务方法
            //logger.info(JSON.toJSONStringWithDateFormat(u, "yyyy-MM-dd HH:mm:ss"));
            logger.info(u.getUserId()+",,,,"+u.getCompany());
        }

        public InfoCfgServiceI getInfoService() {
            return infoService;
        }

        @Autowired
        public void setInfoService(InfoCfgServiceI infoService) {
            this.infoService = infoService;
        }

        public UrUserServiceI getUruserService() {
            return uruserService;
        }

        @Autowired
        public void setUruserService(UrUserServiceI uruserService) {
            this.uruserService = uruserService;
        }
    }

  • 相关阅读:
    实现微信朋友圈点击评论按钮时cell上移
    UITableView的横向使用
    用Xcode6的Leaks检测内存泄漏
    IOS8设备连接XCODE6真机调试报错"Could not inspect the application package"
    Implicit declaration of function 'ether_ntoa' is invalid in C99
    .xcodeprok cannot be opened because the project file cannot be parsed
    根据图片的链接获取图片的宽高
    关于UIWebView设置高度自适应的问题
    reason: 'data parameter is nil'
    CSS图标文字对齐和表单输入框文字对齐兼容
  • 原文地址:https://www.cnblogs.com/xifenglou/p/6185734.html
Copyright © 2020-2023  润新知