测试smartServer servlet的最佳方法是什么?

时间:2011-11-30 20:06:33

标签: java web-services junit cactus

我有以下Servlet方法,我想使用junit或Cactus为它创建测试。我尝试过Junit,但是在测试实现类,但我是测试WebServices的新手,所以我真的很感激任何帮助。 / p>

public DSResponse executeFetch(DSRequest req) throws Exception { 
DSResponse resp = new DSResponse(); 

String maID = (String) req.getCriteria().get("memberActivityID"); 
MemberActivityImpl memberImpl = new MemberActivityImpl(); 

MemberActivity memberAct = new MemberActivity(); 

if (req.getDataSourceName().equals("memberActivity")) { 
if (maID != null) { 
// Fetch the MemberActivity based on the memberActivityID criteria 
memberAct = memberImpl.getMemberActivity(maID); 

List<Map> resultList = new LinkedList<Map>(); 

if( memberAct != null && memberAct.getMemberID() != null ) 
    // Pass the memberAct to the client 
    Map<String, Object> result = new HashMap<String, Object>(); 
    result.put("name", memberAct.getName()); 
    result.put("type", memberAct.getType()); 
    result.put("memberID", memberAct.getMemberID()); 
    if (memberAct.getGoal() != null) { 
        result.put("goal", memberAct.getGoal());} 
        resultList.add(result); 
    } 
    resp.setData(resultList); 
} else { 
    resp.setFailure(); 
} 

`

0 个答案:

没有答案