码迷,mamicode.com
首页 > 其他好文 > 详细

JUnit中的invoke

时间:2015-03-09 10:46:22      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:

AAAAServlet.java:
protected void execute(HttpServletRequest req, HttpServletResponse res, DataSource ds) {************}

AAAAServlet.javaをテスト
Class<? extends Object> clazz = AAAAServlet.class;
Method method = clazz.getDeclaredMethod("execute", HttpServletRequest.class, HttpServletResponse.class, DataSource.class);
method.setAccessible(true);
MockRequest req = new MockRequest();
req.setParameter(key, value);
MockResponse res = new MockResponse();
method.invoke(new AAAAServlet(), req, res, ds);
assertEquals(actualValue, res.getDocument());

 

JUnit中的invoke

标签:

原文地址:http://www.cnblogs.com/taobr/p/4322826.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!