- 博客(8)
- 收藏
- 关注
原创 提取mybatis mapper接口
在使用mybatis 3.0的annotation之后,会产生大量mapper接口文件。使用下面这个类可以提取这些mapper的清单public final class MybatisMapperScanner extends ClassPathScanningCandidateComponentProvider { { addIncludeFilter(new Annot...
2013-03-16 19:22:06
264
原创 获取类的所有子类
开发过程中,有时需要获取某个包下的所有类,或者基于指定规则获取类清单。比较常见的解决方案是自己遍历目录,查找所有.class文件。下面这个方法使用spring工具类实现,简化过程,不再需要自己遍历目录 /** * 获取在指定包下某个class的所有非抽象子类 * * @param parentClass * ...
2013-03-16 19:15:10
825
更有效的mock,优化spring框架下的mock方法
本文主要是提供了一种解决方案,用于解决spring管理的测试用例在mock过程中,如何有效管理mock宿主和mock实体,并优化mock方法一、基础类1、Sping配置基础@ContextConfiguration(locations = { "classpath:spring.xml" })public abstract class BaseServiceTest extends...
2011-08-06 11:59:17
479
1
使用jmock测试System.in和System.out
本文要求读者已具备juit和jmock基础在TDD过程中需要测试代码中的System.in和System.out。技术难点包括1、mock宿主还原2、inout参数的行为模拟3、mock system.in和out1、测试主体@Serviceclass ConsoleManagerBizImpl{ private static Logger LOGGE...
2011-08-06 11:39:43
303
使用mybatis3.0 annotation接口简化数据访问
数据访问进化简史,比较简单,不负责能跑起来一、原始的sql select address from user where name='test' 二、jdbc //若干操作String sql="select address from user where name='"+name+"'";//执行//解析结果//包括若干个try catch...
2011-07-31 00:11:16
116
使用工厂方法mock测试方法体内中new出来的对象
本文假设读者已了解mock的基本定义,基础使用场景。本文的mock框架采用jmock1、mock经典测试场景class ToTest { private Member m; public void test(Varible v){ m.call(); v.call(); }}通过mock出一个m和v...
2011-07-22 10:29:48
1700
原创 另一个hosts文件
66.249.89.99 docs.google.com66.249.89.99 spreadsheets.google.com66.249.89.99 spreadsheets0.google.com66.249.89.99 docs1.google.com66.249.89.99 clients1.google.com66.249.89.99 clients2.google...
2011-07-20 13:23:20
120
原创 不使用中间变量交换两个int值
[code="java"]int a=1;int b=2;a=a+b;//a=3,b=2b=a-b;//a=3,b=1a=a-b;//a=2,b=1[/code]
2011-07-19 10:47:35
108
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人