`
honlin
  • 浏览: 19676 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

spring的applicationContext的测试代码

    博客分类:
  • java
阅读更多
package com.mycompany.project.test;

import com.mycompany.project.dao.EmployeesDao;
import com.mycompany.project.model.Employees;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;

import java.util.List;

@ContextConfiguration(locations={"/applicationContext.xml"})
public class TestCase extends AbstractJUnit4SpringContextTests{

    @Autowired
    private EmployeesDao employeesDao;

    @Test
    public void testEmployeesDao(){
        List<Employees> list = employeesDao.findAll();
        System.out.println("list.size="+list.size());
    }

}

 

分享到:
评论

相关推荐

    spring4.1核心包

    15. spring-test-4.1.1.RELEASE.jar 支持Spring组建JUnit和TestNG的单元测试和集成测试。 16. spring-tx-4.1.1.RELEASE.jar 17. spring-web-4.1.1.RELEASE.jar 包含Web应用开发时,用到Spring框架时所需的核心类,...

    Spring Context测试

    学习spring组件扫描(Component Scanning)的代码 使用方法:直接把工程导入,直接Run project即可。 组件扫描自动进行主要在两个地方进行设置 1.applicationContext:键入 ...

    HttpServletRequst的mock实现基础上的测试案例介绍

    1.无maven,照样实现发布war中不含测试代码 在主工程中,不包含任何测试代码,理论上连main方法都不应该存在。测试代码常常放在与主工程同package的下面,以Test+className作为类名。由于采用了junit4,建议使用...

    Spring-Reference_zh_CN(Spring中文参考手册)

    2. Spring 2.0 的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 更简单的XML配置 2.2.2. 新的bean作用域 2.2.3. 可扩展的XML编写 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP XML配置 2.3.2. 对@AspectJ 切面的...

    Spring 3.0+Struts2+Mybatis 3 + p6spy 平台框架

    这是自己整合的Spring 3.0+Struts2+Mybatis 3 + p6spy +ehcache的平台框架,内含一点示例代码,目前ehcache没有使用。直接编译后发布就能用 测试环境基于JDK1.6+Tomcat 6.0. 大家拿到后请根据实际情况修改 ...

    Spring 2.0 开发参考手册

    2. Spring 2.0 的新特性 2.1. 简介 2.2. 控制反转(IoC)容器 2.2.1. 更简单的XML配置 2.2.2. 新的bean作用域 2.2.3. 可扩展的XML编写 2.3. 面向切面编程(AOP) 2.3.1. 更加简单的AOP XML配置 2.3.2. 对@...

    Spring中文帮助文档

    3.10. 以J2EE RAR文件的形式部署Spring ApplicationContext 3.11. 基于注解(Annotation-based)的配置 3.11.1. @Autowired 3.11.2. 基于注解的自动连接微调 3.11.3. CustomAutowireConfigurer 3.11.4. @...

    Spring API

    3.10. 以J2EE RAR文件的形式部署Spring ApplicationContext 3.11. 基于注解(Annotation-based)的配置 3.11.1. @Autowired 3.11.2. 基于注解的自动连接微调 3.11.3. CustomAutowireConfigurer 3.11.4. @...

    springmybatis

    重写测试代码 程序代码 程序代码 public static void main(String[] args) { SqlSession session = sqlSessionFactory.openSession(); try { IUserOperation userOperation=session.getMapper(IUserOperation....

    spring chm文档

    Spring Framework 开发参考手册 Rod Johnson Juergen Hoeller Alef Arendsen Colin Sampaleanu Rob Harrop Thomas Risberg Darren Davison Dmitriy Kopylenko Mark Pollack Thierry Templier Erwin ...

    Spring+MyBatis/Hibernate+Ehcache+Maven的Demo Web项目(稳定版)

    1.标题所提及技术的整合,Spring包括mvc、aop、ioc等。个人属于强迫症类型,技术水平怎么样再说,代码必须好看 2.Hibernate几个级别缓存对比。见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache...

    Spring.html

    --全局初始化参数--&gt; &lt;context-param&gt; &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt; &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt; 4.在Servlet中使用WebApplicationContextUtils获取容器...

    Spring框架1

    1.Spring概述 3.编写配置文件注册bean 4.代码测试 1.Spring的配置文件名常用applicationContext.xml 2.Bean在创

    spring考试通过必备材料.docx

    2、applicationContext.xml 总代码 4 不必着急 5 &lt;!—4、依赖注入 --&gt; 8 applicationContext.xml中Setter方法类之间的注入 8 applicationContext.xml 中Setter方法属性注入 User配置 8 applicationContext.xml构造器...

    Spring+MyBatis/Hibernate+Ehcache+Maven的Demo Web项目

    1.标题所提及技术的整合,Spring包括mvc、aop、ioc等。个人属于强迫症类型,技术水平怎么样再说,代码必须好看 2.Hibernate几个级别缓存对比。见DaoImpl类 3.Ehcache方法缓存及页面缓存。见applicationContext-cache...

    java8源码-Spring5:Spring5新特性

    AOP:面向切面,不修改源代码进行功能增强 Spring特点 方便解耦,简化开发 AOP支持 方便测试 如Junit5 集成其他框架 方便进行事务操作 降低APi开发难度 2.IOC容器 IOC底层原理 XML解析、工厂模式、反射 通过加载配置...

    OA办公自动化管理系统(Struts1.2+Hibernate3.0+Spring2+DWR)130224.rar

    它通过配置文件applicationContext.xml来管理Bean的创建和注入,降低了各个模块之间的耦合度,提高了系统的可测试性。DWR(Direct Web Remoting)作为Ajax框架,负责实现客户端与服务器端的异步通信。它可以实现在不...

    matlab改变代码字体-invesdwin-context:软件产品线的模块系统

    测试还得益于灵活的方法,即可以用存根替换Bean实例,根据情况选择要加载的不同spring-xmls并可以通过注释在每个测试的基础上启用嵌入式服务器(例如,webserver = jetty,database = h2)。 这些嵌入式服务器本身...

    java三大框架

    ·采用成功的框架的代码比自己的代码容易测试 J2EE本身提供了一些框架。比如, Enterprise Java-Beans (EJB) container或者 Servlet engine 而这些框架一般在中小工程中我们都不会使用,会让我们把大量的时间浪费...

    基于SSM框架的人力资源管理后台系统+源代码+文档说明+数据库

    (3)Spring容器配置文件:applicationContext.xml: 见resources/applicationContext.xml. (4)SpringMVC配置文件:springmvc.xml: 见resources/springmvc.xml. **3 测试** 写好上述配置文件后,可以在...

Global site tag (gtag.js) - Google Analytics