Junit4测试Spring
2
3 import javax.annotation.Resource;
4
5 import org.junit.Test;
6 import org.junit.runner.RunWith;
7 import org.springframework.test.context.ContextConfiguration;
8 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
9
10 @RunWith(SpringJUnit4ClassRunner.class)
11 @ContextConfiguration(locations={"../../../../applicationContext.xml","../../../../applicationDatasource.xml"})
12 public class UserServiceTest {
13 @Resource
14 private IUserService userService;
15
16 @Test
17 public void testAddOpinion1() {
18 userService.downloadCount(1);
19 System.out.println(1);
20 }
21 @Test
22 public void testAddOpinion2() {
23 userService.downloadCount(2);
24 System.out.println(2);
25 }
26 }
27
注意需要新的Jar包如下
javassist-3.4.GA.jar
hibernate3.jar
hibernate-annotations.jar
尤其注意用新版的,旧版会出现类未找到的异常
Junit4测试Spring的更多相关文章
- web项目中 集合Spring&使用junit4测试Spring
web项目中 集合Spring 问题: 如果将 ApplicationContext applicationContext = new ClassPathXmlApplicationContext(& ...
- 使用JUnit4测试Spring
测试DAO import static org.junit.Assert.*; import org.junit.Before; import org.junit.Ignore; import org ...
- junit4测试 Spring MVC注解方式
本人使用的为junit4进行测试 spring-servlet.xml中使用的为注解扫描的方式 <?xml version="1.0" encoding="UTF- ...
- 就是这么简单(续)!使用 RestAssuredMockMvc 测试 Spring MVC Controllers
就是这么简单(续)!使用 RestAssuredMockMvc 测试 Spring MVC Controllers 转载注明出处:http://www.cnblogs.com/wade-xu/p/43 ...
- JUnit4 测试示例
1. JUnit4 测试示例 // Calculator.java public class Calculator{ public int add(int a, int b){ return a + ...
- (转)编写Spring的第一个案例并测试Spring的开发环境
http://blog.csdn.net/yerenyuan_pku/article/details/52832145 Spring4.2.5的开发环境搭建好了之后,我们来编写Spring的第一个案例 ...
- Junit4 测试代码
Junit4 测试代码 import org.junit.Test; import org.junit.runner.RunWith; @RunWith(SpringJUnit4ClassRunner ...
- 利用Spring的junit4测试
利用Spring的JUnit4进行测试 不需要再显式创建Spring容器和getBean @RunWith(SpringJUnit4ClassRunner.class) @ContextConfigu ...
- spring中试用junit4测试
一:加入jar包 <!-- 单元测试 --> <dependency> <groupId>junit</groupId> <artifactId& ...
随机推荐
- 非负矩阵分解(4):NMF算法和聚类算法的联系与区别
作者:桂. 时间:2017-04-14 06:22:26 链接:http://www.cnblogs.com/xingshansi/p/6685811.html 声明:欢迎被转载,不过记得注明出处 ...
- 面试题 ARC
什么是ARC ?ARC主要解决什么问题? ARC:自动引用计数. 要点..当对象被创建时 retain count+1, 当对象被release时 retain count-1, 当retain co ...
- IOS 程序运行过程
第一次写有点小紧张 希望大家多多指教! 主要讲讲程序从点击运行到结束这个过程中后面的代码都有哪些变化. 首先先了解一下UIApplication.UIApplication的核心作用是提供IOS运行 ...
- 实时监听input标签输入 实时监听文本框输入 避免中文输入法无法触发onkeyup事件的问题
前言: 对于实时监听输入,这种需求大多数都是用于一个联想字提醒,智能提醒.大家都知道onkeydown,onkeypress,onkeyup的在监听中文输入法或者右键粘贴的时候都存在一些弊端,不是那么 ...
- 基于Prism.Windows的UWP开发备忘
以前做UWP开发都是使用MvvmLight,主要是简单易上手,同时也写了很多MvvmLight的开发系列文章: UWP开发必备以及常用知识点总结 UWP开发之Mvvmlight实践九:基于MVVM的项 ...
- java异常处理机制(try-catch-finally)
/* * 异常处理机制 * 1.分类:Error和Exception * Error错误是JVM自动报错的,程序员无法解决例如开数组过大int a[]=new int [1024*1024*1024] ...
- 使用charles抓取htpps的方法
自己整理的步骤做个记录 1.下载证书,官方地址:http://www.charlesproxy.com/ssl.zip 可直接点击链接下载:http://charlesproxy.com/getssl ...
- PHP 学习笔记(2)
<?php$foo = "0"; // $foo 是字符串 (ASCII 48)$foo += 2; // $foo 现在是一个整数 (2)$foo = $foo + ...
- PHP 手册
http://www.php.net/manual/zh/index.php 感谢中文翻译工作者. PHP 手册¶ by:Mehdi Achour Friedhelm Betz Antony Dovg ...
- python循环
#!/usr/bin/python #coding:utf-8 lcf_age = "19" count = 0 while count < 3: c_lcf_age = i ...