Comments (4)
Final方法就是不希望你去修改。JDK中有大量final方法,spring中也有很多,我不觉得对测试有什么影响。不知道你所说的“脱离容器测试”是什么意思?URIBroker就是一个bean,你直接创建它就行了,不需要mock。
from citrus.
如果不是final,when(uriBrokerService.getURIBroker(anyString()).render()).thenReturn("http://foo.bar") ; 这样的mok会很easy
from citrus.
URIBroker broker = new GenericURIBroker();
broker.setBaseURI("http://foo.bar"); 好吧,GenericURIBroker创建的成不确实不高,不需要依赖webx
from citrus.
你这个代码即使对于URIBroker做成接口也是行不通的。
我给你个代码建议:(使用EasyMock)
import static org.easymock.EasyMock.*;
import com.alibaba.citrus.service.uribroker.URIBrokerService;
import com.alibaba.citrus.service.uribroker.uri.GenericURIBroker;
import com.alibaba.citrus.service.uribroker.uri.URIBroker;
public class Test {
public static void main(String[] args) {
URIBroker uri = new GenericURIBroker().setServerURI("http://aaa.com/bbb");
URIBrokerService uris = createMock(URIBrokerService.class);
expect(uris.getURIBroker("myuri")).andReturn(uri.fork()).anyTimes();
replay(uris);
URIBroker myuri = uris.getURIBroker("myuri");
System.out.println(myuri.render());
verify(uris);
}
}
在 2012-7-26,下午7:41,jilen [email protected] 写道:
如果不是final,when(uriBrokerService.getURIBroker(anyString()).render()).thenReturn("http://foo.bar") ; 这样的mok会很easy
Reply to this email directly or view it on GitHub:
#12 (comment)
from citrus.
Related Issues (20)
- 如何在程序中对cookie进行设置maxAge? HOT 1
- webx中form表单的验证取值问题 HOT 1
- bug report - webx3 在构造rundata parameters的时候 如果发现是文件上传就会忽略 请求url上的参数 HOT 3
- 参数注解在使用cglib的时候有bug?
- webx3中如何添加自定义velocity块指令?
- webx 对 spring4 的支持 HOT 5
- 代码好久没更新了,官方还维护吗 HOT 2
- webx应用petstore启动报错
- 支持servlet3.1么 HOT 2
- http://www.openwebx.org/无法访问
- 文档9.3.1.2表述有误
- webx怎么按模块打包?
- 不用maven配置webx,所有的配置文件都不生效
- webx 处理json请求的循环引用问题
- 官网无法访问 HOT 5
- webX现在支持spring4吗?
- when post args contain 'ञ' ,get the param is change "" HOT 3
- webx spring版本过低
- 解决在IDEA里,autoconfig在跑JUnit测试时,不能输入的问题 HOT 12
- 配置切面不生效
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from citrus.