[j2ee][spring]使用UnitilsJUnit4进行测试
来源:互联网 发布:东方市网络诈骗2017 编辑:程序博客网 时间:2024/06/05 05:45
博客中有两篇文章介绍了spring和ibatis集成后的测试,现在介绍第三种方式,使用UnitilsJUnit4进行测试
代码如下:
package test.wendellup;import java.util.List;import org.junit.Before;import org.junit.Test;import org.springframework.context.ApplicationContext;import org.springframework.context.support.ClassPathXmlApplicationContext;import org.unitils.UnitilsJUnit4;import org.unitils.spring.annotation.SpringApplicationContext;import org.unitils.spring.annotation.SpringBeanByType;import com.wendellup.biz.ICountryService;import com.wendellup.entity.Country;@SpringApplicationContext( { "spring/applicationContext.xml" })public class TestCountryServiceImpl extends UnitilsJUnit4 {@SpringBeanByTypeprivate ICountryService iCountryService;//private ApplicationContext applicationContext;////@Before//public void setUp(){//applicationContext = //new ClassPathXmlApplicationContext("applicationContext.xml");//}@Testpublic void findByPinyinOrEnglish() throws Exception{Country country = new Country();country.setPinyin("meiguo");country.setEnglish("china");List<Country> CountryList = iCountryService.findByPinyinOrEnglish(country);for(Country c : CountryList){System.out.println(c);}}}
项目是实现类似于百度输入框输入信息会有下拉列表的功能,由于不是最新版本,所以访问有些问题(ajax那块),但是测试是正确的。
http://pan.baidu.com/share/link?shareid=226967&uk=3475027816
- [j2ee][spring]使用UnitilsJUnit4进行测试
- 使用junit进行Spring测试
- J2EE中使用Spring进行事务和异常设计
- 【j2ee spring】1、使用注释@Resource进行注入
- 使用spring-mock进行dao集成测试
- 使用Spring+Junit4.4进行测试
- 使用spring RestTemplate进行rest接口测试
- 使用Spring进行测试驱动开发
- 使用Spring+Junit4.4进行测试
- Spring下使用MockMvc类进行测试
- Spring项目使用JUnit4进行测试
- 使用spring RestTemplate进行rest接口测试
- 使用Spring+Junit4.4进行测试
- 使用Spring的测试机制进行集成测试
- Spring高级程序设计 21 使用Spring进行测试
- Mybatis集成Spring MVC,使用Spring test进行测试
- 使用Spring+Junit4.4进行测试(使用注解)
- 使用Spring+Junit4.4进行测试(使用注解)
- 2012年年度总结
- linux C 遍历目录及其子目录 opendir -> readdir -> closedir
- linux下面如何设置SSH服务开机启动?
- 邓仲祥:用甘肃地名命名的和政化石标本
- 缩进与对齐——正确地使用Tab和空格
- [j2ee][spring]使用UnitilsJUnit4进行测试
- C#取整函数实例应用详解
- jmeter的定时器学习
- 'libxml/tree.h' file not found
- GWT的未来?
- 安装 启动/关闭 开机启动/关闭ssh
- error C2065: : undeclared identifier 解决方法
- Eclipse 使用的注意 灵格斯 取词
- 扩展线程池ThreadPoolExecutor的简单例子