`

junit4 单元测试service(Spring)方法

阅读更多
import static org.junit.Assert.assertEquals;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.job36.admanage.service.AdAdTypeService;
import com.job36.admanage.vo.AdAdTypeVO;


public class AdTypeTest {
	ApplicationContext dsContext = null;
	AdAdTypeService adAdTypeService = null;
	AdAdTypeVO adAdTypeVO = null;

	@Before
	public void init() throws Exception {
		dsContext = new ClassPathXmlApplicationContext(new String[] {
				"applicationContext.xml", "applicationContext-dao.xml",
				"applicationContext-service.xml" });
		adAdTypeVO = new AdAdTypeVO();
		adAdTypeVO.setTypeId(1);
		adAdTypeVO.setTypeName("banner");
		adAdTypeVO.setMessage("测试");
		adAdTypeService = (AdAdTypeService) dsContext.getBean("AdAdTypeService");
	}

	@Test
	public void findByCondition() {
		assertEquals(adAdTypeService.findByCondition(adAdTypeVO).getListAdAdTypeVO().get(0), adAdTypeVO);
	}
}
分享到:
评论
3 楼 starlight_王亦 2012-05-21  
chen6485 写道
我的妈啊,这是90后MM技术员自己写的文章么?这也太假了吧?

怎么个假?
2 楼 cx372877498 2012-04-20  
刚刚需要,明天去试试。
1 楼 chen6485 2011-04-03  
我的妈啊,这是90后MM技术员自己写的文章么?这也太假了吧?

相关推荐

    spring+Junit4单元测试

    通过Spring集成单元测试,以后测试service层内容时,就不用getBean()来获得Service层对象了

    SpringBoot 多模块 Serivce 层单元测试

    IDEA Spring 多模块 Service 层单元测试, 此代码只演示Service层单元测试。。。。。。。。。。。。。。

    Struts2SpringUnitDemo单元测试

    Struts2 Spring 框架整合 单元测试 Action和Service http://blog.csdn.net/fansunion/

    JUnit4TestService

    Spring 提供Junit4的支持测试Demo.

    idea +junit单元测试获取不到bean注入的解决方式

    主要介绍了idea +junit单元测试获取不到bean注入的解决方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧

    java的单元测试和集成spring单元测试

    为了后期测试基于spring的单元测试,我们直接新建spring工程。新建之后,我们先讲一般在java项目中怎么去做单元测试。我们先定义一个实体User在service包中新建一个接口,在接口中定义一个方法,方法的返回值就是...

    Spring Boot从Controller层进行单元测试的实现

    主要介绍了Spring Boot从Controller层进行单元测试的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

    spring-restful-service-junit5:Spring Boot 2 REST API的JUnit 5测试用例

    Spring Boot 2 REST API的JUnit 5测试用例如何使用Spring Boot Test框架和JUnit 5对RESTful Web服务进行单元测试的示例。它使用MockMvc来提供Spring MVC基础结构,而无需启动HTTP Server。 SpringExtension和@...

    Spring.3.x企业应用开发实战(完整版).part2

    16.6 使用unitils测试Service层 16.7 测试Web层 16.7.1 对LoginController进行单元测试 16.7.2 使用Spring Servlet API模拟对象 16.7.3 使用Spring RestTemplate测试 16.7.4 使用Selenium测试 16.8 小结 第17章 实战...

    spring-database.zip

    一个空的Springboot2项目模板, 已包含druid和配置,能启动druid的监控平台 ;包括controller/service/entities和junit test的例子.

    springMVC+Spring+Mybatis+Maven整合代码案例

    5、测试Spring+mybatis的框架搭建,写单元测试JUnit,测试事务配置等:model-->dao(mapper)-->service-->test 6、映入SpringMVC:配置SpringMVC配置信息。-->配置文件:spring-mvc.xml(扫描controller) 7...

    Spring3.x企业应用开发实战(完整版) part1

    16.6 使用unitils测试Service层 16.7 测试Web层 16.7.1 对LoginController进行单元测试 16.7.2 使用Spring Servlet API模拟对象 16.7.3 使用Spring RestTemplate测试 16.7.4 使用Selenium测试 16.8 小结 第17章 实战...

    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 AOP配置源码

    此单元测试基于spring的AbstractJUnit4SpringContextTests,你需要添加spring的关于单元测试的支持 在类上标注@ContextConfiguration(locations="classpath:applicationContext.xml")意思是去classpath路径下加载...

    Spring LDAP 简单使用

    使用spring-ldap-core测试链接ldap com.ldap.test.service包下为Junit测试类

    Spring.html

    Spring整合Junit 1.导入依赖spring-test 2.加注解:RunWith、ContextConfiguration 3.注入对象进行测试 Spring整合web 1.导入依赖spring-web 2.配置ContextLoadListener 3.配置 <!--全局初始化参数-->...

    demo:Spring启动演示项目

    service 集成了dubbo,test目录下有dubbo消费者 Junit单元测试 service-api 接口 utils 工具类,简单封装了okhttp 3.0 web 使用的是spring推荐的模板引擎 thymeleaf ,优点是前后端可以很好的分离,理念界面即原型,...

    Restful_Service:Restful Service CRUD(Java,Spring,MySql,TDD,单元测试,Maven,eClipse)

    技术规格eClipse Luna MySQL 5.6.22 MySQL-工作台-6.2.4 Java 1.8 春天4 Hibernate4 Log4j 1.2 Maven的3.2 的JUnit4 Mokito 1.9 Apache Tomcat 85.部署指南下载项目的存档文件提取项目存档文件使用mvn clean install...

    Spring中文帮助文档

    8.2.2. 单元测试支持类 8.3. 集成测试 8.3.1. 概览 8.3.2. 使用哪个支持框架 8.3.3. 通用目标 8.3.4. JDBC测试支持 8.3.5. 常用注解 8.3.6. JUnit 3.8遗留支持 8.3.7. Spring TestContext Framework 8.3.8....

Global site tag (gtag.js) - Google Analytics