基于spring 的单元测试
需要引用的依赖:
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
maven依赖为:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:applicationContext-springService.xml" })
public class DistributeServiceTest {
@Resource
DistributeService distributeService;
@Test
public void testGetStatisticsByChannel() {
long beginTime = 0;
long endTime = 1545615321794L;
List<Distribute> distributeInfo = new ArrayList<>(3);
Distribute distribute = new Distribute();
distribute.setChannelNo("1055100004");
distributeInfo.add(distribute);
distributeService.getStatisticsByChannel(distributeInfo, beginTime, endTime);
Assert.assertTrue(distributeInfo.get(0).getAndroidTotal().equals("3"));
}
@Test
public void test() {
System.out.println(123);
}
}
基于spring 的单元测试的更多相关文章
- 基于spring与mockito单元测试Mock对象注入
转载:http://www.blogjava.net/qileilove/archive/2014/03/07/410713.html 1.关键词 单元测试.spring.mockito 2.概述 单 ...
- step6----->往工程中添加spring boot项目------->修改pom.xml使得我的project是基于spring boot的,而非直接基于spring framework
文章内容概述: spring项目组其实有多个projects,如spring IO platform用于管理external dependencies的版本,通过定义BOM(bill of mater ...
- Spring实战5:基于Spring构建Web应用
主要内容 将web请求映射到Spring控制器 绑定form参数 验证表单提交的参数 对于很多Java程序员来说,他们的主要工作就是开发Web应用,如果你也在做这样的工作,那么你一定会了解到构建这类系 ...
- 基于Spring设计并实现RESTful Web Services(转)
基于Spring设计并实现RESTful Web Services 在本教程中,你将会使用Spring来创建一个具有生产力的RESTful网络服务. 为什么用RESTful网络服务? 从和Amazon ...
- Spring Boot 单元测试示例
Spring 框架提供了一个专门的测试模块(spring-test),用于应用程序的单元测试. 在 Spring Boot 中,你可以通过spring-boot-starter-test启动器快速开启 ...
- 基于Spring Boot/Spring Session/Redis的分布式Session共享解决方案
分布式Web网站一般都会碰到集群session共享问题,之前也做过一些Spring3的项目,当时解决这个问题做过两种方案,一是利用nginx,session交给nginx控制,但是这个需要额外工作较多 ...
- 基于Spring的可扩展Schema进行开发自定义配置标签支持
一.背景 最近和朋友一起想开发一个类似alibaba dubbo的功能的工具,其中就用到了基于Spring的可扩展Schema进行开发自定义配置标签支持,通过上网查资料自己写了一个demo.今天在这里 ...
- 基于Spring MVC的Web应用开发(三) - Resources
基于Spring MVC的Web应用开发(3) - Resources 上一篇介绍了在基于Spring MVC的Web项目中加入日志,本文介绍Spring MVC如何处理资源文件. 注意到本项目的we ...
- RESTLET开发实例(三)基于spring的REST服务
http://www.lifeba.org/arch/restlet_spring_3.html 前面两篇文章,我们介绍了基于JAX-RS的REST服务以及Application的Rest服务.这里将 ...
随机推荐
- python %s深入解析
默认我们通常用字符串填充它 'Keep %s, and you will aways make %' % ('moving', 'it') 如果你就此止步,那就错过了一些神乎其技的用法 比如: arr ...
- 一个国家专利查询demo
写了一下午,借鉴apache的 httpclient 源码 调用 写的,拿出来分享一下,可以用作其他不同平台的项目post/get数据上面. package cn.shb.test; import o ...
- SoapUI 设置 request data with json body
--背景 使用WCF定义REST风格的WebService,如下: [ServiceContract] public interface INISTService { [Op ...
- Ubuntu配置svn
http://www.cnblogs.com/arrongao/archive/2013/03/30/linux_svn.html
- 网络编程之addrinfo
addrinfo结构体定义如下: typedef struct addrinfo { int ai_flags;//指示在getaddrinfo函数中使用的选项的标志. int ai_family; ...
- error C2144: 语法错误:“int”的前面应有“;”
百度网上都说是中文输入的问题. 但我的错误是函数声明时后面忘了加 :真是要死......
- PV操作
学习PV操作之前,我们首先来了解两个很基础的概念: 同步.互斥: 同步:其实说同步还不如说”协作“,就是我们的目标只有一个,我们奔着同一个目标去的,都是在大家的努力下共同完成这么一件事情.还是比较容易 ...
- redis数据类型之—String
(1)String 简单介绍 string是redis中最基本的数据类型,一个字符串类型的值存储的最大容量是1GB. (2)String 常用命令
- node 关键点总结
1.I/O密集的地方尽量不要用require.(require是同步I/O操作) eg:正在运行一个HTTP服务器,如果在每个进入的请求上都用了require,就会遇到性能问题.所以通常在程序最初加载 ...
- Node.js学习之简介
1.简单的说Node.js就是运行在服务端的javaScript: 2.Node.js是一个基于Chrome javaScript运行时建立的一个平台: 3.Node.js是一个事件驱动I/O服务端J ...